Advertisement

Racing AI with time constraint

Started by August 28, 2012 08:27 PM
7 comments, last by LorenzoGatti 12 years, 2 months ago
Hello community I have an atypical question for you. I am working on a car AI for a racing game. I am not allowed to disclose specific details, so don't try to find logic in next sentence :). We want a mod where AI would always reach the goal at a particular time ie. first checkpoint in 15 sec, second in 10 sec etc. Actually that describes the problem pretty well. Let's say we have only one car, realistic physics engine, and we want our AI to be able to drive to checkpoints for the given time. Note that "cheating" the pysics is allowed.

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 :).
Ooohhh... fun with rubber-banding!

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!"

Advertisement
Thank you Dave for a prompt reply.
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.
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.

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.
If that's all you are trying to solve, then either pre-baking the speeds into the track or "solving" the remaining track to feed your parameters are, indeed, the best bet.

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!"

Advertisement
Okay.... I like Dave Mark's approach. Maybe break the track into good and bad lines (with the ability to switch between them). Create a series of segments of those lines with best and worst case times for the segments (assuming no physics cheating or accidents). This will allow you to set bounds on how long is remaining to the finish line. If the best case is greater than the desired remaining time, turn physics cheating on. If the worst case is lower than the desired remaining time, have an accident or do something else stupid. Otherwise switch between the good and bad lines for the next segment depending upon whether you are over or under the desired time.
Hey guys, i tried to prototype this but it looks to unrealistic so far, it looks like we are going go abandon this idea. Thank you all.
Can you estimate the time that is going to be wasted in typical interference cases? For example, overtaking a slow car ahead, or waiting for two cars to separate before having room to pass them? Even a conservative or inexact estimate would be very useful: the car could accelerate smoothly in advance by the right amount, and avoid unpleasant sudden speed changes.

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

This topic is closed to new replies.

Advertisement