Antonio Bobadilla

Web designer & developer | Neural Networks Researcher

Modeling of multi-agent system with computer graphics

Category: Software Development

Date: December 2021

Multi-agent system which consists of n number of robots that collect and stack boxes. Developed in Python with Mesa framework and 3D modeling with Unity.

Role: Responsible for all the development including backend and frontend.


C#

Python

Mesa

Unity

API

Flask

Phase 1. Multi-agent development in Python

First, this system was developed with a number of established boxes, as well as the number of stacks and the places where the boxes will be stacked and the number of robots in the system.

The mesa framework in Python was used to design the different agents that were used in the system.

The robots move randomly 1 pixel maximum until they find a box, which in the video below is gray.

Each robot at the beginning of the program is assigned a position in x,y of some stack which is not full and Astar's algorithm was used to find the closest one and go to it when it has a box in its inventory. This stacks can only store 5 boxes maximum, when they are full they change color to red. This algorithm repeats until there are no boxes in the maze and the robots don't have any more in their inventory.

The following video shows the system in 2D with a total of 5 robots, 100 cells, 60 boxes and 12 stacks.

Once we had the 2D system working, an API was made in flask to transmit the data of the robots, boxes and others to carry out the 3D modeling. A snippet of the code is shown below.

Database on Centos

Phase 2. 3D modeling in Unity

When carrying out the 3D modeling of the area, it was decided to make a kind of closed garage with textures like those seen in the image. Assets were also taken from the Unity store to simulate robots, boxes and stacks.

The result was the following.

Phase 3. API connection with Unity

At the end of the 3D modeling, a connection was made with the API which brings all kinds of data of the resources used, the positions of the boxes, the robots, the stacks and others. In each step of the program, the coordinates of the robots are also sent and if they picked up any boxes or are full.

With this connection from the API it could be said that the movement from Unity is in real time with program execution.

Below is a piece of C# code and a final video of the project.

Learnings

In this project I was able to learn about many new technologies, such as the Mesa framework for multi-agent modeling, as well as 3D modeling in Unity, which can help me start other projects that involve the modeling of a situation with multi-agents and make use of 3D modeling as in this project. Using multi-agents to solve current problems can be a great and valuable option for many areas and I am excited to learn more about these topics.