Giter VIP home page Giter VIP logo

stepantita / q-learning Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 283 KB

a Python-based platformer infused with Q-Learning and dynamic level creation from simple JSON files.

License: MIT License

Python 100.00%
epsilon-greedy game-ai machine-learning machine-learning-algorithms platformer-game python q-learning q-learning-algorithm reinforcement-learning reinforcement-learning-algorithms

q-learning's Introduction

Q-Learning game with epsilon-greedy algorithm ๐ŸŽฎ ๐Ÿง 

This is a university project. The game with basic level editing. One can add obstacles, enemies, and bonuses on the level by putting those in the JSON file. That way creating and editing test environments is as easy as adding a couple of rows to the JSON file. After the level is built, one should initialize some basic parameters and see the model performance. Based on that, one may consider updating or keeping the parameters. The game itself is just a set of primitives. The objects can either be static or moving. We also introduce the concept of reward backpropagation in this project.

More precise description of the solution and full report please find in the REPORT

Demo:

Screen.Recording.2023-08-10.at.20.37.54.mov

Features ๐Ÿš€

  • Q-Learning Powered: Experience a game environment influenced by Q-Learning.
  • Epsilon-Greedy Strategy: Watch the game evolve and adapt its strategy over time.
  • Custom Levels: Design and play on your very own levels using straightforward JSON structures:

*.json level file

{
  "floors": [
    {
      "shape": "rect",
      "type": "platform",
      "x": 0,
      "y": 650,
      "width": 150,
      "height": 10
    }
  ],
  "walls": [
    {
      "shape": "rect",
      "type": "wall",
      "x": 800,
      "y": 400,
      "width": 10,
      "height": 300
    }
  ],
  "spikes": [
    {
      "shape": "triangle",
      "type": "spike",
      "scale": 25,
      "internal_angle": 45,
      "rotation": 0,
      "x": 150,
      "y": 575,
      "rotor": true,
      "angle": 5
    }
  ],
  "finish": {
    "shape": "rect",
    "type": "finish",
    "x": 950,
    "y": 650,
    "width": 100,
    "height": 10
  }
}

Tech Stack ๐Ÿ“š

  • Python
  • Reinforcement Learning: Q-Learning with epsilon-greedy algorithm
  • Reward backpropagation concept. Please find detailed description in the REPORT

Getting Started ๐Ÿ

Prerequisites

  • Python 3.8+

Installation

  1. Clone the repository:
git clone https://github.com/StepanTita/q-learning.git
  1. Install requirements:
pip install -r requirements.txt
  1. Run the game:
python main.py

or

  1. Run the game in reinforcement learning mode:
cd reiforcement # make sure you are in the correct direction
python main.py

Level Creation ๐ŸŒ

Create custom levels using JSON files. Refer to the level creation guide to learn about the structure and possibilities!

License ๐Ÿ“„

This project is licensed under the MIT License. See the LICENSE.md file for details.

TODO:

  • enemies

q-learning's People

Contributors

stepantita avatar stepantytaconsultant avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.