Blueprints #3 - Building an AI


Hello everyone! Welcome back to Blueprints, where I explain some of the design decisions of Aerostrike. In this issue, I will give some insight into how the AI of Aerostrike was made.

When I first started developing games, one of the first issues I stumbled upon was how to make an AI. I understood the concept of an AI, I just was not sure how to write it into code. It was a problem that stumped be while creating my first full game, Attrition. However, one day I realized something important, that I had already created half of the code I needed without even realizing it. It was the code I used for the player. It did all the functions that I needed the AI to do. All that was left to do was automate it.

This little bit of information was something that would prove very useful in the development of Aerostrike. If I needed the enemy to fire its weapon, I could simply reuse the code from the player's weapon, replacing the "button pressed" input check with a set of conditions, like "AI is trying to attack the player" and "AI can see the player". If I needed the AI to move, I could replace the directional buttons with an angle of movement and a set speed. Anything the player could do, an AI could do as well. It was the same base code, with slight modifications.

Now we have a way to make the AI do things, but how do we actually make the AI as a whole? For starters, it is much easier to approach the issue from a different perspective. Instead of trying to "build the AI" in one go, make the AI "do things" one by one. First, make the AI move; not in any particular direction, just move somewhere. Then we make it move in a specific direction, let's say left. Next, we make it move in the direction of the player, following them around. Next, we make it stop at a certain distance from the player. Finally, we give the AI the ability to fire a weapon from the reused player's code; without any conditions, just let it fire all the time for now. The end result is an AI that will chase the player around while attacking them. An AI has been successfully built!

Applying this methodology we can create the various systems that make the whole of the AI, one by one. However, having all enemies behave the same way is not quite as entertaining. How do we change that? Join me next issue to find out. Stay safe, Pilots!

PS: If anyone has any tips on making AI, or wants to point out anything wrong, leave a comment so others can see.

Get MF-01 Aerostrike

Buy Now$5.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.