An evolutionary multi-agent platform based on mesa and NEAT

Related tags

MiscellaneousEvoAgent
Overview

EvoAgent

An evolutionary multi-agent platform based on mesa and NEAT
A video of an old version of EvoAgent can be found on youtube:
https://www.youtube.com/watch?v=pOF1H84xPik&ab_channel=VBiscione

Overview

With this tool you can evolve agents in a simple 2D environments.
At the beginning, agents are endowed with a simple neural network which is specified by their genome. With time, they'll make children, which will inherit the genome, plus some random mutations. The mutations will add a connetion, a node, or change the weight. The evolutionary system is based on NEAT by Kenneth Stanley (paper here). However, the main difference between this approach and the classic evolutionary algorithm approach, is the naturalistic approach we are using here. In a classic evolutionary algorithm we would use a fitness function, we would test our agents, and we would use a genetic operator for generating the next generation. We have none of that here. Agents will spawn a new children every x time-steps. The more they survive, the more children they'll get. I found this approach much more intuitively valid as will simply respond to the rule: the more you survive, the more you'll spread your genes. This will also allow for generational interactions (as multiple generations will live at the same time), in case one wants to run experiments on family behaviour etc.

Install

git clone [email protected]:ValerioB88/EvoAgent.git

EvoAgent plots everything in the browser. This is heavily dependent on the Mesa library. My fork of Project Mesa should be automatically added as a submodule.

Examples

There are several examples in the folder code/evoagent/experiments/, which should get you started. Most of this is self explanatory. For example, run the file difficult_env.py and a browser with the environment view should open. Both the model state and the population gets saved (the model state includes the population). You want to use the model state to continue a running simulation with exactly the same parameters, from exactly the same point (the model state includes the population state). Instead, you may want to test an evolved population on a different enviornment: in that case, load the population. Examples of both these cases in continue_sim.py and load_pop.py. Model and population get saved every 1000 time steps, or when you press s.

Environment View

This contains a canvas, information about the selected agent, and some plots. At each points there always be a selected agents, for which many info are shown in the text field on the right sidebar. You can change the selected agent by pressing a and d on your keyboard (in a future version, it will be possible to click on the agent on the canvas to select it). Other info are shown in the following image:

Shortcuts

q start/stop simulation
a/d previous/next agent
k kill selected agent
c selected agent spawn a child
s save model
x advance the simulation one step

Agents Behaviour

Agents will have a limited field of view, specified by the parameters fov and max_vision_dist. You can visualize them by checking Render FOV in the environment view. Each agent will have a maximum lifespan of max_age = 500, but it can die faster if its energy goes to 0. They have a energy_depletion rate of 0.008. An agent will eat a food token when it touches it, getting an energy increase of 0.8 (or whathever established by the current Epoch, see later), up to 1. Agent will become fertile after fertile_age_start = 90 timesteps. At that point, they will spawn a child every time_between_children = 100 timesteps. For now, reproduction is asexual, so there is no crossover (this will be expanded in a next version).

Agents can only perceive the closest food token, IF it's within their field of view. If the selected agent is perceiving a food token, this will be represented with a red color in the environment view. Agents' network input will be the linear distance to the perceived food token, the angular distance, and their own energy level. There will be two output units, one defining the forward/backward movement, the other one defining the rotation.

Epochs

The epochs are interval of times defined by the amount of food in the environment.

epochs = deque([Epoch(2000, [0.8]*200),
                Epoch(2000, [0.8]*100),
                Epoch(6000, [0.8]*75)])

