The Prisoner's Dilemma Game is a strategic game built with Go, allowing players to explore the classic game theory problem. Players can compete against each other either locally or over a network, choosing between cooperation or defection in each round. The outcome of each decision impacts their "prison time," with the goal of minimizing their own time.
- Local and Network Play: Choose to play against another player on the same machine or over the network.
- Multiple Rounds: Customize the number of rounds and view summaries after the game.
- AI Opponent: Play against different AI strategies like Tit-for-Tat or Random (future release).
- Futuristic UI: Experience a sleek, animated interface with cool ASCII art and a modern design (future release).
- Go 1.20 or higher
- A terminal or command line interface
- Clone the repository:
git clone https://github.com/kh3rld/prisoners-dilemma.git
- Navigate to the project directory:
cd prisoners-dilemma
- Initialize the Go module:
go mod init github.com/kh3rld/prisoners-dilemma
- Tidy up the dependencies:
go mod tidy
- Build the project:
cd ./cmd && go build .
- Run the game:
./cmd
When you start the game, you'll be presented with a menu:
- 1. Play Locally: Start a local game between two players on the same machine.
- 2. Play Over Network: Host or join a game over the network.
- 3. View Instructions: Learn how to play the game.
- 4. Quit: Exit the game.
Follow the prompts to enter your choices and enjoy the game!
To play over the network:
- Host a Game: Select "Host a Game" on one machine and wait for the other player to join.
- Join a Game: Select "Join a Game" on the second machine and enter the host’s IP address.
- Each player can choose to cooperate or defect.
- If both players cooperate, they each get 1 year in prison.
- If one defects while the other cooperates, the defector goes free and the cooperator gets 3 years in prison.
- If both defect, they each get 2 years in prison.
- The goal is to minimize your prison time over multiple rounds.
We welcome contributions! Please fork the repository and submit a pull request with your improvements.
- Add AI opponents with different strategies.
- Implement a leaderboard for networked games.
- Enhance the user interface with more animations and effects.
This project is licensed under the MIT License - see the LICENSE file for details.
- Special thanks to the Go community and open-source contributors.
- Inspired by the classic game theory problem, the Prisoner's Dilemma.
Feel free to reach out via X or GitHub for any questions or feedback.