|This is the archived CodeCup 2010 website.
Click here to go to the new CodeCup website.
Rules of the game Amazes
Amazes is a two player game that is played inside a square maze on rectangular grid of dimensions 25 x 25. The player that starts the game is the 'Red' player. The other player is the 'Blue' player.
Both players are located in the maze and initially do not know the layout of the maze. They are provided with information about what they can see from their location, and how far away from their opponent they are. A player cannot see the other player. Each turn consists of the player taking steps through the maze. The players earn points by discovering previously undiscovered squares in the maze, but lose points by taking steps.
The Red player starts by getting information about what is visible from his position. He must then indicate which steps he wishes to take in the maze. Once he is done moving about, the Blue player gets information and also takes steps. After this it is Red's turn again. The maximum number of turns for each player is 150.
The final score of each player is determined by the number of points collected during the game.
The goal of the game is to score as many points as possible by discovering previously undiscovered squares in the maze. A player does not necessarily have to visit a square in order to discover it.
A player will score more points by the following:
The players do not receive a map of the maze beforehand. The exact layout of the maze is therefore unknown, but some properties of the 625 squares of the maze are known beforehand:
The following is an example of a valid maze.
You can find more examples of mazes here.
During the competition, a different maze will be used for each round.
The players start in a randomly determined square somewhere in the maze. These positions are chosen such that the Euclidian distance at the beginning of the game is at least √288 ≈ 17. The Euclidian distance between the two players is calculated using the following formula:
√(Δy^2 + Δx^2)
Δy is the vertical distance in squares between the two players. Δx is the horizontal distance in squares between the two players.
The Euclidian distance is equivalent to using Pythagoras' theorem to calculate the distance.
The starting position of a player is chosen so that there is no wall directly behind the player (i.e. it is always possible to take a step backwards).
Making a move
The players take turns moving around the maze. A changes the position of the player (i.e., in which square are you located) and may change the orientation of the player (i.e., which direction are you facing).
Before making a move, a player is given information about the situation of the maze. This information consists of information about the maze directly around you, as well as information about the Euclidian distance to your opponent.
A single turn consists of several steps and turns you wish to make.
A player can read information about the current situation from stdin. The information is given in the form of five lines. The first four lines describe what you see in the corridors respectively ahead of you, to your right, behind you and to your left. The last line is the squared Euclidian distance to your opponent. This number is always an integer.
A line that describes a corridor consists of several characters that describe the consecutive visible squares of the corridor. The final character is always a 'W'. The following characters may be used:
The following example demonstrates the information that you are given before making a move. The information that the red player is given is:
W W LLBNW W
The two vertical walls are discovered because you know that each corner in the maze is the endpoint of at least one wall.
Making your moveThe players take turns writing instructions to stdout.
A turn consists of a single line of instructions of moves. A line must have between 1 and 256 (inclusive) characters. A move is basically an instruction to step into another square and to change your orientation so that you are facing away from the square that you came from.
The player that starts the game gets an extra first line of input that says 'Start'. Based on the presence of this text during your first move, you can determine whether you are the first or second player.
If on the first line of input the text 'Quit' is written, the players program must exit normally.
End of the game
The game can end in two ways:
Points & score
During the game, the players may earn points. The number of points is used to determine the final scores of the players.
You start with 0 points. While playing you may earn or lose points according to the following rules:
If the game ends because of sudden death, the number of points of the player that made the last move is doubled. The number of points of the losing player is set to 0.
For the purpose of the extra points that you may earn by being first to discover a square, the time of discovery is important. At the beginning of your turn, you stand still and look around you. This is the time that you discover many new squares.
During your turn you may walk across squares that you have not yet discovered. They are discovered immediately.
Your final score is determined according to the following rules:
You score points based on the new discovery of squares in the maze.
The discovery of squares, walls, and openings between squares is determined by the jury software according to the following rules:
Discovery of squares
Discovery of wallsAt the beginning of the game you do not know where you are located in the maze, or in which direction you are facing. Initially you will not know whether a wall is an interior wall or part of the outer edge of the maze.
Example gameYou can watch an example game!
Play this applet to see an extreme example of the square and wall detection rules:
Right after the information stage of turn 2, the red player knows some of the walls of the dead end corridor at the right corner, of course, the red player doesn't know this yet, because he doesn't know where he is inside the maze.
Note that in turn 2 this player is going into an area which is entirely unknown. As described this is still a valid move, the red player is just lucky that there is no wall on it's path.
Or maybe we put this all up to keep the example short, who knows!
Right after the information stage of turn 4, the red player also knows some of the walls of the dead end corridor at the left. The number of known squares horizontally is now 23 so the red player still doesn't know any of the walls of the left or right outer edges.
This image has been modified for clarity
This is what the situation looks like after the 4th turn. The player has discovered the long corridor and took a last step to the left. This square was already discovered, but two of the edges (the bottom one and the right one) were not yet discovered. The player is about to discover more!
This image shows what is going on during the information stage of turn 5. The red player detects that the square at the right (marked by the number 0) exists (it is discovered). So the player has found squares in each of the 25 rows (note that we've used the verb found instead of discovered).
Move one to the next image to see the result of the more complicated detection rules.
This is the advanced part of the information stage of turn 5. The jury software iterates through the list of rules until there is no new information available:
The squares below the squares 4 are not discovered, because they still have two edges the red player knows nothing about.