Simple AI

Hello dear readers,

What is a PvE¹ game if there is no AI²? Even if the AI is fairly simple it will still be better than no AI at all, if nothing else there will be a few laughs about the behaviour of the NPC³.

So in our game we have three distinct enemies:

  • The Water enemy which is aiming directly at you, or slightly forward from your direction
  • The Fire enemy, which is aiming slightly above you and slightly below you.
  • The Wood enemy, which is charging right at you, trying to smash your character right out of the screen.

A more In-Depth description of the behaviours would be:

The Water enemy is going to move to either the top or the bottom of the screen, whichever that is the closest. After that it will begin to fire a projectile each N seconds.

Where the AI will move (if it has not reached said positions already) towards where the enemy is located right now and the dot in the bottom. While simultaneously firing at the players hitbox center with a certain time interval.

waterAI

The Fire enemy is going to walk to the players top Y or bottom Y position, whichever that is closest, and then fire each N seconds.

In this picture you will see that the fire enemy will move towards the pink lines, and then start firing with a certain time interval.

FIREAI

The Wood enemy is going to walk to a point right of the player, until it gets within the players hitbox’s Y position. When it does it will charge at the players X coordinates and it will attack when it is able to reach the player with a punch.

The light green at the bottom of the wood enemy is the first coordinate that the wood enemy is charging at. This is to simulate a form of “Interception”, where the enemy is trying to run infront of you and then smash right at you.

When the enemy then gets within the light green box around the player, it is going to punch the player. (Effectively moving its hitbox in the direction it is punching).

WOODAI

 

This is as far as we have gotten with the AI in our game, somewhat simple but it does create some challenging moments when we have all three different enemies present at the same wave.

Have a good day to you all and good luck with your future endeavours!

1.

PvE stands for Player versus Environment. Which basicly is you, as the player, against the computer, as the environment.

2.

AI, Artifical Intelligence, is a behaviour generated by a computer or equivalent from different algorithms.

3.

NPC is an abbrevation for Non Player Character. Which is, just as the name suggest, a character in a game that is not directly controlled by the player input.

One thought on “Simple AI

  1. First off, I think it’s great that your game have multiple enemies, each with its own attack pattern. I think that you’ve made a good decision of not having such advanced patterns, as I believe that these three simple ones will compliment each other quite well. I’m looking forward to testing the finished product on Friday and seeing them operate inside the game.

    Now to some feedback. I’d prefer if your post explained a bit, how each enemy actually worked, either through pseudo-code or a more detailed explanation. Since I saw the titles’ “AI” part, I thought that it would contain either algorithms, behavioral graphs or some other explanatory method.

    Either way, you’re writing in a straightforward fashion and its really easy to understand and even if you were someone not that familiar with gaming terms, you’d not have any difficulty at all. Also, if that were the case I think that the last “explanation” part of all the words would help a tremendous amount.

    As I said, I’m looking forward to trying out the game on Friday. Keep neutralizing all the remaining bugs, adding all the “juice” and I’m sure that the game will be a joy to play!

    ~Lead Programmer, Per “Gimmic” Johansson

Leave a comment