10
\$\begingroup\$

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?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Nate
    Feb 21, 2011 at 22:45

3 Answers 3

2
\$\begingroup\$

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.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Seems overkill to me. \$\endgroup\$
    – o0'.
    Feb 22, 2011 at 11:01
  • 2
    \$\begingroup\$ @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. \$\endgroup\$
    – Ray Dey
    Feb 22, 2011 at 14:24
  • \$\begingroup\$ 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... \$\endgroup\$ Feb 22, 2011 at 14:28
2
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.