Hive Mind Progress Update #10

Over the past two weeks, i have tackled one of the most challenging aspects of the Hive Mind project: ant navigation through the nest. It was a journey full of problem-solving, adjustments, and learning, but i made some significant progress.

The Challenge: Navigating the Nest

The biggest hurdle was creating a system that allows ants to navigate through the complex structure of the nest, including surface areas, tunnels, and chambers. Due to the small size of the tunnels and chambers, Unreal Engine’s NavMesh system wasn’t suitable. This led us to rethink the entire approach and design a more custom solution.

The Solution: Graph-Based Navigation

Warning: this gets nerdy. When looking for solutions i got inspired by graph theory. Which to me it makes sense to represent the nest as a graph where:

  • Nodes represent chambers (including the surface as one large node).
  • Edges represent tunnels connecting the chambers.

To implement this in code, i have created two key structures:

  • ChamberNode: Represents each chamber with its ID, location, and colony association.
  • TunnelNode: Represents tunnels with their connecting chambers, entrance and exit trigger locations, and additional metadata.

This setup allows me to use Breadth-First Search (BFS) to find the shortest path through the nest from one chamber to another, ensuring ants can efficiently navigate their environment.

Reducible made on YouTube an excellent video on this subject:
https://www.youtube.com/watch?v=PMMc4VsIacU

Teleportation Through Tunnels

Since NavMesh couldn’t be used inside the nest, i have implemented a teleportation system. Ants walk to tunnel entrance triggers, get teleported through the tunnel to the exit trigger, and continue their journey to the next point or their final destination. For now it is instant, in the future i will add a timer that counts for the distance of the tunnel. Also in future we will add more properties to a tunnel like dangerlevel, length, congestion etc.

Code Refactor and Improvements

I have moved all route-finding logic to the TunnelManager for better organization and efficiency. The TunnelManager now:

  • Calculates routes using BFS.
  • Stores all chambers and tunnels in memory.
  • Handles teleportation logic through tunnels.

Additionally, each ant now knows which chamber it is currently in, including when it is outside the nest (treated as a large chamber), making route calculation more seamless.

What’s Next?

Next, I plan to:

  • Refine our SpawnManager to spawn ants in specific chambers.
  • Complete the FollowRoute task to include walking to tunnel entrances, teleporting, and navigating through the nest.

As the mesh includes the surface, nest chambers and tunnels i expect some problems when ants want to navigate in ant chambers. I believe in those chambers there is no collision detection available and the ant will fall through the mesh once teleported. If so, we will also find a way to deal with that later 🙂

This sprint taught me lot about graph theory, navigation challenges, and efficient code design. I also faced several obstacles, such as collision issues, NavMesh limitations, and code refactoring needs, but each challenge helped me improve the complete system.

I also plan to make an extra blog post purely on AI, reinforcement learning and how i aim to implement it into this project. I already have decided to use PyTorch as a default instead of Tensorflow. But don’t worry this project will be framework agnostic. You can even write your own neural networks and connect to the simulation environment and test it.

Stay tuned for more updates, and check out the recommended YouTube videos on graph theory and BFS to see the inspiration behind our navigation system!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.