How to Win a Capture-the-Flag Programming Challenge

Back in May, I described how entering coding challenges can be a way in to the industry. A recent AI competition that’s just started is offering prizes, and one of the competition’s supporters, Guerilla Games, is hiring AI programmers.

The competition, Capture the Flag (linked below), is free to enter. You just need a Windows or Linux PC to run the software on, and then submit your entries.

What is AI?

Short for Artificial Intelligence, AI is a branch of games programming where you devise and code algorithms for a computer player to play as well as, if not better than, a human player. Every computer or Web game where you play against a computer player is using artificial intelligence.

At first glance AI doesn’t sound too difficult, but if you’ve ever tried to discover a winning strategy that can defeat computer players, then you’ll realize that it’s perhaps not that easy.

Back in the mid-1980s in the home computer era, I created a couple of games that used AI. One was a tactical Civil War game where the Confederates were attacking a bridge and trying to get across, while the Union troops were defending. It was written in Z80 assembler, which is not the easiest language for creating AI, and I remember taking several days to get it right, just to have the troops form up, approach the bridge and cross. Fighting was a bit easier to code, because the main tactic was to concentrate fire onto single targets.

Likewise, I wrote a brigade-level Battle of the Bulge game where the Germans were attacking and moving slowly through the Ardennes. The AI for that set strategic targets that it tried to capture while responding to the Allied counter attacks, to make sure they kept hold of the targets. It’s no good capturing strategic points then losing them, or needlessly losing units to enemy attacks because the AI hasn’t been told to do those things. It all has to be coded in.

In an article linked below, I describe the AI system for a strategy game I’m developing in a series to teach game programming.

AI Sandbox

In the “Capture The Flag” competition, you have to program an AI Commander to manage several bots on your team. This is the classic Capture the Flag game, where each side has the dual objectives of stealing the opposing team’s flag and getting it back to their own base, while preventing the opposing team from doing the same.

Each team has between 5 and 15 bots, and there’s a simple combat system where bots get eliminated. Read the Game Mechanics on AI Sandbox for full details.

The commander AI receives information about its own bots and enemy bots that are seen, have killed or been killed, or have a flag. Orders are given to individual bots to defend a place, move, attack a location, or even charge towards a location. It’s all happening very quickly, so the AI has to be highly reactive, trying to appraise tactical situations and gain the advantage in milliseconds.

It gets interesting in that bots only see in a 90-degree arc and will fire on any enemy bot entering the location. There are also blocks that obscure visibility to make movement longer. It’s quite a challenge.

Entering the Competition

Anyone with a Windows or Linux PC can enter, and support for the Mac OS X is under consideration. (AI Sandbox says to let them know if you’re interested in the Mac platform and to spread the word.) Though Python is the main programming language used, there’s also a C++ starter kit and Google Go as well, with Java coming along soon. Just download the starter pack, which includes a server so you can test your code locally then submit it. It runs through November and December, so don’t delay. The deadline is Jan. 7, 2013.

There are several sample games shown (the screenshot shows one), so you can see what the bots see and how they react.

What Strategy to Use?

Sending your troops in en masse may win, or it may get them all quickly killed. The combat rules seem to favor strength, so you might consider having your bots move in small groups, trying to ambush individual enemy bots by groups of two or three bots. However, the sides aren’t big, so concentrating your troops may leave holes that allow enemy bots to sneak through and grab your flag.

A classic real-world tactic for small groups is Overwatch. Group A stops and watches while group B moves forward. Then they swap roles, and A moves up under the careful watch of B.

Whatever strategy or tactics you program for your team, good luck!

Related Links

Image: Sample Game [AI Sandbox]

Comments

  1. BY joeBoo says:

    “AI is a branch of games programming ”

    maybe this was unintentional, but game programming is just one of many problem domains in which AI is used. your quote makes it sound like it’s only part of game programming.

Post a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>