A command-line simulator for the card game "Go Fish" with support for different player strategies and customizable game rules.
- Modular design with separate components for cards, players, and game logic
- Multiple AI player strategies:
- Random: Makes completely random choices
- Smart: Prioritizes ranks it already has multiple cards of
- Memory: Remembers which cards other players have asked for
- Human player support for interactive gameplay
- Customizable game parameters (number of players, initial cards, etc.)
- Simulation mode for running multiple games and gathering statistics
src/
├── gofish/
│ ├── __init__.py
│ ├── cards.py # Card, Deck, and Hand classes
│ ├── player.py # Player interface and strategy implementations
│ └── game.py # Core game logic
└── main.py # Command-line interface
- Python 3.6 or higher
Run a single game with 4 random AI players:
python src/main.pyInclude a human player:
python src/main.py --humanCustomize the number of players and initial cards:
python src/main.py --players 3 --initial-cards 5Run a simulation of multiple games:
python src/main.py --games 100 --quietMix different player types:
python src/main.py --player-types random,smart,memorySet a random seed for reproducible results:
python src/main.py --seed 42--players N: Number of players (default: 4)--human: Include a human player--initial-cards N: Number of cards to deal initially (default: 7)--quiet: Run in quiet mode (no verbose output)--games N: Number of games to simulate (default: 1)--player-types TYPES: Comma-separated list of player types: random, smart, memory (default: random)--seed N: Random seed for reproducible results
To create a new player strategy, subclass the Player abstract base class in player.py and implement the required methods:
from gofish.player import Player
class MyCustomPlayer(Player):
def choose_rank_to_ask_for(self):
# Your strategy for choosing a rank
pass
def choose_player_to_ask(self, player_names):
# Your strategy for choosing a player
passThe core game logic is centralized in the GoFishGame class in game.py. You can modify this class to implement different rule variations.
This project is licensed under the terms of the MIT license.