A server for the game Noughts and Crosses

About the game

In this game two players place markers (O:s and X:s) in the squares of a board. The winner is the player that first gets five markers in a row:

About the server

I have installed a Noughts and Crosses server on dogbert, port 30831. You can test it by doing
telnet dogbert 30831
and use it in a fudget program by connecting to it with openSocketF, as I mentioned in the lecture on Fudgets.

The messages sent to and from the server all consist of one line of text.

The two players are called 0 and 1. Examples of commands you can send are:

init 20 20
creates an empty bord of size 20x20 squares. The response from the server is:
init 20 20
h 0 10 15
tell the server that the human user makes a move for player 0 by marking square (10,15).
c 1
ask the computer to make a move for player 1. The response is, for example
c 1 10 14
x
close the connection
Usually, the response to a command looks similar to the command. If winning move is made, the response starts with the letter w instead of h or c.

If an error occurs, the response is the letter e followed by an error message. The server may also output a copyright message starting with the letter r.

Acknownledgements

The server was implemented by Claes Löfqvist. See also his web page on Noughts and Crosses for BeOs.
Links