Skip to content

Refactor project structure and implement Rock-Paper-Scissors AI#4

Open
JoshiMinh wants to merge 22 commits into
ethan-schaffer:masterfrom
JoshiMinh:main
Open

Refactor project structure and implement Rock-Paper-Scissors AI#4
JoshiMinh wants to merge 22 commits into
ethan-schaffer:masterfrom
JoshiMinh:main

Conversation

@JoshiMinh

Copy link
Copy Markdown

This pull request introduces a major refactor and modernization of the LivingRPS project, transforming it from a basic Pygame simulation into an AI-powered Rock-Paper-Scissors environment where each entity is a DQN agent. The codebase is restructured for modularity, maintainability, and AI integration, with improved documentation and user experience.

Key changes include:

1. Major Game Refactor & AI Integration

  • Replaced the old procedural main.py with a new src/main.py that uses a neural network (RPSAgentNet) to control agent behavior via deep Q-learning, including state feature extraction and action application for each agent. The game loop is now modular, uses a more robust collision system, and integrates audio/visual assets. [1] [2]
  • Added src/model.py defining the RPSAgentNet PyTorch neural network architecture for agent decision-making.
  • Refactored the agent logic into a new, fully documented src/mover.py class, supporting state representation, action application, and physics updates for AI-driven movement and interaction. [1] [2]

2. Project Structure & User Experience Improvements

  • Introduced a run.bat CLI menu for Windows users to install dependencies, train the model, or launch the game, streamlining setup and execution.
  • Added a comprehensive and visually enhanced README.md with usage instructions, requirements, and preview images for better onboarding and clarity.

Summary of most important changes:

Game logic & AI integration

  • Complete rewrite of the main game loop in src/main.py to use DQN agents, modular functions, and improved event handling. [1] [2]
  • Addition of src/model.py with the RPSAgentNet neural network for agent decision-making.
  • Refactored agent logic into a modern Mover class in src/mover.py, supporting AI state/action and physics. [1] [2]

Project usability & documentation

  • Added a user-friendly run.bat CLI menu for running, training, and installing the project on Windows.
  • Enhanced README.md with project description, setup instructions, and visual assets.

JoshiMinh and others added 22 commits September 16, 2024 18:12
…ing assets, updating model paths, and adding `requirements.txt`.
…Paper-Scissors AI

- Implemented the main game loop in `main.py` to handle player creation, AI inference, and collision detection.
- Added audio and visual assets for player actions.
- Created a training script in `train.py` for the RPS agent using reinforcement learning.
- Defined state representation, reward function, and action selection for the agent.
- Integrated experience replay and target network for stable training.
- Saved the trained model to a specified path after training completion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant