No description or website provided.
Haskell Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Turn-based capture the flag game for University of Helsinki AI Challenge course


$ cabal configure
$ cabal build
$ ./dist/build/ctf/ctf config "(cat input_a.txt; cat >/dev/null)" "(cat input_b.txt; cat >/dev/null)"

$ (cd brains; javac *.java)
$ ./dist/build/ctf/ctf config "(cd brains; java RandomWalk)" "(cd brains; java Capturer)"

Example input_[ab].txt included.

Rules of the game

The idea of the game is to capture the enemy's flag and bring it to
your home base. Killing enemy soldiers gives additional points.

The game is carried out on a 2d grid that contains walls, a base for
both teams, and a spawn point for both teams. The flags are initially
in the bases.

The game is turn-based. Both teams submit orders for their all of
their soldiers, and the orders are carried out simultaneously. During
a turn, a soldier can move (up, down, left or right) and/or throw a

Grenades can only be thrown to a certain distance. A grenade thrown on
turn N explodes in the beginning of turn N+3. The grenade explosion
kills all soldiers in the 3x3 square centered on the grenade. Grenades
are not visible to the enemy. Grenades have a cooldown time, which
means that you have to wait a certain amount of time before the same
soldier can throw a new grenade.

A dead soldier respawns in the team's spawn point after being dead for
one round.

A flag is picked up by walking into the same square that it is in. You
can only pick up your enemy's flag. Once a flag gets moved to the base
of the opposing team, the opposing team gets points and the flag warps
back to its home base. If a soldier carrying a flag dies, the flag
stays where it is.

Brain->Engine communication format

This is what your brain should output on stdout:

<soldiername> <movementdirection> [<grenadecoord>]
<soldiername> <movementdirection> [<grenadecoord>]

movementdirection: either U (meaning y--), L (x--), D (y++), R (x++)
or S (stay still)
grenadecoord: optional and should be of the form (<x>,<y>)

Engine->Brain format

This is what your brain gets from the engine on stdin.



yourteam: "A" or "B"
map: m lines of n characters representing an mxn tile map.

NB! The coordinate system of the map is as follows:
  - (0,0) is the first character on the first line
  - x increases along one line and
  - y increases with every line change.
The meanings of the tiles are:
  . -- empty
  # -- obstacle
  A,B -- spawn of team A, spawn of team B
  a,b -- base (flag) of team A, base of team B


<yourpoints> <enemypoints>
Flag <x> <y>
Soldier <name> <x> <y> <cooldown> <alive> <flag>
Soldier <name> <x> <y> <cooldown> <alive> <flag>
Soldier <name> <x> <y> <cooldown> <alive> <flag>
Grenade <x> <y> <countdown>
EnemyFlag <x> <y>
Enemy <name> <x> <y> <alive> <flag>
Enemy <name> <x> <y> <alive> <flag>
Enemy <name> <x> <y> <alive> <flag>
<an empty line signals the end>

x, y: integers
cooldown: integer. 0 means you can throw a grenade
countdown: integer
name: matched by the regex [A-Za-z]+
alive: either "True" or "False"
flag: either "No", "A", or "B"

The entries are always in this order. There number of Soldier, Enemy
and Grenade records can vary, but there will always be exactly one
Flag and exactly one EnemyFlag record.

Config format

The first line should contain a Rules struct in Haskell format. The
fields are:

nRounds - number of rounds
nSoldiers - number of soldiers per team
pointsKill - how many points a kill awards
pointsCapture - how many points capturing a flag awards
grenadeRange - the range of a grenade
grenadeCooldown - how long a soldier has to wait before throwing a new grenade

The rest of the lines should describe the game map, one character per
tile, rows ended by newlines. All lines should be of equal length. The
meanings of the characters are:

'.' - empty
'#' - obstacle
'A' - spawn of team A
'B' - spawn of team B
'a' - flag of team A
'b' - flag of team B

See the provided file "config" for an example.

Engine output

The stdout of the engine contains a log of game events. The last line
on stdout is either the score in the format "Final score: A 0 - B 101"
or "<teamname> failed" if a brain terminates prematurely.

The stderr of the engine contains the stderrs of the two brains, each
line labeled by the team of the brain that produced it.


- timeouts for reading commands?