GF2 (Gipf for two)
This document is a description of the next stage of GF1-development.
The goal is to make it possible to play Gipf over the internet in real-time with GF1 as the user-interface.
For playing Gipf over the internet you will need 2 things, a client and
a server.
The client will be GF1. You will make your moves on the gipf-board as
you are used to now, but instead of handling the moves internally the
moves will be sent to the server.
The server (which I have called GF2 for the moment) will do all the
administrative tasks: connect players with each other, start games, ...
The following is a scenario of how to play against an opponent over
the internet.
- Connect to the server
- Start a new game
- Play
2.1 Connect to the server
GF1 will have a new option: Networkgame.
When you choose this option, a
window
will open asking you to enter the following information:
- server+port: the name or address of the server where GF2 is running
- username: the name you want to use on the server
- password: to make sure nobody else plays with your name
When you choose the OK-button, GF1 will attempt to make a connection to the
server you entered. If the connection succeeds, he will try to login with
the username and password you entered. If this is also successfull you will
be shown the main network-dialog.
If the connection fails, you have to check the server+port you entered for
any typo's. If you are sure this is correct you e sure this is correct you will have to try to contact
the person who is responsable for the server.
If you get a connection but your login-attempt fails, there are 2
possibilities:
- You typed the wrong username and/or password: correct it and try again.
- This is the first time you log on to the server so you don't have a
username and a password.
If the second option is the case, the you can click on the 'new user'-button
to create your own username on the server. this will open a new
window where you have to enter some
information about yourself.
- Username: It's preferable that you use your own name, but if you want
to remain "unknown", then you can use an alias
- Password (2x): A password is necessary to make sure nobody can play
in your name (and lower your rating :-)
- e-mail address: this is optional. it's ok to leave this field blank, but
then you can't be contacted with important news about the server.
GF1
GF1 will save all this information in a configuration-file so you don't have
to enter it every time.
2.2 Start a new game
When you are connected to the server a new
window will open showing you a list
of all the other players currently connected to the server. This list will show
their name and if they are currently playing a game.
You will also see a list of all the games in progress and the people
participating in them.
You can then select a name from the list of people who are not currenly
playing a game. The server will ask the other player if (s)he wants to play
against you. If the answer is yes the game can start.
REMARK: I don't know at what point or who will decide what type of game
to play or if it will be a timed game.
(the first version will have no possibility to choose what game to play. all
games will be untimed tournament games.)
2.3 Play
Playing will be just as normal. But instead of everything beingd of everything being handled
internally in GF1, all moves will be sent to the server which will see
what the result of your move is and send you the new board-situation.
extra possibilities while playing:
- Resign the game: If you think you have no chance of winning the game
anymore then you can resign.
- Stop the game: Your opponent will get a question if he agrees. I don't
know yet if it will be possible to resume a game later.
- Send messages to your opponent: While playing you will be able to
exchange messages with your opponent (to congratulate him on a very good move
for example).
- The server will store all the games ever played. (probably only the
log-files, because that's the only thing necessary to replay the game)
- The server should calculate a kind of ELO-ranking from
all the matches played. this ranking will be listed next to the name of
each player.
- It would be nice if other pe would be nice if other people could follow a match in progress.
(should they be able to see the messages between the players?)
- There should be a server for tournaments. Where you don't choose
yourself who you will be playing, but you play against a fixed opponent for
that step of the tournament.
- A "dating point" will probably also be necessary, where you can
say I will be available to play on that date from a certain hour. (in the
beginning this can probably be done with a mailing list)
- If for some unknown reason the connection between a player and the
server is broken while playing a game, the server should ask the other
player if he would like to wait for the disconnected player to return.
If the disconnected player logs on again, he should be automatically returned
to his game in progress.
- In a later stage it would be nice to have the possibility to view
server-information through a webbrowser. this could be done with a mini
webserver builta mini
webserver built into GF2, or with cgi-scripts that read the GF2 datafiles.
(it could even be possible to watch games this way.)
- what if somebody logs on twice at the same time with the same userid?
- when you start a game you should finish it (or resign). no stop
or interrupt possible!
- possibility to play a game which doesn't count for ELO.
4.1 step 1: basic
this will allow you to:
- choose an opponent
- play a game (always tournament without time-limit)
- the only score kept is the number of games lost and won
step 2
- allow watching games
- let players choose what type of game to play and timelimit.
step 3: the sky is the limit
If you have comments about this document, send a mail to
kurtvdb@village.uunet.be.
Please send all your reactions:
- do you like my ideas
- do you hate them
- am I doing something completely wrong
- do you want to help (programming or testing)
- even if you just want to wish me good luck
If you're not interested in how GF2 will work internally, then you can
skip the following part.
6.1 Connection states
This is a list of the different states a connection between GF1 and GF2 can
be in. (I think these states should be the same on client and server.)
NOTCONNECTED
there is no connection between client and server.
CONNECTED
TCP/IP connection has been established between client and server.
(the client can do nothing on the server yet because he still has to login)
possible client actions:
- login (LOGGEDIN)
- newuser (LOGGEDIN)
- newuser (LOGGEDIN)
possible server actions:
- disconnect (NOTCONNECTED)
LOGGEDIN
the client logged in with an existing name or made a new user.
you now get a list of players and games on the server
possible client actions:
- start game (PLAYING_MOVE, PLAYING_WAIT)
- view game (WATCHING)
- disconnect (NOTCONNECTED)
possible server actions:
- general message
- disconnect (NOTCONNECTED)
- do you want to play (PLAYING_MOVE, PLAYING_WAIT)
PLAYING_MOVE
you are involved in a game and it is your move.
possible client actions:
- move (PLAYING_MOVE, PLAYING_WAIT)
- resign game (LOGGEDIN)
- stop game (LOGGEDIN)
- private message
possible server actions:
- new gameboard (PLAYING_MOVE, PLAYING_WAIT)
- do you want to stop (LOGGEDIN)
- private message
- general message
- disconnect (NOTgeneral message
- disconnect (NOTCONNECTED)
PLAYING_WAIT
You are involved in a game and it is your opponents move.
possible client actions:
- private message
- stop (LOGGEDIN)
possible server actions:
- new gameboard (PLAYING_MOVE, PLAYING_WAIT)
- do you want to stop (LOGGEDIN)
- you have won/lost (LOGGEDIN)
- private message
- general message
- disconnect (NOTCONNECTED)
WATCHING
possible client actions:
- stop watching (LOGGEDIN)
- disconnect (NOTCONNECTED)
possible server actions:
- new gameboard
- general message
- disconnect (NOTCONNECTED)
WAITING_RECONNECT
Waiting for a reconnect when your opponent has unexpectedly disconnect
from the server.
possible client actions:
possible server actions:
- general message
- general message
- disconnect (NOTCONNECTED)
6.2 messages
All messages between the server and the client will be in the xmlite-format.
this makes them a little larger but it makes sure there will be no
problems with special characters and spaces in the parameters.
messages have a 3-digit number to identify them. the rest of the data
depends on this number.
messages from the server to the client:
- 100: message from the server
- 101: message from your opponent
- 110: login acknowledge
- 111: unknown user
- 112: new user acknowledge
- 113: username already taken
- 120: user list
- 121: game list
- 122: do you want to play
- 130: game situation (when playing or watching)
- 131: invalid move
- 132: opponent disconnected, do you want to wait
- 133: stop game (!! will probably not be allowed !!)
- 134: you win/lose
- 140: rou win/lose
- 140: reconnect (after unexpected connection-loss when opponent didn't
quit.)
messages from the client to the server:
- 200: message to opponent
- 210: login
- 211: new user
- 220: start game
- 221: view game
- 230: move (subdivide for normal move, remove gipf and remove row?)
- 231: wait for opponent reconnect
- 232: request stopping of the game
- 233: resign game
6.3 Classes
network class
Low level handling of the connection between the server and the client.
- connect to server (don't handle logging on)
- disconnect from server
- receive data from server
- send data to the server
- possibility to get the socket
I started writing this myself and normal connections and data sending
and receiving worked, but I have no idea how to handle all possible errors.
That's why I started looking for an exist's why I started looking for an existing library. Candidates at the
moment are:
- easynet-1.2: very simple, very understandable
networkgame class
High level interpretation of the messages being sent to and received from
the server.
will be kind of a state-machine.
must be called when:
- a message comes in on the network connection
- the user does something in the user-interface
security class
Used for encrypting passwords
- encrypt password using TEA (Tiny EncrYption Algorithm)
- decrypt using TEA
ascii85 class
Used for converting binary data to ascii. (This uses the ASCII85 algorithm)
- btoa: binary to ascii
- atob: ascii to binary
6.4 data kept by the server
- list of users (name, password, e-mail, matches won, matches lost, ELO)
- list of all the matches (players, winner, date)
- matches in progress (normal e)
- matches in progress (normal saved game format)
- finished matches (just the logfile)
6.5 random notes
- usernames should always be compared case-insensitive.
- passwords are compared case-sensitive. (correction, passwords are never
compared directly, the encrypted passwords are compared on the server)
- zlib can be used to compress the data sent between server and client.
(a saved game file can be up to 10 KB large.)
- protocolversion: In case the connection-protocol between server and
client changes, during startup communication they should check what protocol
each is using.
- view list of people watching your game. (maybe just show there names
in the logwindow when they start watching.)