State and Object Oriented Programming - 2. Introduction to State

What is status?

When you locate a vehicle, all you care about is the vehicle's position and movement.

These two are called the state of the vehicle.

  • The state of any system is a set of values ​​that we care about.

In the case we are currently concerned with, the state of the vehicle includes its current position x and velocity v .

In code, it looks like this:

x = 4
vel = 1

state = [x, vel]
 

Predict future states

The state gives us most of the information we need to predict the future location of the vehicle. In this lesson, we'll see how states are represented and how they change over time.

 

For example, suppose our world is a one-lane road, and we know that the vehicle's current position is at the start of the road, at 0 meters. We also know the speed of the vehicle: moving at 50 m/s. These values ​​are its initial state.

state = [0, 50]
 

Estimation of the initial state of the vehicle

 

practice questions

Using our state notation, what do you think the new state will be after 3 seconds?

  • [0,50]

  • [50,50]

  • [150,50]

  • [150,0]

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325294284&siteId=291194637