Quick Details

The git repository is listed on The UCC git page as "progcomp2012.git"

We will use the same mailing list as last year (progcomp).

There is a #progcomp irc channel on the ucc irc server where you can ask questions or help with setting things up.

Stratego

This site explains what Stratego is.

I have never played this game. But it sounds cool. So naturally I decided to make a competition based on it.

My original idea was to force people to write AI for Astral, but then I realised that that was a terrible idea.

There is in fact, already a World Stratego Championship. However, you have to use Metaforge. Using stdin/stdout will probably make it slightly easier for us. And its better to work out how to do these things ourselves.

Programming Competition

Create an AI to play Stratego.

Yes, I know people are inherently lazy and won't be bothered to do this. But so far in setting this up I have learn quite a lot about inter-process communication, so thats good.

Programs are written independently and interface through stdin/stdout with a manager program, which queries them on setup and moves.

The Manager Program

The manager program takes two executable paths, one to each of the AI programs to pit against each other.

It first requests each program to print the setup of its pieces to stdout. Then the programs take turns (Red, then blue, etc) to move one piece.

The first program is Red (top of the board), the second is Blue (bottom of the board).

I have now added graphics, but you can disable them by commenting out the "#define GRAPHICS" in the file "common.h"

EDIT: You also have to remove graphics.o from the Makefile dependencies, and there are probably other annoying things. Its probably easiest just to install the SDL and OpenGL libraries to be honest

Messaging Protocol and Rules

Setup

Query

The manager program prints one line in the following format to each program:

COLOUR OPPONENT BOARD_WIDTH BOARD_HEIGHT

At the moment BOARD_WIDTH and BOARD_HEIGHT are always 14. The arguments are followed by a newline.

OPPONENT will be the identity of the opposing AI program.

Response

The AI program queried must print four (4) lines containing its initial setup. Each character represents a unit or empty space. The characters are as follows:

Rank Character Number
Marshal M 1
General G 1
Colonel C 2
Major m 3
Captain C 4
Lietenant L 4
Sergeant S 4
Miner n 5
Scout s 8
Spy y 1
Bomb B 6
Flag F 1
Unoccupied .
Obstacle +

The AI program can't place any obstacles, and must at least place the Flag for its setup to be valid.

RED will always occupy the top four rows of the board, and BLUE occupies the bottom four rows.

Turns

Query

RED starts the game. The manager queries RED to make the first move by printing:

START

Followed by a WIDTH*HEIGHT grid. '*' or '#' characters are used to indicate positions of unknown (BLUE/RED) enemy units.

Response

The AI program must respond with a single line of the following form:

X Y DIRECTION [MULTIPLIER]

Where X and Y represent valid co-ordinates, upon which there is a piece of the AI program's colour.

DIRECTION must be either "UP", "DOWN", "LEFT", or "RIGHT", and is, obviously, the way the piece is supposed to move

MULTIPLIER is optional, and should only be given if the AI program is moving a Scout. Scouts may move multiple times in the same direction if possible.

Outcome

The manager program will indicate the result of a move by responding with:

X Y DIRECTION [MULTIPLIER] OUTCOME

Where X, Y, DIRECTION and MULTIPLIER are as above.

OUTCOME signals the result of the turn, and will be one of the following:

OUTCOME Description
OK The piece was successfully moved, nothing eventful happened
FLAG The piece moved onto the opposing Flag; the game will end shortly
KILLS The piece landed on a square occupied by an enemy, and destroyed it, moving into the square
DIES The piece landed on a square occupied by an enemy, and was destroyed. The piece is removed from the board.
BOTHDIE The piece landed on a square occupied by an enemy, and both pieces were destroyed.
ILLEGAL The moving player attempted to make an illegal move, and has hence lost the game. The game will end shortly.

Additional Turns

The Outcome of each turn is printed to both AI programs.

The state of the board is then printed to BLUE, who makes a move, then the process repeats.

Overview

This is a description of the signals the AI programs recieve, in order:

  1. Previous turn's outcome (other player's move) OR "START" if it is the first turn
  2. A WIDTH*HEIGHT grid indicating the board state, with the AI program's own pieces revealed
  3. After the AI program makes a move, the outcome is printed to it, and the other program, which continues from step 1

End Game

Query

At the end of the game, the manager program outputs the following:

VICTORY

To the winning AI program, and

DEFEAT

To the losing program.

Both programs then have 2 seconds to exit succesfully, or the manager will kill them.

Invalid Responses and Timeouts

If any program fails to respond correctly, or gives an invalid move, or does not respond within 1 second, it will lose by default.

In this case, the message

ILLEGAL

will be sent to the malfunctioning program, and

DEFAULT

to the other program

Both programs then have 2 seconds to exit succesfully, or the manager will kill them.

Modifications/Clarifications to Rules

Refer to This site for the original rules again

Currently, the pieces taking part in the combat are not revealed; only the outcome of the combat is revealed. In a human game, the pieces would normally be revealed. I am planning to reveal the pieces, since not revealing pieces significantly reduces the value of low ranked pieces (normally used for working out enemy piece values).

It is up to the AI program to keep track of pieces. The manager program will only reveal the identity of the AI program's own pieces; the other player's pieces will be marked with * or # characters.

In a traditional game, two pieces of equal value will both be destroyed in combat. Currently, only one piece is destroyed and the outcome is randomly chosen.

Example Program

I have written a spectacularly boring AI which randomly selects a unit, and then randomly selects a direction in which to move it.

I should probably make a more interesting example if I want people to actually care about this.

I am working on another AI, but things seem to die and explode every time I try to use it...

Longterm Scoring

I haven't started a system for pairing AI's and keeping track of scores and winners etc yet

I'll probably have a bash script that chooses who will play, and stores all the scores in files. I've done this before for a BrainF*** based "survival of the fittest" style thing, so I can probably recycle it

I believe it will make things more interesting if programs are allowed to keep state of who they have played, and the various tactics used.

Its kind of hard to implement this... at the moment programs are killed every time a game finishes

Perhaps it will be easier if each program is allowed access to one directory, where it can create and read files?

This would allow me to keep the manager program which actually plays the games seperate from the program for scoring and matching of opponents

There'd probably be security issues with that though.