
In this latest video on YouTube I start to introduce the concept of eyesight to the simulation. The initial concept is very rudimentary in that the entities can see everything around them within 200px. The range of the eyesight is sometimes shown in the video as a yellow dotted circle depending on where it makes sense (as shown in the picture above). If an entity sees another smaller entity in it’s eyesight it will go into hunting and seeking mode at which point the eyesight will turn from a yellow dotted line to a green dotted line.
This is Part 1 because the eyesight is not fully implemented, there’s still some missing features (and one bug). The bug is that an entity’s eyesight doesn’t wrap around the map like it’s movement can. Meaning if an entity is on the other side of the map, even if it’s within the eyesight of another entity, it will not be seen. The math and logic to do this still has to be implemented.
In terms of features, and although this isn’t a missing feature of the eyesight, one feature that really needs to be implemented is some kind avoidance rules. Specifically if an entity sees another smaller entity it will hunt and seek it right away, regardless of it’s surrounding environment. This can be very problematic if say the smaller entity is surrounded by an army of larger entities all around it. In other words the entities have tunnel vision and completely ignore any dangers seeking out a smaller entity. There’s a whole section on this in the video with examples. The best example however is the near the end where a single small entity that has somehow managed to survive by itself for a long time suddenly sees a smaller entity in a cluster of larger entities and decides to go after it to its own detriment, where it’s pretty much immediately consumed.
One challenge of implementing eyesight, well more seeking, is how fast should an entity move towards its target? In the video I show a few options I tried until I found the one I liked the best. Not to give too many spoilers but using the maximum movement was problematic and resulted in the entities often looking like they were teleporting. Going with too slow a movement caused the entities to look like they were almost strolling to their targets, even looking as if they were two different types of behaviors. The movement I decided on was to use a random movement between their min and max divided by two. This seemed to be the most organic and natural looking option.

With all that in mind adding eyesight and seeking has significantly changed the simulation. One of the more interesting behaviors is that we now see much tighter clusters as shown above (as well as empty space between the clusters). This is the result of entities all congregating to the same location as larger entities see smaller ones until eventually a dominant colors wins out, after which the cluster starts to expand. And in between the clusters there is a lot of empty space because the entities are now seeking out any other smaller entities in their eyesight. The video highlights some good examples of this.
This effect is especially prominent at the start of random simulations as the entities quickly cluster into groups which have a distance almost equal to the eyesight between them which is kind of visible in the picture at the top of this post It’s much more visible in the video. The video also shows very well how the simulation always progresses from these initial grid like clusters until it transitions to being a lot more organic and natural looking.
An interesting side effect of this is that the clusters are good indicators of where the last big battles took place. For example in the screenshot just above you can clearly see clusters of red and blue, these are where the last big battles occurred between the colors.
Another effect that I didn’t expect to see is what I call hopping for lack of better word. Well I suspect it’s because entities pick the smallest entity in their eyesight. I should’ve mentioned this in the video but specifically an entity will pick the smallest entity in it’s eyesight, regardless of distance. This is important because if two clusters are close enough and in the middle of a big battle entities can hop to another cluster to take advantage of a smaller entity. And if one is small enough then a number of larger entities can suddenly decide to all target that smallest entity. This makes it look like a bunch of entities suddenly hop from a large cluster battle to another, especially if they start to get into the eyesight range of another cluster.

One thing that is particularly interesting is how much quicker the simulation runs are taking. The average run time went from almost 2 hours to around 5 minutes. This is a huge difference. I suspect that when I add avoidance rules and behaviors that the simulations will take somewhere between the initial approximate 2 hour run time to the current 5 minutes run time. I’m very curious how much the average run time will change. Without avoidance rules every entity that can consume another pretty much attacks it right away. There’s no defensive rules at all, so of course things will be a lot faster than random movements. I’m just surprised at how significant the difference was. And again I’m very curious to see how adding avoidance and defensive behaviors and rules will affect the average simulation run times.
The next steps are most likely going to focus on resolving the eyesight issue in regards to wrapping around the map. But that’s not why I called this video Part 1 of eyesight, it’s because I want to adjust how eyesight works. At the moment I’m leaning more towards having the eyesight be directional, similar to how it works for humans in that we can’t see 360 around us at all times but more what is in front of us. I would also like to add blocking, by which I mean an entity can be block the view of another entity. Similar to how if someone is behind someone else you may not be able to see them. That will probably be later but it’s something I’d like to also look into at some point. So most likely there will be multiple parts to eyesight.
But getting back to the next video, after fixing the map wrapping issue for eyesight, I suspect I will look into adding some kind of avoidance and defensive behaviors. That too will probably be broken down into multiple parts, with the first part being pretty naive and maybe just moving away from larger entities. In other words there’s a chance I’ll stop therefore before adding more advanced logic to also avoid clusters of larger entities, but it will depend on if the resulting behavior is interesting or not. If it’s not I’ll keep going, and if it is then I’ll make a video. I’ll only know when I try.
On that note let’s see where the next step of simulation leads us. I of course strongly recommend watching the video if you haven’t already done so, the link is here. And of course I look forward to reading any and all feedback you have, both here in the comments as well as comments in YouTube under the video.