An engine made in c simulating the board game Quoridor
on a terminal
How to play: see available commands on Commands/Quoridor Text Protocol
Currently an alpha-beta pruning algorithm
The evaluation function has the following 4 features:
- Black's distance from goal
- White's distance from goal
- Penalty if the minimizing agent is very close to the goal
- Penalty if the maximizing agent has fewer walls than minimizing agent
Uses iterative deepening to get the most depth in a given fixed move time (4.5 seconds)
As the game progresses and the branching factor decreases the depth the agent can see ahead increases
Sorts wall placements by distance to the enemy. The furthest away a wall is from the enemy the more likely it is that it's a bad wall to place
Possible improvements of the agent:
- Sort player moves by sortest distance to its goal
- Sort wall placements by
min{distance from minimizing agent, distance from maximizing agent}
. This will make walls that will support the maximizing agent be considered earlier Possible a mid to late game improvement - Take into account the actual path the maximizing agent has to follow and place walls to make it harder for the minimizing agent to block it
make
to compile, make run
to compile and run
make clean
to clean files created during compilation
Commands supported by the engine used in plaing the game
Assumes the input is mostly correct, no major parsing/error checking is being done
-
name
- arguments β none
- effects β β none
- output β β name
β β β β β string* name - Name of the engine - fails β β β never
- comments β E.g. "IP Quoridor".
-
known_command
- arguments β command_name
β β β β β string command_name - Name of a command - effects β β none
- output β β known
β β β β β boolean known - "true" if the command is known by the engine, "false" otherwise - fails β β β never
- comments β The protocol makes no distinction between unknown commands and known but unimplemented ones.
β β β β β Do not declare a command as known if it is known not to work.
- arguments β command_name
-
list_commands
- arguments β none
- effects β β none
- output β β commands
β β β β β string& commands - List of commands, one per row - fails β β β never
- comments β Include all known commands, including required ones and private extensions.
-
quit
- arguments β none
- effects β β The session is terminated and the connection is closed.
- output β β none
- fails β β β never
- comments β The full response of this command must be sent before the engine closes the connection.
β β β β β The controller must receive the response before the connection is closed on its side.
-
boardsize
- arguments β size
β β β β β int size - New size of the board. - effects β β The board size is changed.
β β β β β The board configuration, the number of walls of each player, and move history become arbitrary. - output β β none
- fails β β β Syntax error.
β β β β β If the engine cannot handle the new size, fails with the error message "unacceptable size". - comments β The controller must call clear_board and walls explicitly.
β β β β β Even if the new board size is the same as the old one, the board configuration and the walls number become arbitrary.
- arguments β size
-
clear_board
- arguments β none
- effects β β The board is cleared, the two pawns return to their starting position, the number of walls of each player becomes arbitrary and the move history is reset to empty.
- output β β none
- fails β β β never
- comments β
-
walls
- arguments β number_of_walls
β β β β β int number_of_walls - Number of walls for each player. - effects β β Each player has that number of walls at the beginning.
- output β β none
- fails β β β never
- comments β
- arguments β number_of_walls
-
playmove
- arguments β where
β β β β β move where - Color and vertex of the move - effects β β The player of the requested color is played at the requested vertex.
- output β β none
- fails β β β syntax error, illegal move. In the latter case, fails with the error message "illegal move".
- comments β Consecutive moves of the same color are not considered illegal from the protocol point of view.
- arguments β where
-
playwall
- arguments β placement
β β β β β wall placement - Color, vertex and orientation of the wall - effects β β A wall place at the requested vertex and orientation. Decrease number of wall for that player by one.
- output β β none
- fails β β β syntax error, illegal placement. In the latter case, fails with the error message "illegal move".
- comments β Consecutive moves of the same color are not considered illegal from the protocol point of view.
- arguments β placement
-
genmove
- arguments β player
β β β β β color player - Color for which to generate a move. - effects β β The engine makes a move or wall placement for the requested color.
- output β β vertex orientation
β β β β β vertex||string
β β β β β Vertex where the move was played or where the wall was placed. - fails β β β never
- comments β If orientation returned a wall placed, otherwise it's a move.
- arguments β player
-
undo
- arguments β times (optional)
β β β β β int times - how many times to undo - effects β β The game goes 'times' moves back.
- output β β none
- fails β β β If times is greater than moves played or no moves are played. Fails with the error message "cannot undo".
- comments
- arguments β times (optional)
- winner
- arguments β none
- effects β β none
- output β β boolean color
β β β β β boolean - true if game ended, otherwise false
β β β β β color - It's the color of the winner - fails β β β never
- comments
- showboard
- arguments β none
- effects β β none
- output β β board
β β β β β string*& board - A diagram of the board position - fails β β β never
- comments β The engine may draw the board as it likes.
β β β β β It is, however, required to place the coordinates as described in section 1.11.
β β β β β This command is only intended to help humans with debugging and the output should never need to be parsed by another program.
make run
boardsize 9
walls 10
genmove black
playmove white E2
genmove black
genmove white
...
quit
To play with referee you need 2 executables (can play against itself)
Executables must follow the Quoridor Text Protocol
described previously
Run with:
quoridor_referee.py --white '<path to program 1>' \
--black '<path to program 2>' \
Possible quoridor_referee options:
--verbose 1 (to list moves) or --verbose 2 (to draw board)
--size <board size> (default 9)
--walls <number of walls> (default 7/4*boardsize-23/4)
--games <number of games to play> (default 1)
--maximum_time <time(in seconds)> (default boardsize/3)
--move_time <time(in seconds)> (default 30)
--memory_limit <memory(in MB)> (default 950MB)
--seed <seed> (default current unix timestamp)
Engines on folder CupProgs
are (mostly) from here (in greek)