Giter Site home page Giter Site logo

e-dong / space-war-rl Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 14.43 MB

Recreating Bill Seiler's 1985 version of Space War and training RL agents with Self-Play

Home Page: https://e-dong.itch.io/spacewar

License: GNU General Public License v3.0

Python 95.93% Makefile 4.07%
ai machine-learning pygame reinforcement-learning self-play pygame-wasm

space-war-rl's People

Contributors

e-dong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

space-war-rl's Issues

Train DQN on dummy player 2

This is a good way to start developing the DQN algorithm. The dummy player does not move or shoot back, so this should be an easy task. The goal of the agent is to eliminate the target as fast as possible while staying alive.

Fix phaser line on screen wrap around

I can't use dist * cos(rad) and dist* sin(rad), because that assumes the intercept is always the same. The intercept can change, so I would have to calculate a new line formula or copy the rect and translate it correctly.

This is low priority and not that noticeable.

Implement movement physics

Implement zero gravity physics, when activating the thrusters the player will keep moving at the same velocity. It will be alot easier for the player to go out of bounds. I can either setup boundaries around the edges of the screen or implement the parallax of wrapping around the screen when the player goes out of bounds. I will probably do the latter since the original game does that.

Implement Proper Movement Actions

Image

Player rotation and and impulse engines will be implemented in this issue.
I will need to keep track of where the player is facing (0 - 359 degrees)

Implement Weapon Projectiles

There are two weapons in the game:

  • photon torpedoes
  • phasers

Torpedoes

In the original game, I noticed the image is different based on the angle the player fires them. For simplicity, I may keep them the same. Explosion animations will most likely be skipped for now. There can be multiple torpedoes, so the sprite class will make these easier to manage. There should be a timeout if the torpedoes do not hit anything and disappear.

Phasers

This will probably be the simplest to implement. I can just draw a straight line. I can probably use pygame.draw to draw a line. I will need to check if the rect collides with a player

Create Player 1

Replace the "Get Started" code and create a player sprite class. Movements in space war will be implemented in #2 , so I will use the same movements from the get started code. (WASD)

Add Player 2

Create pixel art for the player 2 sprite and render it in the game

Add Screen Wrap Around

In the 1985 game, the ship would wrap around to the other side of the screen. I should implement this as well.

Add Energy Management System

Image

  • Implement actions to balance between energy and shields
  • Add energy regeneration

#4 should be done first, collision with the projectiles will cause the shields to go down. Once shields are depleted, implement player death. When energy is depleted, ship cannot move and fire weapons until energy regenerates.

Add unit tests

Extract the logic into util functions to create unit tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.