Racing AI with time constraint
So far we have that drives around the track aggresively and really fast. I was thinking about implementing a pid controller for car speed, where my control variable would be projected time (from current acceleration and velocity) to reach the checkpoint, and tweak the throttle accordingly. However I am unsure how exactly I would tweak the throttle, and what other factors should I look after, or even if this method would give good passing times (tolerated margin of error would be +-0.5sec).
What do you think of my idea, or do you have other ideas for this particular problem? Some other guidances would be helpful also, like general vehicle AI tips and tricks and/or books, because I am really inexperienced in this field, yet I have a really responsible job of implementing this stuff, and I have done a good job so far .
Sounds like you are on the right track as far as what to tweak. The problem you have to look for is that hard targets on time can be a problem if they are the only (or primary) consideration. Imagine that the player restricts the car from going -- either intentionally or unintentionally (crashes). Once released from this restriction, the car will be so desperate to catch up that it will accelerate very unrealistically to do so. You need to make sure that you have other reasonable restrictions such as rate of acceleration, speed, etc. and just live with the consequences.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
It is nice that you pointed out this situation where a player could restrict intentionally an AI car, and then it would accelerate unrealistically, but this situation is prohibited by design. Other situation is where other AI cars restrict each other unintentionally, and this is a whole other set of problems, and I still havent wrapped my head around it fully. My first thought are that I should imeplement some kind of master mind AI that would look after car agents (like a flock) and would prohibit them from getting into dangerous situations. I would also tweak the physics layer when necessary to avoid sideslips off track or something similar. This would yield unrealistic results sometimes (but rarely) but it's a tradeoff we have to pay.
But so far my first question remains, before I start to work on a full race. Let's just say we have one car and time constraints. I have to figure this out before I go to vacation . I will try to implement something by tommorow and I wil report.
As far as slowing it down, there's all kinds of driver errors you could introduce, e.g. taking a bad line, bad gear changes, braking too early/late for a corner, going too aggressive and slipping/spinning out. For going faster that optimum driving with physics.... I guess instant gear changes, super-grippy tires with no wear, advance knowledge of track condition, a slight horsepower boost, cars assisting each other.
I think the challenge would be to make the car look like it's trying to win, regardless of whether it gets 10 seconds or 15. If a car looks like it's taking it easy on you, e.g. driving very slowly, it's a bad look. Also not breaking physics too much to go fast.
Hi jeffery, thank you for showing up on this thread.
But it looks like you didn't understand my problem. This is not a classical human vs AI race, and I am not allowed to disclose specific details so I simplified my problem like this: What do you think would be a good method for implementing a vehicle AI that has a feature that it can always reach checkpoints on predetermined times.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
Another suggestion: probably, not all cars have equally tight time constraints, and even if they do some have an earlier deadline: lower priority cars should cooperate by moving out of the way, so that many cars are slowed frequently by acceptable and recoverable amounts and none risk missing the deadline.
Omae Wa Mou Shindeiru