{"id":19251659,"url":"https://github.com/lokranjanp/asteroidsai","last_synced_at":"2025-04-21T13:30:38.931Z","repository":{"id":243805361,"uuid":"801876228","full_name":"lokranjanp/AsteroidsAI","owner":"lokranjanp","description":"Training a Deep Q Learning agent to master the famous arcade game, Asteroids using a DQN Neural Network with Long and Short term Memory recall. This is also my undergrad minor project, 21IS6P01.","archived":false,"fork":false,"pushed_at":"2025-04-08T02:58:04.000Z","size":18590,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-08T03:32:56.311Z","etag":null,"topics":["deep-learning","neural-networks","qlearning","reinforcement-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lokranjanp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T05:01:24.000Z","updated_at":"2025-04-08T02:58:08.000Z","dependencies_parsed_at":"2024-11-09T18:26:31.370Z","dependency_job_id":"bf13f915-4de8-4d0c-b34f-4f9955f7425a","html_url":"https://github.com/lokranjanp/AsteroidsAI","commit_stats":null,"previous_names":["lokranjanp/asteroidsai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokranjanp%2FAsteroidsAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokranjanp%2FAsteroidsAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokranjanp%2FAsteroidsAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lokranjanp%2FAsteroidsAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lokranjanp","download_url":"https://codeload.github.com/lokranjanp/AsteroidsAI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250064488,"owners_count":21368914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","neural-networks","qlearning","reinforcement-learning"],"created_at":"2024-11-09T18:23:24.939Z","updated_at":"2025-04-21T13:30:33.921Z","avatar_url":"https://github.com/lokranjanp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI-Powered Asteroids Game\n\n## Overview\nArcade game using Pygame and open-source game graphics built in Python 3.10. This project served as a facilitator game for an undergrad minor project to train a Reinforcement Learning (RL) model to play Asteroids.\n\n### Game Graphics\nGame graphics used from: [Spacecraft Redux](https://www.kenney.nl/assets/space-shooter-redux)\n\n### Human Playable Game\nThe human-playable version of the game can be found at: [Asteroids](https://github.com/lokranjanp/Asteroids)\n\n### Data Analysis Repository\nData analysis comparing human and RL agent gameplay can be found at: [Asteroids Data Analysis](https://github.com/lokranjanp/Human-RL-DQN-interpretations)\n\n## Project Phases\n\n### Phase 1: Human Playable Game\nDeveloped a fully functional, human-playable version of Asteroids using Pygame. This phase involved:\n- Designing game mechanics\n- Creating graphics and controls for smooth gameplay\n\n### Phase 2: Game Reinforcement Learning (RL)\nIntegrated a reinforcement learning (RL) agent into the game using PyTorch. Key tasks included:\n- Training the RL agent to play the game autonomously\n- The agent learned through trial-and-error to navigate, avoid obstacles, and maximize its score\n\n### Phase 3: Human Game Data vs. RL Game Data Analysis\nAnalyzed game data from human players against the data generated by the RL agent. This provided insights into differences in:\n- Gameplay strategies\n- Decision-making processes\n- Overall performance\n\n## Technical Details\n\n### Neural Network Architecture\nThe RL agent was trained using a deep neural network with the following architecture:\n\n- **Input Layer:** Takes the game state as input, which includes the spaceship's position, health, power level, points, and positions of asteroids and bullets.\n- **Hidden Layers:** Two fully connected hidden layers with ReLU activation functions.\n- **Output Layer:** Outputs action probabilities for moving left, right, forward, and shooting.\n\nThe neural network was trained using the DQN (Deep Q-Network) algorithm, optimizing the following parameters:\n- **Learning Rate:** 0.001\n- **Gamma (Discount Factor):** 0.99\n\n## Installation\n\n### Prerequisites\n- Python 3.10\n- Pygame\n- PyTorch\n\n### Setup\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/lokranjanp/AsteroidsAI.git\n    ```\n2. Navigate to the project directory:\n    ```bash\n    cd AsteroidsAI\n    ```\n3. Install the required dependencies:\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n### Running the Game\n1. To play the human-playable version:\n    ```bash\n    python3 main.py\n    ```\n2. To run the RL agent:\n    ```bash\n    python3 agent.py\n    ```\n\n## Usage\n\n### Human Playable Game\n- Use arrow keys to move the spaceship.\n- Press the spacebar to shoot.\n\n### RL Agent\n- The RL agent automatically navigates and plays the game based on the trained model.\n\n## Contributing\nWe welcome contributions to improve the project. Please feel free to submit a pull request or open an issue to discuss any changes.\n\n\n## Acknowledgements\n- [Kenney.nl](https://www.kenney.nl/assets/space-shooter-redux) for providing the game graphics.\n- Our project guide, Dr. Shashank Dhananjay, Associate Professor @ Dept of ISE, NIE, Mysore and reviewer for their \n  valuable feedback and support.\n\n---\n\nHappy gaming! 🎮🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokranjanp%2Fasteroidsai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flokranjanp%2Fasteroidsai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flokranjanp%2Fasteroidsai/lists"}