Pig Game GUI

Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:

Problem:  Implement a GUI for the game of Pig where the user plays a succession of games against a computer player.  A brief summary of software requirements follows.

Overview

Your goal is to create a simple-yet-fun GUI implementation of the game of Pig.  The user is the starting player of the first game.  The starting player alternates with successive games.  The computer plays a "Keep Pace and End Race" policy as follows:  Let the hold value be 21 + round((user score - computer score) / 8).  If either player has 71 points or more, or if the turn total is less than the hold value, then roll.  Otherwise, hold.

Resources

Image files are supplied in PNG and JPEG formats.

Graphical User Interface Components

Main application frame titled "Pig", terminating program on close, and containing:

For the most part, layout is not specified.  However, the related label-value label pairs should be horizontally adjacent with the label to the left of the value label.

Functional Specification

Initialization

Roll Button

Roll Action

Hold Button

Hold Action

Change Turn Action

Computer Turn

End Game Action


Extra Exercises:

1. Use an alternative computer play policy.  Let i be the player's score, j be the opponent's score, and k be the current turn total.  Some alternative play policies:

2. Compute win statistics (e.g. games won, games lost, percentage won) and display these at game end.

3. Extend design to three or more user/computer players.

4. (Advanced Project) Extend design to three or more user/computer players over a network, using a client-server model. 


Todd Neller