Introduction

We wish to provide anyone with a little knowledge of Mathematica the basic elements necessary to program 2-person impartial games. We intend this site to become a resource of examples of games that can rendered, in a pleasing way, and then investigated. Thus it can serve the needs of students, teachers, researchers, hobbyists, etc. Hopefully the list of examples will grow and the tools will be expanded and improved.

An elementary exposition of these games, along with details on how to program them can be found in our paper, Playing Games with Mathematica, which appeared in Mathematica in Education and Research in 1998 and can be downloaded below.The standard reference for these games is the 2-volume set, Winning Ways, by Berlekamp,Conway and Guy, Academic Press, 1982. A very nice introduction to these games can be found in the text, Introduction to Discrete Math, by McEliece, Ash and Ash, Random House, 1989. Also there is a chapter on playing and programming games with Mathematica in the book, Discovering Mathematics with Mathematica, by Cowen and Kennedy, Erudition Books, 2001. Finally, there is the extensive games bibliography, compiled by Aviezri Fraenkel, which can be accessed through his home page: http://www.wisdom.weizmann.ac.il/~fraenkel/.

The common basis of the programs can be found in, GamesEngine.nb, which should usually be loaded first. The other notebooks contain individual games, mostly known, but some invented for this project (2d-welter and non attacking queens).

We strongly encourage contributions to this project and feedback, so that it can grow into something truly useful.
Send to: rcowen@nyc.rr.com


Robert Cowen
Robert Dickau
  1. Playing Games with MathematicaAn introduction to 2 person impartial games and programming them in Mathematica using the game, cram, as an illustration. Cram is played on a rectangular board, with possibly some squares removed; players put dominoes on unoccupied squares (dominoes cover two squares). Last player who places a domino, wins. A compressed version of this large file is available here.
  2. GamesEngineThe "core" of any games program in Mathematica, which implements the Sprague-Grundy algorithm. Allows also for random choices when there is more than one "good" move. Also has a "quick" version which only uses 0s and 1s for grundy numbers. In addition provides for graphics for displaying some games.
  3. nim A collection of heaps of counters is given initially. Then the two players take turns removing counters from any one heap. Last player to move wins.
  4. Grundy's game Like nim, collection of heaps of counters is given; however, this time, the players take turns dividing any heap into two heaps of unequal size.
  5. kayles Bowling pins are arranged in a row. Each player can knock down one pin or two adjacent pins. Last player to knock down a pin, wins.
  6. Keep Your Distance Played on a ruled strip. Players put down tokens on unoccupied squares, but not next to an occupied square! Last player to place a token, wins.
  7. welter Played on a ruled strip with tokens on some of the squares. Players move tokens to the right onto unoccupied squares. Last player to move, wins.
  8. 2d-welter Like welter but on a two dimensional ruled board. Players can move tokens to the right or down.
  9. strip dominoes Players put dominoes on unoccupied squares of a ruled strip (dominoes cover two squares). Last player to move, wins.
  10. non-attacking queens Players put Queens down on an n by n chessboard. No Queen can attack any previously placed Queen. Last player to move, wins.