• interested in more? sign up to the newsletter


Keeping up the pace

Tweet about this on TwitterShare on RedditShare on Facebook

Space Grunts is a fairly fast turn-based game, as you might have noticed when playing it, or seen it in the video’s. Every time you do your turn, all monsters act pretty much within a second, finding their path towards you, and keeping the gameplay pace high.

How is this magic done so quickly? well it’s: PAC-MAN man!

I decided to use the fastest possible AI code that still gives a lot of variation for different monster types.  This is probably also the oldest code to do something like this, as it was used by Blinky, Inky, Pinky and Clyde, aka: the ghosts of Pac-man past.

In Pac-man you have these four different ghosts, and what these ghosts do is look at where the player is (grid-based) and decide to either target that exact grid location, a location or two in front-of the player, or a few locations behind or above the player.

Then it’s just a matter of checking if the ghost has to move horizontally to the right or horizontally to the left, or move vertically upwards or downwards. The priority between horizontal or vertical depends on the distance between the target and the ghost. It’s all very quick, very fast, and very smart.

In Space Grunts I add a few more things to the mix, so some monster will only come towards you if you have your back turned to them, and then run away if you are just looking at them. Other monsters are targeting your exact spot, and others are checking which direction you are looking at and then target your next most likely spot on the map.

Since these are all very fast calculations to make, you can add a few more things to all this logic. We can check if we have a lot of health, because if not we rather keep our distance and change our behavior according to our stats.

And finally we also add a “lazy” parameter to each monster, which is basically the willingness of a monster to actually attack you in a turn. Some monsters are less aggressive and will not move on every turn, other monsters are very aggressive and will keep moving every chance they get.

All these variations add to the tactical part of the game, once a player figures out who the aggressive monsters are, and who is most likely going to step away if you look into their direction, you can make your decisions on clearing a room based on the knowledge of how these creatures work, or try to run away..



Bookmark the permalink.