Introduction
Within this project, I made a tower defense like game using heat maps and influence maps to control the behaviors with each tower and cannon. To achieve this, I used Unreal Engine 4 and C++. Currently in the demo, enemy waves spawn at the start which they follow to the end and then they destroy themselves. When the enemy is following the path, they can be shot at by towers and cannons, which all do different types of damage.
Implementation
Influence Map
To actually create an influence map, I first needed to find which grid nodes were in position to have some sort of influence. To do this, I used a grid system, which can be created with custom dimensions and spacing between each cell. I then went through each cell and calculated its cost based on where it was relative to other towers so in essence, each cell is getting its calculated once instead of multiple times, which would happen if we went through each tower. The influence map is eventually used by the tower to deal damage after x amount of seconds based on if the enemy is within the influence area to do damage
Dynamic Influence Map
Though I wanted most of my towers to be static and non-moveable, I did want some to be able to move about the level and do damage dynamically. For this, I decided to make my very own map layer dedicated to it and this layer would be updated every frame, instead of just at start, which is what it is for the influence map. With my static influence map though, I found that it would be way too much computation to try on every frame so I decided to try a different route. I used an implementation similar to an flow field, where I go from neighbor to neighbor, trying to calculate the cost within the distance of the tower. The pro about this solution is that we only need to check a couple of grid nodes, not the entire grid, which is what happens in the static influence map
Heat Map
Finally, I decided to make a heat map to try and figure out where enemy concentration is at its max. To do this, I used the same system that I used for the dynamic influence map since it also needed to be updated every frame to keep track of enemy location. The only difference is that heat maps can also take in positive and negative values. I needed to do this to try and represent which areas are being protected by ally towers and which are occupied by enemies. To finally bring this concept together, I made a cannon which looks for the grid cell that has the greatest enemy presence and fires there.
Conclusion
In general, I found that the implementation of flow fields and influence maps to be alarming similar to each other. I think that with both of them, it is really difficult to push them to be dynamic since there is just so much calculations that need to be done for them to generate. In the future, I would like to explore influence maps and especially heat maps with turn-based strategy games because I think there are tons of applications you can make for that genre. I would also like to try and experiment with influence maps and obstacle avoidance because I think that especially for static obstacles in a level, it could prove to be very useful.