by date
Vehicle AI
Vehicle AI
| Name: | Sam Redfern | |
|---|---|---|
| Date Posted: | Feb 07, 2007 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Sam Redfern |
Blog post
Darkwind: War on Wheels is a turn-based car combat MMORPG set in a post-apocalyptic near future. I've spent a lot of time working on vehicle AI, so that all those computer-controlled deathracers and on-the-road pirates and traders can put up a decent challenge.
Driving paths: the basic racing AI involves waypoints (using a heavily modified AIWheeledVehicle2). I actually spent quite a bit of time early on using self-learning strategies using things like neural networks, but pre-defined paths turned out to be the best all-round approach. The waypoints also encode differences for different tyre types, and there is variation due to the aggression (and skill) of each AI driver. Aggression varies during the race, depending on how well a car is doing as well as its driver's state of health.
Collision avoidance: at the start of each move (it's a turn based game) the AI cars build a list of nearby obstacles (moving: other cars, rigidshape objects such as mines and spikes, or trigger-implemented objects such as oilslicks, and static: InteriorInstances and StaticShapes) and then based on the current velocities extrapolated over 2 simulated seconds, decide whether evasive action is necessary. In a combat (depending on relative mass and armour values) an AI car may actually decide that it wants to ram an opponent rather than avoid them.
Shooting targeted and dropped weapons: again, this is only done once per turn, at the start of the shooting phase of the game. The AI gunners evaluate all nearby opponents to see whether they're in the line of site of their guns (which have 90 degree firing arcs) and what likelihood they have of hitting before selecting their best shot (this is quite a comlex calculation: see this blog on the Darkwind combat system). Dropped weapons are a bit different: the AI gunners merely look for enemies nearby in their own rear firing arc, with the additional proviso that they themselves must be not cornering too hard (or else the mine/spike tends to just spin out on the corner and not pose a threat to the car behind).
Arena combat driving strategies: here, I use a combination of path driving (with multiple paths to choose from) and, when an enemy is close enough and has a clear view with no obstacles between them, direct chasing. When chasing an enemy, an AI car may take on a 'ramming' strategy or a 'non ramming' strategy (in the latter, they will circle away rather than actually crash, before turning towards their target again, while firing guns of course).
Wilderness driving strategies are the most complex of the lot. Here we have multiple car paths with predefined points of connection, along with the potential for switching between path driving and direct chase/ram strategy. Chasing (or running from) an enemy involves deciding which car path leads in the best direction to get towards (or away from) them. When the end of a car path is met, the AI car decides which potential car path to join next (and whether to drive it in the forward or reverse direction). Basically the car path connection points form a graph structure. As well as heading towards or away from an enemy, gangs of AI vehicles may nominate a leader and follow them in formation. Dealing with TGE repeating terrain was also quite a bit of effort in wilderness driving: car paths and car positions are basically mapped into their nearest terrain-repetition position before being evaluated. This means an AI car can drive indefinitely along the repeating roads and the waypoints only have to be defined once.
Hmm.. obligatory image... AI not being a very graphically exciting thing to discuss, I've just done a screen cap of one of our wilderness maps (the 'Gates of Somerset', thanks viKKing), showing two Car Paths joining at a road intersection:

www.dark-wind.com
Driving paths: the basic racing AI involves waypoints (using a heavily modified AIWheeledVehicle2). I actually spent quite a bit of time early on using self-learning strategies using things like neural networks, but pre-defined paths turned out to be the best all-round approach. The waypoints also encode differences for different tyre types, and there is variation due to the aggression (and skill) of each AI driver. Aggression varies during the race, depending on how well a car is doing as well as its driver's state of health.
Collision avoidance: at the start of each move (it's a turn based game) the AI cars build a list of nearby obstacles (moving: other cars, rigidshape objects such as mines and spikes, or trigger-implemented objects such as oilslicks, and static: InteriorInstances and StaticShapes) and then based on the current velocities extrapolated over 2 simulated seconds, decide whether evasive action is necessary. In a combat (depending on relative mass and armour values) an AI car may actually decide that it wants to ram an opponent rather than avoid them.
Shooting targeted and dropped weapons: again, this is only done once per turn, at the start of the shooting phase of the game. The AI gunners evaluate all nearby opponents to see whether they're in the line of site of their guns (which have 90 degree firing arcs) and what likelihood they have of hitting before selecting their best shot (this is quite a comlex calculation: see this blog on the Darkwind combat system). Dropped weapons are a bit different: the AI gunners merely look for enemies nearby in their own rear firing arc, with the additional proviso that they themselves must be not cornering too hard (or else the mine/spike tends to just spin out on the corner and not pose a threat to the car behind).
Arena combat driving strategies: here, I use a combination of path driving (with multiple paths to choose from) and, when an enemy is close enough and has a clear view with no obstacles between them, direct chasing. When chasing an enemy, an AI car may take on a 'ramming' strategy or a 'non ramming' strategy (in the latter, they will circle away rather than actually crash, before turning towards their target again, while firing guns of course).
Wilderness driving strategies are the most complex of the lot. Here we have multiple car paths with predefined points of connection, along with the potential for switching between path driving and direct chase/ram strategy. Chasing (or running from) an enemy involves deciding which car path leads in the best direction to get towards (or away from) them. When the end of a car path is met, the AI car decides which potential car path to join next (and whether to drive it in the forward or reverse direction). Basically the car path connection points form a graph structure. As well as heading towards or away from an enemy, gangs of AI vehicles may nominate a leader and follow them in formation. Dealing with TGE repeating terrain was also quite a bit of effort in wilderness driving: car paths and car positions are basically mapped into their nearest terrain-repetition position before being evaluated. This means an AI car can drive indefinitely along the repeating roads and the waypoints only have to be defined once.
Hmm.. obligatory image... AI not being a very graphically exciting thing to discuss, I've just done a screen cap of one of our wilderness maps (the 'Gates of Somerset', thanks viKKing), showing two Car Paths joining at a road intersection:

www.dark-wind.com
Recent Blog Posts
| List: | 10/31/08 - Deathracing Firetrucks (many images) 06/23/08 - Happy New Year: 2046 01/06/08 - January 2044 Roundup 10/15/07 - Happy New Year 2043 09/06/07 - What you get when you give an indie developer a free reign to rant, and don't argue with him 08/08/07 - Darkwind Retail 04/26/07 - Darkwind Official Opening May 4th 04/04/07 - Characters on Foot |
|---|
Submit your own resources!| Mathieu Marquis-Bolduc (Feb 08, 2007 at 17:17 GMT) |
| Viren Thambidorai (Mar 09, 2007 at 13:33 GMT) |
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


