Early Design - Attributes, Checkpoints & Racing AI
EJ5Y_Cameron_McAvoy 270005EJ5Y Comment (1) Visits (2395)
This blog post is the first of many writeups about our (Mark, Nick, and my) progress on the top down racing game.
Users will be able to customize cars by the attributes they invest in them. The current game only has a few functional attributes (acceleration, weight, turning, traction) but we plan on expanding these in later iterations. Attributes are invested in a poin
One of the early challenges in designing a top down racer is teaching the AI to follow the track. Cars aren't aware of the track, and with a variety of environments and track layouts, pattern recognition would be very difficult. We initially decided to use a checkpoint system, which involves placing a predefined list of points for each track, so the cars have a "guidepost" to follow and attempt to aim for so they remain on track. Our early design was exactly as described, a JSON list of x, y points that corresponded to points on the track that the cars were meant to follow.
It worked - partially. There was difficulty in determining when a car should advance towa
Our solution was to turn checkpoints into a line instead of a fixed point. Checkpoints went all the way across the track, much like ski gates. Cars don't aim for the center checkpoint, they just attempt to cross the line at the best intersection point [best being the intersection point that involves the least turning to still intersect the checkpoint]. These line-checkpoints are invisible to the user, but the AI uses them as guides to navigate the track.
Another early issue was the AI design - we needed to provide an event driven AI that could guide the car through the track and also react to different situations. Our initial design was a completely reaction driven AI design. Cars had an AI that listened to events, and responded to each event. Events were fired for the race start, checkpoints being reached, if the car goes off-track, if an opponent moves in proximity, obstacles, and other related situations. The AI did not have any long term memory, it did not remember what previous events have been fired and did not have any long-term strategy.
There are several problems with this design that we encountered. In a best case, cars have little difficulty navigating the track, but other cars and obstacles often pose a problem. Because the AI only responds to the last event it receives, it might end up ignoring the track to escape another car, and end up worse off if it had simply collided. Or it might get stuck off track, and not be able to recover.
The Race-AI is not a problem we have completely solved, but we are experimenting with a strategy system that allows the AI to have longer-term goals, and pick and choose which events to respond to, based on the current situation.