/dicegame

Object oriented dice game

Primary LanguagePython

dicegame project

Object oriented python

This dice game was developed from an 'object oriented python' tutorial.

To play the game

Run 'dbgame.py' to play the game.

It has a simple menu driven user interface that allows a single player to roll dice, reroll & score much like the UK version of 'Yahtzee'.

The files

dice.py

The dice object and D6 were created during the tutorial to provide a 6-sided dice object for use in dice games.

hands.py

This creates a 'hand' object that holds 5 dice.

reroll.py

This places previously rolled dice into a hand and allows selected dice to be rerolled.

scoresheets.py

This evaluates a score for any given 'hand' or reroll hand.

dbgame.py

This file interacts with all of those listed above plus 'yahtzee.db' to provide the full 1-player game.

Other files

  • 'game.py' is a test game to check components are working - it doesn't keep the scores
  • 'auto.py' is a simple experiment with automatic scoring and could be further developed as a 'computer' player
  • 'yahtzee.db' is the sqlite database used to keep scores in 'dbgame.py'
  • 'tests.py' contains units tests to check 'dice.py'