YimengL / Hog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The skeleton code are provided by CS 61A, I finished the hog.py.

Files:

hog.py: A starter implementation of Hog
dice.py: Functions for rolling dice
hog_gui.py: A graphical user interface for Hog
ucb.py: Utility functions for CS 61A
ok: CS 61A autograder
tests: A directory of tests used by ok
images: A directory of images used by hog_gui.py


Description:

In Hog, two players alternate turns trying to reach 100 points first. On each turn, the current player chooses some number of dice to roll, up to 10. That player's score for the turn is the sum of the dice outcomes, unless any of the dice comes up a 1, in which case the score for the turn is only 1 point (the Pig out rule).

To spice up the game, we will play with some special rules:

  • Free bacon. A player who chooses to roll zero dice scores one more than the largest digit in the opponent's score.
  • Hog wild. If the sum of both players' total scores is a multiple of seven (e.g., 14, 21, 35), then the current player rolls four-sided dice instead of the usual six-sided dice.
  • Hogtimus prime. If at the end of a turn the sum of the scores of both players is a prime number, then the points earned during the current turn are also added to the score of the current leader at the end of the turn. If after adding the boost, the total score happens to be another prime number, subsequent boosts are not applied. In addition, if the two scores are equal, no boost is applied to either score.

Test

using ok (CS 61A autograder):

python3 ok --local

Play

python3 hog_gui.py

About


Languages

Language:Python 100.0%