Asynchronous Ant Colony AI


Project Features                                                                          C++ Custom DLL / 3 Weeks Development Time

  • Asynchronous Ant Colony AI built into a DLL that sends and receives data from a main application

  • Ant colony collects food and attacks other colony ants with the goal of being the last standing

  • Utilized A* pathfinding to traverse the map

  • Implemented AI for worker ants, scout ants, soldier ants, and the queen ant

  • Utilized critical sections to create thread-safe data access

  • Competed against other classmates and professors

  • In the video to the right, I am competing against myself and a benchmark AI


Relevant Notes and Rules

  • Green tiles are food tiles, brown tiles are dirt, and grey are stone. Ants can never move through stone but can dig through dirt

  • There are four types of ants

    • Queen Ant - This ant produces other ants and receives food from workers. It must rest every other frame
    • Scout Ant - This ant cannot collect food but has better vision and no upkeep cost. It pays no price for digging through dirt
    • Worker Ant - This ant collects food and brings it back to the Queen
    • Solider Ant - This ant attacks other ants and wins a battle with any of the ants above. If a solider fights a solider, both perish
  • Every ant colony AI faces time restrictions with response of orders each frame. If an ant colony surpasses this time restriction (for us it was 20ms), a random ant is removed from the violating colony.

  • Every ant type but the scout has an upkeep cost incurred each frame

  • The last any colony remaining wins

  • For most maps, food stops respawning after a specified time limit


Project Post Mortem

What went Well

  • Implementing thread safety mechanisms and a double buffer went surprisingly well. I almost never had issues with violating the 20 ms restriction.
  • My strategy to park soldiers on food squares and secure food areas surprised many people and helped me to win some competition rounds
  • The project and competition was overall fun and boosted my interested in game AI.

What Went Wrong

  • My A* pathfinding worked well but was not as performant as other classmate's implementations. This meant I could make less path requests per frame and ultimately meant slower food collection. In the future, I will need to allocate more time to optimizing pathfinding.
  • I ran out of time to explore additional AI techniques, such as heat maps. 

What Was Learned

  • AI does not often have the largest allocated time block in games and great care should be given to the efficiency of core algorithms. If my A* was more perfomant, I would have been able to make more path requests per frame.
  • AI competitions are a great chance to explore various AI techniques