(Sorry, not sure whether this belongs here on the Physics StackExchange or the Math StackExchange.)
I'm creating a computer game in which there is a computer-controlled car that needs to travel along a straight line (thus making this problem effectively 1-dimensional) and reach a destination coming to a rest at 0 velocity. This car "thinks" every second and decides whether (and by how much) to accelerate or decelerate.
Here are the variables the car knows about:
Dist= Our current distance to the destination in meters
Vel= Our current velocity towards the destination in meters/second
MaxAccel= The maximum amount by which we can increase our velocity every second.
MaxDecel= The maximum amount by which we can decrease our velocity every second.
Accel= The change in velocity per second. The car can change its acceleration every second to any number in the range [-MaxDecel, MaxAccel].
Drag= The amount by which the car's velocity is reduced every second, as a fraction of its current velocity that second.
So to be as clear as I can, here's the math that runs every second to update the car simulation:
Accel = some amount between [-
MaxAccel] as chosen by the computer
New_Vel = (
Accel) * (1 -
So my question is: Every time the car "thinks", what formula(s) should it use to determine the ideal value of
Accel in order to reach its destination (with a 0 final velocity) in as little time as possible? (Approximate solutions are acceptable.)
(In the event that the car's initial velocity is too high and it can't decelerate fast enough to achieve 0 velocity by the time it reaches its destination, then it should come to a rest as close as possible to the destination.)
Please let me know if you have any questions.