Enemy Sights and the Doughnut Radius.

Hello everyone!

When people ask me how my Final Year Project is going, I used to reply with “Oh it’s going…” But now that is all in the past! I have progressed with a main menu and the ability to win and return to the main menu. It’s a small feat, but a feat nonetheless.

However, the reason I’m posting this today is not for the feat of making UI. Today I will be talking about my very basic enemies and how I intend them to proceed with what they should do in a given situation.

My overall idea is to have 3 different AI’s that attack differently, have different attacks, and different radii for both attacks and movement. Right now, I have 1 AI with the ability to move towards the target using the A* algorithm. I now want to include attacks for the enemies and to do this I need to add some logic and it might get complicated so bear with me.

Image 1.

Image 1, as you can see above, was beautifully and expertly made with paint to add some context. Green circle is player; red circle is enemy; blue line is a raycast to detect whether or not the player is in the enemies sight; black blocks are obstacles that are not walkable.

The enemy will always know the distance from the enemy to the player and will always know its position. The enemy will always fire the raycast from the enemy in the direction towards the player if the player is within the outer radius of the enemy. That’s right, the enemy has more than one radius! Let me show you further with more artistic skills.


Image 2 (above) shows the radii of the enemy and where the enemy can see. Considering my game is grid-based, my radius is a combination between a square and a circle. However, I have shown it here as a square for my own ease.

The “O” means “outside field of view, but still within range”. The “I” means “inside field of view and within range”. The orange box is the enemy’s close range radius meaning if the player is within this radius, the enemy will favour the “Close Range” attack over anything else. The white is simply anywhere walkable, if the player was in this white space, the enemy would prefer to walk close towards the enemy. In my opinion, the purple is not a true radius as it has a max range as well as a minimum range that is not zero or close to zero. It is for this reason I am calling the purple radius, “Doughnut Radius”. Since the player is within this “Doughnut Radius”, the enemy will favour the “Ranged Attack” over any other method.

There is another situation that I am currently contemplating which considers just passing their turn instead of making an action. This would happen if the player’s position is close to the “Doughnut Radius”.

Like I said, this is just for the basic AI at the moment meaning that more advanced techniques for combat and decisions will come later in the project.

So if anyone has any questions then please feel free to drop a comment or email me and I’ll get back to you as soon as possible!

Image accessible at https://www.technobuffalo.com/wp-content/uploads/2012/08/xcom_enemy_unknown.jpg. Last accessed: 26/02/2017.

James 😀


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s