Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a school project to build an AI for a 2D racing game in which it will compete with several other AIs (no collision).

We are given a black and white bitmap image of the racing track, we are allowed to choose basic stats for our car (handling, acceleration, max speed and brakes) after we receive the map. The AI connects to the game's server and gives to it several times a second numbers for the current acceleration and steering. The language I chose is C++, by the way. The questions are:

What is the best strategy or algorithm (since I want to try and win)? I currently have in mind some ideas found on the net and one or two of my own, but I would like before I start to code that my perspective is one of the best. What good books are there on that matter? What sites should I refer to?

share|improve this question
1  
It would depend on the accuracy of the physics simulation. If there is no physics, I'd go full speed all the time... otherwise, I'd start slowing down before each turn and speed up 2/3rd through the turn. –  Nate Feb 21 '11 at 22:45

3 Answers 3

Set up a basic AI, then set up an API to handle your own car. If you can beat it, you should set up a recording algorithm that can then positively reinforce your AI. This could be a neural network to tweak your AI's actions. Such as gradual braking into a corner etc.

Are you allowed to use external libraries in your project? If so, I suggest you look at FANN. It is a fast neural network library; to save you writing your own. If you need the source code, you could always write it yourself, it can take some time however.

share|improve this answer
1  
Seems overkill to me. –  Lohoris Feb 22 '11 at 11:01
2  
@Lo'oris Definitely, especially since this is probably a fairly simple school project with a limited amount of time to create a solution for, I don't think supervised learning is the way to go with this, just for practicality's sake. –  Ray Dey Feb 22 '11 at 14:24
    
Its not that hard to set up, and depending on the level of the subject the OP is doing, this approach may not necessarily be overkill. It is what I would (and have done), its fun, and can be quite simple to achieve effective results. The hardest part is determining what should be done in the pre-processing... –  Daniel Feb 22 '11 at 14:28

If you can preprocess the map before running the AI, then just calculate the best racing lines through segments of the map.

This post on GameDev.net has a number of suggestions.

The AI Wisdom books have A LOT of articles about racing AI. I'd definitely recommend them, especially the first one which has articles describing how you can represent the map as a data structure within your AI.

Another method I've seen is simple reinforcement learning (Q-learning), which will probably take a good few thousand iterations to get the optimal path. It's described in this paper: http://www.cs.ubc.ca/~zhijin/540report.pdf

share|improve this answer

Here is an excellent reference for driving AI: Steering Behaviours for Autonomous Characters. Posted here for everyone's reference. There is plenty of information to get you started, but also a lot of information, so don't get too bogged down in the details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.