Pinned Project Overview Post

Project Overview

Introduction There have been numerous researches conducted for the development of algorithms that can be used for environment exploration an...

Sunday, October 1, 2023

[Post :10] NetLogo Simulation Progress Part - 3

I managed to implement all the functionalities I was thinking of in the beginning. However, there are some limitations in the simulation. I uploaded the project to GitHub so anybody can find the implementation-related information. [Github Link]

By default, the NetLogo floor is wrapped. That means when an agent goes against an edge instead of colliding with it, the agent emerges from the other side. From agents’ perspective, they have an infinitely large area to roam around. This feature is not going to be used in my implementations as the agents are supposed to work in environments with limits. This feature can be easily disabled in the program, but the edge cases are needed to be handled or otherwise agents will collide with edges and stick to it. Since obstacle avoidance was already done in the program, the same behavior is mirrored to deal with edges. The only difference is how agents detect obstacles and edges.

In order to detect obstacles, agents check for yellow color patches in the neighborhood. The edges are detected using the ‘patch-ahead’ primitive as they return the ‘nobody’ value when the agent can't detect any patch ahead of it when it is near an edge.



In the obstacle detection part, you can see the agent changes its color. As discussed in the previous post, this is due to the freedom it has at each moment.

The agents are supposed to follow an agent if that has more freedom than the freedom of self. In order to follow an agent, the current agent will turn towards the agent with the most freedom while maintaining a minimum distance between them. The code can be looked at in the GitHub repository to further understand the code.


Since the code can be looked at to understand the functionality in detail, I will focus on the GUI elements built to change the simulation conditions.

 

Custom Agents placement

When the agent count is set and initialized, they will spawn randomly all around the floor. If obstacles are already placed, it will check for the status of a patch before placing. If the decided patch is already occupied by an obstacle, it will select another random position. This behavior might not be suitable for some applications. To avoid this problem, 2 buttons were placed to place and delete agents using the mouse cursor.

Custom Obstacle Placement

Similar to agent placement, this feature can be used to draw obstacles on the floor. The only difference is that the cursor needs to be dragged on the floor while holding a click. The agent function will only place a single agent regardless of the mouse button holding.

Marking Explored Area

A toggle switch was placed on the GUI to enable or disable the coloring of the explored area. When an agent passes through a patch, the agent will change the color of the patch to blue. While this needs to be turned on to update the graph which shows the explored region, at the same time it slows down the simulation speed a bit.

Loading an existing obstacle layout

The coordinates of the NetLogo floor are different in default settings. 0,0 coordinate is in the middle of the floor. The default convention is crucial to know when loading an obstacle layout as a previously saved coordinates list will be completely different in another coordinate system. 

Drawing obstacles in specific shapes takes a long time and might not be practical to repeat the same in every run. So the save obstacle pattern can be used to save the layout. This will save the coordinates of the yellow patches into a '.txt' file which will be loaded back when clicked on 'load obstacle pattern'


I will publish the last post of this project with  a demo video, the report, and the GitHub link along with the comments I received from the panel

No comments:

Post a Comment