Your program (a client) will communicate with another player (also a client) via a server. (See figure below.) The server runs on port 153 of avrim.pc.cs.cmu.edu.
![]()
Figure 2: A FishNet game setup.
The server's job is to pair players together, to deal cards, to referee the game, and to notify players of the game's progress. The server keeps track of both players' hands and takes care of the forced communication (replying to requests and revealing books) on its own. It frequently sends information to the clients about the progress of the game, and it prompts the clients to choose which rank to request when appropriate. The client's primary tasks, therefore, are to keep track of what is in the hand (based on the server's messages) and to generate requests when the server prompts the program to do so. Your program may assume the server referees the game properly; very few of the rules will need to be incorporated into the program.
The following is a sample communication session between the server and a client. The server's messages are in boldface type, the client's in normal type. The C++-style comments describe what is happening and are not part of the communication.
In this game, Spot receives seven cards in the deal and happens to complete a book of zeroes, leaving three cards. Spot loses two of these when you request 3s, leaving one card. Then, when it becomes Spot's turn, Spot holds a single card. Spot requests 2s, of which you have two. Spot requests 2s again, and of course you have none. But Spot fishes a 2, completing a book. Since Spot fishes the same card as requested, Spot gets another request. But Spot has no cards; thus the game ends. Spot has two books (of 0s and 2s) while you have none, so you lose.play cburch spot // You identify yourself and who you want to play fish 3 // Server deals the hand 2,2,3,4,4,9,12 to you fish 4 fish 2 fish 4 fish 9 fish 12 oppmakes 0 // Spot made a book of four 0s during the deal fish 2 // You are dealt your seventh card yourturn // Server chose you to go first request 3 oppgives 2 3 // Spot had two of the 3s you requested yourturn // Server tells you to go again request 12 fish 8 // Spot had none; you draw an eight request 2 // Spot requests 2s (you lose two 2s) request 2 // Spot requests 2s again (you lose none) oppmakes 2 // Spot completes a book of four 2s youlose // Spot is out; with two books to your none, Spot wins
Each FishNet message consists of an operation, followed by some arguments separated by spaces, followed by the end of a line. The following describes operations used in the FishNet protocol. (The only message the server does not send is the play message. The client sends only play, request, and pass messages.)
When the server receives this request, it sees if it has any opponent by the requested name waiting for you. If so, it begins a game. If not, it sends nothing to the client until an opponent of the desired name requests a game with you. Note that the choice of which opponent goes first is always random.
Built into the server are four players always available to play: spot, bob, alice, smarx (in increasing order of difficulty). The last is the 1998 PGSS Go Fish champion, by Steve Marx.