Added Fortran sample Agent
[progcomp2013.git] / web / agent_text.html
1
2 <html>
3
4 <head>
5 <title> UCC::Progcomp 2013 - Writing an Agent - Text based </title>
6 </head>
7
8 <body bgcolor=white>
9
10 <h1> Text based API </h1>
11
12 <p> Be sure to read and understand <a href="http://research.cs.queensu.ca/Parallel/QuantumChess/QuantumChess.html"/>the rules</a> before reading this page. </p>
13 <p> </p>
14 <p> 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. </p>
15
16 <hr>
17
18 <h2> Overview </h2>
19
20 <p> In the following, lines prefixed with "&lt;&lt; " indicate input to the agent, lines prefixed with "&gt;&gt; " indicate output. </p>
21 <p> The end line character is a unix new line character '\n'. There is no carriage return. </p>
22 <p> A token prefixed with '$' is taken to be variable, whilst all other tokens are to be interpreted literally. </p>
23
24 <hr>
25
26 <h2> Game start </h2>
27
28 <p> &lt;&lt; $colour </p>
29 <p> Where: </p>
30 <ol> 
31         <li> $colour is either "white" or "black" and indicates the colour the agent will be playing as. </li>
32         <li> The agent should make <i>no response</i> to this message. If it does, it will be declared illegal. </li>
33 </ol>
34
35 <hr>
36
37 <h2> Request: Selection </h2>
38
39 <p> &lt;&lt; SELECTION? </p>
40 <p> &gt;&gt; $x $y </p>
41 <p> &gt;&gt; $x $y $index $type
42
43 <p> Where: </p>
44 <ol>
45         <li> $x and $y are the x and y co-ordinates of the piece that the agent wishes to select. </li>
46         <ol type="i"> <li> $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. </li>
47              <ol type="a"> <li> The top left square is (x,y) = (0,0). The bottom right is at (x,y) = (7,7). </li>
48                   <li> Qchess does <b>not</b> recognise standard chess square names (eg: E5) </li>
49                   <li> A piece belongs to the agent if its colour matches that of the agent. </li> </ol>
50         </ol>
51         <li> An invalid selection results in the game ending with the offending agent declared illegal </li>
52         <li> A valid selection results in a response from qchess; see <b> Update: Agent selects a piece </b> </li>
53         </ol>
54 </ol>
55         
56 <hr>
57
58 <h2> Request: Movement </h2>
59
60 <p> &lt;&lt; MOVE? </p>
61 <p> &gt;&gt; $x $y </p>
62
63 <p> If an agent selects a piece that cannot move, it will not receive this request before its next selection. </p>
64
65 <p> Where: </p>
66
67 <ol>
68         <li> If an agent selected a piece that couldn't move, it will not receive this request before another selection request </li>
69         <li> $x and $y are the co-ordinates of the destination square </li>
70         <ol type="i">
71                 <li> 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 </li>
72                 <li> If the square was occupied by a piece of the opposing colour, that piece is "taken" and removed from the game </li>
73                 <li> If the "taken" piece was the opposing king, the agent will win the game. </li>
74                 <li> The agent must always make a move </li>
75         </ol>
76         <li> An invalid move results in the game ending with the offending agent declared illegal. </li>
77         <li> A valid selection results in a response from qchess; see <b> Update: Agent moves a piece </b> </li>
78 </ol>
79                 
80
81 <hr>
82
83 <h2> Update: Agent selects a piece </h2>
84
85 <p> &lt;&lt; $x $y $index $type </p>
86
87 <p> Where: </p>
88 <ol> 
89      <li> $x and $y are the x and y co-ordinates of the selected piece </li>
90      <li> $index is either "0" or "1" and indicates which of its two states the selected piece is in. </li>
91      <li> $type is a string indicating what the state of the piece actually is. </li>
92      <ol type="a"> <li> This string is one of: "king", "queen", "rook", "knight", "bishop" or "pawn". </li>
93                    <li> The piece's next move will obey traditional chess movement rules for a piece of this type. </li> </ol>
94      <li> The agent should <b> not </b> respond to this message, or it will be declared illegal
95 </ol>
96
97 <hr>
98
99 <h2> Update: Agent moves a piece </h2>
100
101 <p> &lt;&lt; $x1 $y1 -&gt; $x2 $y2 </p>
102
103 <p> Where: </p>
104 <ol>
105         <li> The piece will have been been selected immediately prior to being moved. </li>
106         <li> $x1 and $y1 are the x and y co-ordinates of the piece's original square. </li>
107         <li> $x2 and $y2 are the x and y co-ordinates of the piece's destination square. </li>
108         <li> Qchess does <b> not </b> provide any indication as to whether the move captured a piece or not </li>
109 </ol>
110
111 <p> <b> Note: </b> 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. </p>
112
113
114 <hr>
115
116 <h2> Game ends </h2>
117
118 <p> &lt;&lt; QUIT </p>
119
120 <p> Where: </p>
121
122 <ol>
123         <li> The agent should immediately exit cleanly without sending any response. </li>
124         <li> Agents which do not exit after 2 seconds shall be sent SIGKILL </li>
125 </ol>
126
127 <hr>
128
129 <h2> Notes: </h2>
130 <ol>
131         <li> 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. </li>
132         <li> Agents can expect to receive an "update" message after responding successfully to the corresponding "request" </li>
133         <li> If no request was made, the agent can assume the "update" is due to the action of the opponent. </li>
134 </ol>
135 <hr>
136 <p> Page last updated 2013-02-19 by matches </p>
137
138 <p> <a href="http://www.ucc.asn.au">The UCC Website</a> </p>
139 <p> <a href="http://progcomp.ucc.asn.au/2013/web">UCC::Progcomp 2013</a> </p>
140
141 </body>
142
143 </html>

UCC git Repository :: git.ucc.asn.au