The specification is now complete; the control program will now be written
Chatroom for this challenge
Your task is to create an AI which builds a profitable transport network to carry passengers. In each game, the first entry to have $262,144 or more in cash wins!
Every entry must have a name and version numbering for each time it is altered. You may submit up to 8 entries, but they must not collaborate.
Control
Each round has four players. Each player has a number from 1 to 4.
A simple map will be randomly generated by the control program for each game. This map will be stored in a file map.txt
two directories above your program (i.e. ../../map.txt
), and updated each game tick. Each player's bank balance (as a number without the $ symbol) will be in ../../account_<PLAYERNUMBER>.txt
. Vehicle data will be in ../../vehicles_<PLAYERNUMBER>.txt
. You may view other player's vehicle and account files.
Your program will be invoked once, at the start of the game. When your program has finished initializing, it must output READY
. If it takes more than 60 seconds to initialize, it will be terminated and disqualified from that game. It may keep files between rounds (for example, to predict an opponent's strategy after watching them for a few games). Other players may not view these files. The tournament will be re-run and the leaderboard updated every 2 days. Your program may not keep files between tournaments.
The control program will put the text WAITING-player_number
(e.g. WAITING-4
) and a newline to your program's standard input when each game tick begins. You will submit actions on standard output, separated by new lines, terminated by END
. Actions that are invalid for whatever reason will be completely ignored. If your program takes longer than 1 second to output END
, it will receive TIMEOUT
on standard input and no action will be executed for this turn.
If no winner has been found after 30 minutes, the player with the most money wins.
Map format
The map will be a two-dimensional ASCII grid where the top is north, the bottom is south, the left is west and the right is east. Example:
#/////////
######@@@*
/**@@#####
//@@1#@@@*
/@@##@**/#
~~~+~~~~~|
///#######
#
represents a road. /
represents empty land. *
is for difficult terrain (e.g. hills, swamps, whatever) - more on that later. @
represents a house. ~
is a body of water. +
is a completed bridge over water. |
is a partially constructed bridge. The numbers 1 to 4 represent stations belonging to players (e.g.: if you are player 4, your stations will be marked as 4
). 5 to 8 represent 'inactive' stations belonging to players 1 to 4 respectively.
The line endings in the file will be Windows-style CRLF.
The top left corner is (0,0)
. X is horizontal and Y is vertical.
Construction
Each tick, a player can perform up to 4 construction actions. These are:
- replace a
/
with a #
(build a road)
- replace a
*
with a /
(prepare terrain)
- replace a
#
with an inactive station (build a station)
- replace a
~
with a |
(start a bridge)
- replace a
|
with a +
(finish a bridge)
- replace one of your stations with a
#
(demolish a station)
You may not perform more than one action on a tile in one turn (you cannot go from ~
to |
and to +
in a single turn).
You cannot demolish roads, bridges, water, houses or other players' stations.
Each action costs $512, and is sent to the control program on standard output in the following format (B is for Build):
B-X-Y-tile
For example, this will build a road at (8,4):
B-8-4-#
Invalid commands will be ignored.
Vehicles
Each player can own an unlimited number of vehicles. The basic bus has the following properties:
- carries 32 passengers
- travels 8 tiles per turn
- consumes $8 per tile in running costs
Each vehicle can have up to 4 upgrades out of the following (but no more than 2 of each type):
- +16 capacity (denoted by
C
)
- +4 tiles/tick speed (
S
)
- -$2 running costs (
R
)
At most one vehicle can be bought by each player per turn. The basic bus costs $4096 and each upgrade costs $1024; the maximum possible cost is therefore $8192 (all 4 upgrades). A bus can be sold at any time for half of its purchase price (including upgrades; a bus with 4 upgrades can be bought for $8192 and sold for $4096). At most one vehicle can be sold each turn.
The command for purchasing a vehicle is (P is for Purchase):
P-id-X-Y-upgrades
For example, this will buy a bus with no upgrades, assign it the ID 5, and place it at (7,7):
P-5-7-7-
The command for selling a vehicle is simply (V is for Vend)
V-id
Vehicles are stored in vehicles_N.txt
in the following format, separated by newlines:
id-X-Y-passengers-upgrades-laststationX-laststationY
For example, this bus has ID 4, is at (5,5), contains 15 passengers, has two speed upgrades and one running cost upgrade, and last stopped at (3,4). If the bus has never run A
before, use the coordinates where it was created for the "last station" coordinates. Update the coordinates every time A
is run for that bus.
4-5-5-15-SSR-3-4
Vehicles can travel on roads (#
), bridges (+
) and station tiles (12345678
). In the above example, it is possible to drive from the top left corner to the bottom right corner. However, the two road sections in the map below aren't connected, because they are only diagonally touching. Building a road on one of the *
would solve this.
/////
##*//
/*###
/////
Vehicles can only stop to pick up and drop off passengers at stations belonging to their owner - player 3's bus can only stop at a 3
or a 7
, but not at any of 124568#+
.
Your AI has complete control over the movement of its buses. It will submit directions as commands. For example, the following command set will move bus 8 in a circle, then two spaces south, then make it offload 8 passengers, then make it wait for passengers (N, E, S and W are north, east, south and west; R is for Remove; A is for Acquire):
N-8
E-8
S-8
W-8
S-8
S-8
R-8
A-8
NB: Waiting at a station with A
counts towards the limit of tiles that the bus can travel each turn, although it is not moving. While waiting, double running costs are charged. A bus may wait for multiple turns. If a bus moves fewer tiles than it is able to (e.g. can move 8 tiles per turn but chooses to move 5 times), halved running costs are charged for the unused turns.
Passengers
Each time an R
command is submitted for a bus that is at a station, the bus loses 8 of its passengers. The diagonal distance (using Pythagoras' theorem) between its current station and the previous one is calculated and rounded down (floored). Each passenger offloaded gives this amount of profits (e.g. if the previous station is 1.4 tiles away, each passenger gives $1; if it is 5.9 tiles away, each passenger gives $5).
Each time an A
command is submitted for a bus that is at a station, the bus gains passengers. Each house in range of your station provides 1/number_of_active_stations_in_range_of_house
passengers.
If there are three stops, A, B and C, and the bus has a route from A to B and then to C, but only picks up passengers at A, then passengers offloaded at B will pay the price for A to B, and passengers offloaded at C will pay for A to C. However, if any passengers are loaded at B, then all of the passengers offloaded at C, even if some of them boarded at A, will pay the fare for B to C.
In the map below, the tiles marked with @
and #
are in range (4 tiles or less away), but not the tiles marked with /
; the bus at 1 will gain 32 passengers because there are 32 houses in range and no other stations.
////@////
///@@@///
//@@@@@//
/@@@@@@@/
####1####
/@@@@@@@/
//@@@@@//
///@@@///
////@////
Other
You will be charged $64 per turn for each station, active or not, that you own.
Each turn, active stations have a 1 in 8 chance of becoming inactive. This is reverted when a bus runs A
at the station.
You will start with $32768.
You may not have a negative quantity of money.
When someone wins, all competing programs will receive GAMEEND
on standard input. They may no longer submit commands after this happens, but they may read and write from files (to prepare for a subsequent game, for example). After 60 seconds, all competing programs will be killed.
The map will be 256*256 tiles.
Todo
- Write control program
- Write map generator
- Plan tournament format