Problem Solving Challenges :: Search in Complex Environments :: Fundamentals of AI
Population learning (firsts GENs) | Cars driving by itselfs (GEN 173) |
---|---|
![]() |
![]() |
Motivation: Academic project for Fundamentals of Artificial Intelligence, M2AI. Use a evolutionary algorithm to learn how to drive a car in a complex environment with the following polynomial function as a controller for the car (w_1a + w_2b + w_3c + w_4ab + w_5ac + w_6bc + w_7a2 + w_8*b2 + w_9*c**2). w_x being the weights the respective agent chromosome genes and 'a,b and c' the distance sensors values.
Implementation: Interface was build using Pygame(2D game package for python). The genetic algorithm process consists in Selection, Cross Over, Mutation and bonus step (Random Agents) to avoid population convergence. Later on, was implemented to the game a car with a different behavior from the others (controlled by a PID controller) in order to swipe out the cars with unwanted behaviors (like spinning cars). There's also a car that can be controlled by the user.
Tested with with four different tracks [Easy, Medium, Medium-Hard and Hard]
Built With Pygame (Python framework for games)
PIDCar cleaning slow cars | PIDCar vs Self-driving Agent |
---|---|
![]() |
![]() |
install Requirements with:
$ pip install -r requirements.txt
usage: main.py [-h] [-t TRACK] [--user-test] [--agent-test] [--show-cleaner]
[--show-simulation] [-p POPULATION] [-fps FPS] [-gif]
optional arguments:
-h, --help show this help message and exit
-t TRACK, --track TRACK
racing track to be used on the simulation. {Default:
None(Random track)}
--user-test spawn car that can be controlled by user. {Default:
False}
--agent-test test the simulation with only the best car. {Default:
False}
--show-cleaner show the car used to draw the Cleaning line. {Default:
False}
--show-simulation show the population evolving in a simulation.
{Default: True}
-p POPULATION, --population POPULATION
how many cars for each generation. {Default: 100}
-fps FPS frames per second. {Default: 30}
-gif, --export-gif export gif with agent driving in four tracks + bonus.
{Default: False}
Distributed under the MIT License. See LICENSE
for more information.
Fábio Oliveira - LinkedIn - [email protected]
Project Link: https://github.com/fabioo29/ai-self-driving-car
Project built as a Msc. Applied Artificial Intelligence Student.