Programming AI Bots for Zombie Dice

UPDATE: I’ve set up a wiki for posting your own Zombie Dice bots: http://zombiedice.inventwithpython.com/

Download the Zombie Dice Python code from GitHub or as a zip file.

This tutorial outlines how to create a tournament simulation program for the Zombie Dice game in Python. With this tournament program, you can also code your own AI bots to play Zombie Dice against each other. You can quickly test out how the different strategies the bots use compare against each other over thousands of simulated games. This tutorial assumes you know basic Python programming. (You can learn to program from the free book on this site, “Invent Your Own Computer Games with Python”.

Computer game simulations make for great science fair experiments, and since the rules to Zombie Dice are so simple it’s fairly easy to program a simulation for it.

The Rules of Zombie Dice

Zombie Dice is a dice rolling game that is fun for groups, quick to play, and can be learned in a couple minutes. It has a “push your luck” game mechanic.

Each of the players is a zombie. Each of the dice represents a human victim. You want to eat brains and avoid shotgun blasts. If the footsteps come up, the human has eluded you. The rules are summarized below: (Or view the official rules PDF or view the Flash tutorial.)

  1. On your turn grab 3 dice from the cup and roll them. Dice are colored red, yellow, and green and have footsteps, brains, or shotgun icons.
  2. Set aside any brain and shotgun dice.
  3. If you have 3 shotguns, your turn ends with a score of 0.
  4. You can decide to either stop rolling or roll again.
  5. If you stop, your score for this turn is the number of brains you have.
  6. If you re-roll, keep the footsteps dice you rolled, set aside the brain and shotgun dice rolled, and randomly grab dice to replace the brain and shotgun dice. Roll the 3 dice.
  7. Go back to step 4. You basically can keep re-rolling for as long as you want to push your luck.

To win:

  • Once a player gets 13 brains, finish the round. If there is a tie, the tied players play a single tie breaker round.
  • Also, if you run out of dice for your turn, note the number of brain dice you’ve rolled and place those brain dice back into the cup. Then continue as normal.
  • The colors note your odds of winning. The entire dice set has 6 green, 4 yellow, and 3 red dice.

    Here’s a video of gameplay:

    Running the Tournament Program

    Download the Zombie Dice simulation code. This should run with Python 2 and Python 3. You can also find it on GitHub. The two main files are:

    • zombiedice.py is the basic simulator and outputs text results when the tournament is finished.
    • zombiedice_web.py runs a web server and launches your browser to provide a GUI and real-time updates while the tournament is in progress.

    When you click the “Begin Tournament” button, the simulation will begin with the loaded bots:

    Next page