This means that we have 3 epochs, the first lasting 2000 iteration, the last 6000 iterations. The first will have 200 food tokens, each provigin 0.8 units of energy (recall that [0.8]*200 generates a list of 200 elements of value 0.8: [0.8, 0.8, 0.8....]. By changing the second parametr, you can specify the distribution of food token easily. You can also have "posionous" food: Epoch(2000, [-0.2]*200) this will work. However, currently the agents don't have a way to differentiate between "good" and "bad" food, so it doesn't make much sense to use bad food right now.

The simulation will activate one epoch at the time, starting from the first one. When the last epoch finishes, the simulation stop. You can instead run the simulation indefinitively by setting the epoch duration to np.inf.

Speed Up Simulation

In the environment view, uncheck Render Canvas, then set the Frame per Second slider to 0. That's as fast as it can get!

Known Problems

If you stop the simulation and try to run it again, you'll get the error:
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
To fix this, try to change the port in server.launch(...). If it doesn't work, close and open your browser. I know this is annoying, but hadn't have the time to fix it yet.

This has only been tested on Windows 10 and Edge 97. I don't plan to test it on any other configuration. Sorry!

To Do

☐ Add sexual reproduction: find a partner, do crossover
☐ Many agents options should be in a config file
☐ Select an agent by clicking on it with the mouse
☐ Implement data collection - or adapt mesa data collection
☐ Implement more ways to perceive food
☐ Implement ways to perceive other agents
☐ Server port stays open after code stops - which often lead to annoying behaviour. Find a way to fix this

Owner
Valerio1988
Valerio1988
Tool to automate the enumeration of a website (CTF)

had4ctf Tool to automate the enumeration of a website (CTF) DISCLAIMER: THE TOOL HAS BEEN DEVELOPED SOLELY FOR EDUCATIONAL PURPOSE ,I WILL NOT BE LIAB

Had 2 Oct 24, 2021
HiQ - A Modern Observability System

🦉 A Modern Observability System HiQ is a declarative, non-intrusive, dynamic and transparent tracking system for both monolithic application and dist

Oracle Sample Code 40 Aug 21, 2022
Hy - A dialect of Lisp that's embedded in Python

Hy Lisp and Python should love each other. Let's make it happen. Hy is a Lisp dialect that's embedded in Python. Since Hy transforms its Lisp code int

Hy Society 4.4k Jan 02, 2023
An example of Connecting a MySQL Database with Python Code

An example of Connecting a MySQL Database with Python Code And How to install Table of contents General info Technologies Setup General info In this p

Mohammad Hosseinzadeh 1 Nov 23, 2021
Blender 3.1 Alpha (and later) PLY importer that correctly loads point clouds (and all PLY models as point clouds)

import-ply-as-verts Blender 3.1 Alpha (and later) PLY importer that correctly loads point clouds (and all PLY models as point clouds) Latest News Mand

Michael Prostka 82 Dec 20, 2022
A code to clean and extract a bib file based on keywords.

These are two scripts I use to generate clean bib files. clean_bibfile.py: Removes superfluous fields (which are not included in fields_to_keep.json)

Antoine Allard 4 May 16, 2022
Capture screen and download off Roku based devices

rokuview Capture screen and download off Roku based devices Tested on Hisense TV with Roku OS built-in No guarantee this will work with all Roku model

3 May 27, 2021
A Lego Mindstorm robot for dealing out cards based on a birds-eye view of a poker table and given ArUco fiducial tags.

A Lego Mindstorm robot for dealing out cards based on a birds-eye view of a poker table and given ArUco fiducial tags.

4 Dec 06, 2021
LOC-FLOW is an “hands-free” earthquake location workflow to process continuous seismic records

LOC-FLOW is an “hands-free” earthquake location workflow to process continuous seismic records: from raw waveforms to well located earthquakes with magnitude calculations. The package assembles sever

Miao Zhang 71 Jan 09, 2023
A python package template that can be adapted for RAP projects

Warning - this repository is a snapshot of a repository internal to NHS Digital. This means that links to videos and some URLs may not work. Repositor

NHS Digital 3 Nov 08, 2022
Telop - Encode and decode messages using an interpretation of the telegraphic code devised by José María Mathé

telop Telop (TELégrafoÓPtico) - Utilidad para codificar y descodificar mensajes de texto empleando una interpretación del código telegráfico ideado po

Ricardo F. 4 Nov 01, 2022
Listen Surah, prepare for next and Endless life...

Al-Quran In this repository, I have linked up all Surah with Arabic-Bangla Audio From Youtube. So, you just need to choose and listen. and the ( surah

SpiderX 1 Sep 30, 2022
Ferramenta de monitoramento do risco de colapso no sistema de saúde em municípios brasileiros com a Covid-19.

FarolCovid 🚦 Ferramenta de monitoramento do risco de colapso no sistema de saúde em municípios brasileiros com a Covid-19. Monitoring tool & simulati

Impulso 49 Jul 10, 2022
One Ansible Module for using LINE notify API to send notification. It can be required in the collection list.

Ansible Collection - hazel_shen.line_notify Documentation for the collection. ansible-galaxy collection install hazel_shen.line_notify --ignore-certs

Hazel Shen 4 Jul 19, 2021
freeCodeCamp Scientific Computing with Python Project for Certification.

Time_Calculator_freeCodeCamp freeCodeCamp Scientific Computing with Python Project for Certification. Write a function named add_time that takes in tw

Rajdeep Mondal 1 Dec 23, 2021
Esercizi di Python svolti per il biennio di Tecnologie Informatiche.

Esercizi di Python Un piccolo aiuto per Sofia che nel 2° quadrimestre inizierà Python :) Questo repository (termine tecnico di Git) puoi trovare tutti

Leonardo Essam Dei Rossi 2 Nov 07, 2022
Project Guide for ASAM OpenX standards

ASAM Project Guide Important This guide is a work in progress and subject to change! Hosted version available at: ASAM Project Guide (Link) Includes:

ASAM e.V. 2 Mar 17, 2022
Procedural 3D data generation pipeline for architecture

Synthetic Dataset Generator Authors: Stanislava Fedorova Alberto Tono Meher Shashwat Nigam Jiayao Zhang Amirhossein Ahmadnia Cecilia bolognesi Dominik

Computational Design Institute 49 Nov 25, 2022
PyCASCLib: CASC interface for Warcraft III

PyCASCLib CASC interface for Warcraft III. This repo provides bindings for JCASC: https://github.com/DrSuperGood/JCASC Installation Jdk is required fo

2 Jun 04, 2022
A simply dashboard to view commodities position data based on CFTC reports

commodities-dashboard A simply dashboard to view commodities position data based on CFTC reports This is a python project using Dash and plotly to con

71 Dec 19, 2022