Skip to content

dgalvan-zz/Hog-project-CIS61

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Hog-project-CIS61

Hog Game Simulator and Strategies

Introduction

Welcome to the Hog Game Simulator and Strategies repository! In this project, you will develop a simulator and multiple strategies for the dice game Hog, applying control and higher-order functions. The project involves implementing various game rules and strategies to create an engaging and challenging experience.

Game Overview

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. His/Her turn score is the sum of the dice outcomes, unless any of the dice come up a 1, in which case the score for his/her turn is only 1 point (the Pig out rule).

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

  1. Free bacon: If a player chooses to roll zero dice, he/she scores one more than the largest digit in her opponent's score. For example, if Player 1 has 42 points, Player 0 gains 1 + max(4, 2) = 5 points by rolling zero dice. If Player 1 has 48 points, Player 0 gains 1 + max(4, 8) = 9 points.

  2. 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.

  3. Swine swap: If at the end of a turn one of the player's total score is exactly double the other's, then the players swap total scores.

Example 1: Player 0 has 20 points and Player 1 has 5; it is Player 1's turn. She scores 5 more, bringing her total to 10. The players swap scores: Player 0 now has 10 points and Player 1 has 20. It is now Player 0's turn.

Example 2: Player 0 has 90 points and Player 1 has 50; it is Player 0's turn. She scores 10 more, bringing her total to 100. The players swap scores, and Player 1 wins the game 100 to 50.

Project Files

hog.py: The main file for implementing the game logic and strategies.

dice.py: Functions for rolling dice.

ucb.py: Utility functions for CS 61A.

hog_gui.py: A graphical user interface for playing Hog.

hog_grader.py: Tests to check the correctness of your implementation.

autograder.py: Utility functions for grading.

Graphical User Interface

A graphical user interface (GUI) is provided to play an interactive version of Hog. Ensure Tkinter is installed, and run the GUI from the terminal, use the next code to try and play:

python3 hog_gui.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages