For the last part of the Flocking Task we were asked to create some data metrics to enable the user to tweak the simulation and see the results. I decided to go with a heat map since I’m interested in learning how to visualize positional data in that way. After hours of crashes due to some silly mistakes (I was trying to put -300 to 300 position data in a 0 to 600 array without converting) I managed to get the array to store an incremental value each time an agent was on that position. I then took that data and incremented a low alpha colour over each pixel.
The result when run with the base simulation configuration:
Next I want to extend this into a proper heat map by having the data on each point radiate out slightly, and then change the colour of the pixel based on the value. To start with I found some example code for extending the colour:
This gave an interesting result compared to the original:
To finish the heat map I wanted to try adding different colours based on weighting. I tried the formulas from this site. Unfortunately they don’t have the desired effect with my heat maps:
Since I was rushing to get it working after dealing with errors all morning I decided to hard code the size of the heat map image. Currently there is no limit on how far an agent can travel which means that they can eventually move beyond the range of the map. As it is currently coded however the position data will clamp to the map range.
I still needed to add some kind of feature to the simulation as part of the first task. I decided that a wrapping feature could be handy as a way to contain the agents without having them bump into a surrounding wall.
The result with wrapping at 200 by 200: