Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmlen/game-of-pyg
Pronounced "Game of Pig"
https://github.com/dmlen/game-of-pyg
Last synced: about 2 months ago
JSON representation
Pronounced "Game of Pig"
- Host: GitHub
- URL: https://github.com/dmlen/game-of-pyg
- Owner: DMLen
- License: gpl-3.0
- Created: 2024-05-19T23:52:35.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-22T01:43:03.000Z (8 months ago)
- Last Synced: 2024-05-22T03:01:06.777Z (8 months ago)
- Language: Python
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# game-of-pyg
*Pronounced "Game of Pig"*A command-line Python implementation of the dice game Pig, also known as Greedy Pig as described on [Wikipedia](https://en.wikipedia.org/wiki/Pig_(dice_game)).
Inspired after seeing the [video on the topic](https://www.youtube.com/watch?v=ULhRLGzoXQ0) by the wonderful youtube channel Numberphile.## Basic Rules
*From Wikipedia*Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player decides to "hold":
1. If the player rolls a 1, they score nothing and it becomes the next player's turn.
2. If the player rolls any other number, it is added to their turn total and the player's turn continues.
3. If a player chooses to "hold", their turn total is added to their score, and it becomes the next player's turn.The first player to score 100 or more points wins.
## Supports play against CPU!
The difficulty of the CPU player can be selected at game start.
The CPU will use three different strategy algorithms depending on the desired setting.
1. "Easy" == The CPU will randomly decide when to end its turn. By default, it has a 1/4 chance to end the turn.
2. "Medium" == The CPU will roll until it has reached 20 points for the current turn. When this number is exceeded, it ends the turn. Also known as a "Hold N" strategy.
3. "Hard" == The CPU will use the "End race or keep pace" algorithm described by Neller and Presser, preferring to take large risks once the goal is almost reached. This represents near-optimal play of the game.