Game Programmer

By: James Keats | November 02, 2017

The next Artificial Opponents project is going to be a tank battle. Unlike the previous two projects which were established games with known strategy and rules, the Tank Battle is going to be a real test of our ability to write a smart AI that can adapt to change. The design of the levels can change at any point, the health and damage values can change, and the points that different actions score you can change. The result is a complex game with many different variables and a lot of data for an AI to process.

The first step in this AI is going to be writing a movement system. The locomotion of the tanks is decided by differential drive kinematics. We are given two treads that we can control the speed of independently, by certain stepped quantities. This is significantly different from any previous AI I've worked on, where we were able to affect the position and rotation directly. As a result, a big portion of the movement is going to depend on interacting with this differential drive system.

This doesn't even begin to think about things like how to score the most points, how to manage the in-game economy, or any of the other variables involved in this project--that will all come later down the line. The key for now is to be able to pass an arbitrary point on the screen into some sort of locomotion system, and have the tank maneuver to that position.

Classes & Algorithms

Before figuring out differential drive, it's necessary to choose some sort of way to get to a point in the first place. Some of my classmates are doing some form of Steering Behavior with collision avoidance. A few others are also planning on creating an A* implementation, using the provided grid of the level to create a graph and doing proper pathfinding over that graph. While I also considered both of these options, in the end I decided that a Context Behavior system would be the best choice, given my past experience with it and its inherit simplicity.

To start, I will simply need to implement a system that populates the danger map with the closest walls (found through a mock-raycast on the grid), then fills the interest map with targets. For this first demo, we will simply be provided with a target position, but later I may want multiple different interests and the Context system will allow me to weigh those options purely from a locomotion standpoint.

The complicated part will be turning the vector returned by the Context system into something usable by the tank treads. For the first iteration, I will simply have the tank stop its forward motion, turn to face the vector, than go straight in that direction. That will give serviceable, testable movement to start with. Then, I will examine the different balances of the tread speeds we are provided with. By comparing the current "forward" vector of the tank with the vector we want to travel in, I will be able to map each tread combination with a range of angles that produces the best looking and most efficient motion. A short Google search resulted in some interesting physics articles on actual differential drive kinematics that may prove to be useful when building this map.

All in all, I think Context Behavior will make this project significantly easier; while A* is an excellent algorithm and pathfinding is a very useful AI skill, it seems to me that it is overly complicated for this project and spending the time implementing the graph generation and heuristics would be a waste of time that could be spent focused on the differential drive.

As always, I'm excited to start this new project, and I can't wait to see where it leads.


Fray, Andrew. "Context Behaviours Know How to Share". Mar 26, 2013.

Hellstrom, Thomas. "Kinematics Equations for Differential Drive and Articulated Steering". Aug 28, 2011.

LaValle, Steven. "Planning Algorithms". 2006.

Category: Artificial Opponents 



Be the first to comment ...

Post a Comment