This is my final project for CKCS149 DCY - Python Programming - P2024.
I created a Pygame-based Rock Paper Scissors game that now utilizes Mediapipe hand detection, replacing the previous YOLOv8 model, for improved performance. Additionally, I developed several game modes, including a multiplayer version using sockets and an AI opponent powered by ChatGPT. My name is Rolex Antoine Alexander. Lecturer: Dr. Mihal Miu.
- Ensure your environment has access to a camera and Python installed.
- Install the required dependencies:
pip install -r requirements.txt
Copy the example environment file and replace its contents
cp env.example .envUpdate the .env file with your values:
GITHUB_TOKEN=your_github_token
SERVER_IP=270.1.0.0.1
SERVER_PORT=5555To play against a randomly selecting computer:
python main.pyTo play against the AI opponent:
python versions/you_vs_ai.pyEnsure your GitHub token is set in the environment (.env) to allow proper functionality.
To play against another player:
- Start the server:
python src/server.py
- Set your
.envfile with the following details:SERVER_PORT: Port where the server is running.SERVER_IP: IPv4 address of the server.
- Run the multiplayer version:
python versions/multiplayer.py
Important: Do not run two instances of multiplayer.py on the same system, as only one process can access the camera at a time.
To watch two AI instances compete:
python versions/ai_vs_ai.pyThis game leverages your camera to detect hand gestures using Mediapipe. Depending on your gesture ("rock," "paper," or "scissors"), the game:
- Matches your choice against a random computer, AI, or another player.
- Displays the result (win, lose, or draw) with the current score.
- Multiplayer Mode: Play with a friend via a local server.
- AI Opponent: Challenge ChatGPT in a strategic 1v1 match.
- AI vs AI Mode: Watch two AI instances battle it out.
- The previous YOLOv8 model was replaced with Mediapipe for more accurate hand detection.
- For the multiplayer mode, ensure the server is correctly configured, and camera access is limited to one instance at a time.
main.py: The classic "You vs Random Computer" game.versions/you_vs_ai.py: Play against ChatGPT.versions/multiplayer.py: Multiplayer mode using sockets.versions/ai_vs_ai.py: Watch two AI instances compete.src/server.py: Server for the multiplayer mode.
For you_vs_ai.py and ai_vs_ai.py, a JSON file (log.json) is generated in the log folder, detailing the reason behind the AI's move. Exploring the logs for the ai_vs_ai.py version will provide fascinating insights into the AI's decision-making process.
Below are screenshots of the game in action:
Feel free to contribute to the project by improving the gameplay or optimizing the code. Suggestions and feedback are welcome! Test out the various modes, especially playing against the AI, and see if you can beat ChatGPT in a 1v1 Rock Paper Scissors showdown.
This project is open-source. Contribute and modify as needed!





