posted by Jeremy Friesner on Mon 12th Aug 2002 20:52 UTC

"The Game and How to Play it"
Before getting into the implementation details, a brief user-level description of the game itself is in order. Our game will boast the following technical features:
  1. The game will consist of a server executable and a client executable. The server executable will be run on a central machine, and multiple clients may log in to the server at once in order to interact with each other.
  2. The game will support an arbitrary of players in a single game simultaneously. In addition to the players, there may be any number of spectators watching the gameplay unfold.
  3. The server will correctly handle players and spectators connecting to or disconnecting from the server at any time, with as little disruption of game play as possible. Clients that have crashed or otherwise become unresponsive will not interfere with the operation of the game.
  4. The server will take reasonable steps to disallow cheating -- that is, it will not "trust" the clients to follow the rules of the game, but rather it will check the clients' actions against the rules itself.
  5. All players and spectators will be able to see each other and talk to each other via a text-chat mechanism, during gameplay.
  6. The server will compile and run correctly with little or no effort on any OS with a modern TCP stack and C++ compiler. The client will compile and run on most modern OS's as well, subject to the limitations of the GUI toolkit. Clients and servers running under different operating systems will be 100% compatible with each other.
  7. The code code written to implement the client and server will contain no direct networking calls whatsoever -- instead, it will interact with the MUSCLE API, which will in turn handle the networking tasks.
  8. The game will be complex enough to be interesting (hopefully even fun!), but also simple enough to serve as a demo and source code example.

Click for a larger version This game is called "FoxRabbitCarrot", and it is a hybrid game; it is part board game, part strategy game, part cellular automata simulation. In this game, each player starts with several game pieces placed on a chess-style rectangular game board. The player's objective is to take over as much of the board as possible with his pieces, either through co-operation or competition with the other players. Each player's pieces are of three different types: Fox, Rabbit, or Carrot (hence the name). Gameplay is divided into 30-second long "turns", and during each turn every player can instruct any or all of their pieces to move to an adjacent square, if they wish to. At the end of each turn, all pieces are moved simultaneously, and rules are applied to any pieces that have come to share a square with another piece.

The rules for what happens to two pieces who occupy the same square are largely what you might expect: If a Fox and a Rabbit end up together, the Fox will eat the Rabbit, which improves the Fox's health meter, but destroys the Rabbit piece. Similarly, a Rabbit moved onto a Carrot will eat the Carrot. However, a Fox that moves onto a Carrot will be eaten by the Carrot! (this game features a truly nasty breed of carnivorous Carrot)

If two pieces of the same species come to share a single square, they will fight to the death, and the piece with the greater number of health points will be the sole survivor (although his health will be decreased by an amount equal to the loser's health points).

Sex, on the other hand, is something that operates across adjacent squares. If two pieces of the same species, but opposite gender, occupy adjacent squares, there is a pretty good chance that the male piece will impregnate the female piece during that turn. When this happens, the female piece becomes pregnant, and several turns later, she will give birth to a new game piece, which is added to the mother's team. Note that mating your own pieces together risks inbreeding, which shows up as a decreased chance of pregancy, and an increased incidence of sterile (neuter-gendered) children, which will not be able to mate with anyone. Because of this, it may be too your advantage to cooperate with other players to produce healthier offspring...

The last rule is this: every turn, every piece loses a small number of health points. If a piece loses all its health points, it will die of starvation. If all your pieces die (whether through starvation or being killed by another piece), you have lost and are removed from the game. However, you will remain as a spectator, and can re-enter the game on the next turn (if there are any open game slots remaining).

If you would like to try out the game, you can find server and client binaries for Windows, MacOS/X, and RedHat Linux 7.2, as well as source code, here:

  1. Windows binaries - Runs under Windows 98 or higher
  2. MaxOS/X binaries - Runs under MaxOS/X 10.1 or higher
  3. RedHat7.2 binaries - Runs under Red Hat Linux 7.2 (you might have trouble if your system has GCC 3.x - better recompile it from scratch in that case)
  4. Source Code - Source code for client, server, and MUSCLE (doesn't include Qt)
Table of contents
  1. "Foxes, Rabbits, and Carrots"
  2. "The Game and How to Play it"
  3. "A Brief Review of the MUSCLE Networking Layer"
  4. "muscled, The basic MUSCLE server"
  5. "Customizing the MUSCLE server"
  6. "How to Set up the Custom Server Logic"
  7. "The FRCPlayerSession Class"
  8. "The FRCGameStateSession class"
  9. "Overview of the FRC server"
  10. "The FoxRabbitCarrot Client Program"
  11. "How the Client Handles Database Update Messages"
  12. "MUSCLE gaming Performance Issues"
e p (0)    8 Comment(s)

Technology White Papers

See More