Giter VIP home page Giter VIP logo

ai-car-simulation-project's Introduction

AI Car 2D Simulation

This project is a Proof of Concept for a 2D car simulation with AI. The goal is to create a simulation where the AI learns to drive a car on a track. The circuits and game mechanisms have been created by NeuralNine :

Introduction

The project is divided in two parts: the simulation and the AI. The simulation is a 2D game where the player can drive a car on a track. The AI is a neural network that learns to drive the car on the track.

Getting started

Prerequisites

  • Python >3.10

We highly recommand you to use a virtual environment to run the project. For this project we used the virtual env feature of PyCharm.

Installation

  • Clone the repository
  • Install the dependencies with pip install -r requirements.txt

Usage

Simulation

To run the simulation, run the Main.py file.

Parameters

You can change the parameters of the simulation in the main function of the Main.py file.

  • NB_CARS: Number of cars in the simulation
    This constant must be equal or lower than your number of CPU cores. If you have 4 cores, you can set this constant to 4.

  • ID_MAP: Id of the map to load
    This constant must be between 1 and 5. There are 5 maps in the game. Feel free to create your own maps and add them to the assets folder.

  • ALGO: The algorithm to use for the training.
    The available algorithms are A2C and PPO.

if __name__ == '__main__':

    NB_CARS = 8
    ID_MAP = 4
    ALGO = "A2C"

    # Start Race Server
    race = threading.Thread(target=thread_race, args=(NB_CARS, ID_MAP))
    race.start()

    if NB_CARS == 1:
        # Start Training with Mono Client
        train_monoproccess(ALGO, ID_MAP)
    else:
        # Start Training with AI Clients
        train_multiproccess(ALGO, ID_MAP, NB_CARS)

AI

For more information about how it works and how to use it, please refer to the documentation of stable-baselines and the video of NeuralNine

Car

The car is a 2D sprite that can move on the map. It has a speed and a direction. The car can move forward and backward. It can also turn left and right.

Car

Maps

Here are the maps available in the game:

Map 1

Map 1

Map 2

Map 2

Map 3

Map 3

Map 4

Map 4

Map 5

Map 5

We do not use this map in our tests because it is too difficult for the AI and does seems relevant for our tests.

MultiProcessing

The simulation is a server that runs on a thread. The AI is another server which create workers. each worker is a client that connects to the server. The server sends the state of the game to the client. The client sends the action to the server. The server applies the action to the game and sends the new state to the client. The client receives the new state and sends the new action to the server. And so on...

Here is a diagram of the process:

MultiProcessing

About us

This project has been created by a group of students from the ESEO Engineering School in Angers, France. We are 3 students in the 5th year of the school, in the Software Engineering and Artificial Intelligence specialization.

ai-car-simulation-project's People

Contributors

clement-cardot avatar clementguais avatar neuralnine avatar guilbaudmaxime avatar

Stargazers

Arghadip Das avatar  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.