GithubHelp home page GithubHelp logo

andre8244 / brave Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 438 KB

BRAVE is a genetic algorithm engine and a simulator for Braitenberg vehicles written in Python

License: GNU General Public License v3.0

Python 100.00%
genetic-algorithm braitenberg-vehicle evolutionary-algorithm artificial-intelligence obstacle-avoidance phototaxis sensor

brave's Introduction

BRAVE

BRAVE (BRAitenberg Vehicles Evolution) is a genetic algorithm engine and a simulator for Braitenberg vehicles written in Python.

A demo of the genetic algorithm execution is avalable on YouTube.

BRAVE screenshot

Requirements

The vehicles

A Braitenberg vehicle is an agent that can autonomously move around based on its sensor inputs. Depending on how sensors and wheels are connected, the vehicle exhibits different behaviors.

BRAVE agents have two wheels, each driven directly by a simple sensor placed on a side of its body; they can exhibit two behaviors: phototaxis and obstacle avoidance.

The vehicles are placed in a virtual environment called scene, along with the objects they interact with, i.e. light sources or obstacles.

The behavior of an agent is influenced by various parameters, such as the size of its wheels, the direction of its sensors, and so on. These parameters can be set programmatically for both obstacle avoidance and phototaxis. High-quality obstacle avoidance parameter values can be generated using a genetic algorithm.

Phototaxis

A phototaxis simulator is provided in phototaxis.py. The Python script accepts the following command line arguments:

  • -h, --help show a help message
  • -s FILE, --scene FILE path to a scene file; a custom scene for the phototaxis simulator can be specified
  • -f NUM, --fps NUM frame rate of the simulation

Obstacle avoidance simulator

An obstacle avoidance simulator is provided in obstacle_avoidance.py. The Python script accepts the following command line arguments:

  • -h, --help show a help message
  • -g FILE, --genomes FILE load obstacle avoidance vehicles from file. Every line in the file represents a genome, that is the set of obstacle avoidance parameters used by a vehicle. By default, only the first 10 genomes of the file are loaded
  • -a, --load_all_genomes load all the genomes contained in a genome file, instead of the first 10. Applicable with --genomes parameter only
  • -s FILE, --scene FILE path of the scene file; a custom scene for the obstacle avoidance simulator can be specified
  • -f NUM, --fps NUM frame rate of the simulation

Genetic algorithm for obstacle avoidance

High-quality obstacle avoidance can be generated executing a genetic algorithm. The parameters that involve obstacle avoidance behavior are:

  • vehicle wheel radius: affects vehicle speed
  • motor controller coefficient: affects how much a detected obstacle makes the vehicle steer
  • motor controller minimum actuator value: affects the speed of the vehicle when no obstacles are detected
  • sensor delta direction: relative angle (in radians) between sensor and vehicle bearing
  • sensor saturation value
  • sensor maximum distance

The set of these parameters compose a genome, the genetic representation of a candidate solution. During the execution of the genetic algorithm, a population of genomes is evolved toward better solutions, applying crossover and mutation. The fitness of every genome is evaluated considering the distance traveled by the related vehicle before colliding with an obstacle.

The genetic algorithm for obstacle avoidance is provided in evolution_obstacle_avoidance.py. The Python script accepts the following command line arguments:

  • -h, --help show a help message
  • -v {0,1,2}, --verbose {0,1,2} set script verbosity
  • -p NUM, --population NUM number of vehicles in each generation
  • -e NUM, --elite NUM number of vehicles carried over unaltered to a new generation (elitism)
  • -m NUM, --mutation_prob NUM probability that a mutation occurs on a single gene
  • -M NUMv, --mutation_coeff NUM coefficient used to alter a gene value during mutation
  • -S NUM, --selection_ratio NUM ratio of parents selected to breed a new generation
  • -r, --random_direction set an initial random direction for the vehicles. If enabled, the fitness value of elite genomes will change in subsequent generations
  • -E NUM, --sensor_error NUM coefficient used to simulate the obstacle sensor read error. If non-zero, the fitness value of elite genomes will change in subsequent generations
  • -l, --long_lasting_generations enable long lasting generations. By default, generations have a time limit: if reached, all remaining robots are destroyed and a new generation is created. If this parameter is enabled, generations don't have a time limit
  • -c, --multicore enable multicore support (experimental)
  • -s FILE, --scene FILE path of the scene file; a custom scene for the genetic algorithm can be specified
  • -f NUM, --fps NUM frame rate of the genetic algorithm execution

A demo of the genetic algorithm execution is avalable on YouTube.

License

GNU GPLv3

brave's People

Contributors

andre8244 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

revenger2

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.