Text based API
Be sure to read and understand the rules before reading this page.
All agents (even python ones) are stand alone programs which qchess spawns instances of to play a game. Qchess sends state updates and requests moves from players through pipes. From the agent's point of view, all it has to do is read commands from stdin and respond to stdout.
In the following, lines prefixed with "<< " indicate input to the agent, lines prefixed with ">> " indicate output.
The end line character is a unix new line character '\n'. There is no carriage return.
A token prefixed with '$' is taken to be variable, whilst all other tokens are to be interpreted literally.
- $colour is either "white" or "black" and indicates the colour the agent will be playing as.
- The agent should make no response to this message. If it does, it will be declared illegal.
>> $x $y
- $x and $y are the x and y co-ordinates of the piece that the agent wishes to select.
- $x and $y must be the co-ordinates of a square that is on the board, and occupied by a piece belonging to the agent.
- The top left square is (x,y) = (0,0). The bottom right is at (x,y) = (7,7).
- Qchess does not recognise standard chess square names (eg: E5)
- A piece belongs to the agent if its colour matches that of the agent.
- An invalid selection results in the game ending with the offending agent declared illegal
- A valid selection results in a response from qchess; see Update: Agent selects a piece
>> $x $y
If an agent selects a piece that cannot move, it will not receive this request before its next selection.
- If an agent selected a piece that couldn't move, it will not receive this request before another selection request
- $x and $y are the co-ordinates of the destination square
- The selected piece must be able to move into the square, and the square must be unoccupied or occupied by a piece of the opposing colour
- If the square was occupied by a piece of the opposing colour, that piece is "taken" and removed from the game
- If the "taken" piece was the opposing king, the agent will win the game.
- The agent must always make a move
- An invalid move results in the game ending with the offending agent declared illegal.
- A valid selection results in a response from qchess; see Update: Agent moves a piece
Update: Agent selects a piece
<< $x $y $index $type
- $x and $y are the x and y co-ordinates of the selected piece
- $index is either "0" or "1" and indicates which of its two states the selected piece is in.
- $type is a string indicating what the state of the piece actually is.
- This string is one of: "king", "queen", "rook", "knight", "bishop" or "pawn".
- The piece's next move will obey traditional chess movement rules for a piece of this type.
- The agent should not respond to this message, or it will be declared illegal
Update: Agent moves a piece
<< $x1 $y1 -> $x2 $y2
- The piece will have been been selected immediately prior to being moved.
- $x1 and $y1 are the x and y co-ordinates of the piece's original square.
- $x2 and $y2 are the x and y co-ordinates of the piece's destination square.
- Qchess does not provide any indication as to whether the move captured a piece or not
Note: The token between the two pairs of co-ordinates is a minus sign followed by a greater than sign. It's supposed to look like an arrow, but in html it's a bit hard to see.
- The agent should immediately exit cleanly without sending any response.
- Agents which do not exit after 2 seconds shall be sent SIGKILL
- The "update" messages give no indication as to which player performed the selection or movement. However this is trivial for agents to keep track of.
- Agents can expect to receive an "update" message after responding successfully to the corresponding "request"
- If no request was made, the agent can assume the "update" is due to the action of the opponent.
Page last updated 2013-03-29 by matches
The UCC Website