Artificial Intelligence in Video Games : Case Studies to consider

Fiction is full of attempts to bring life and to animate objects and recreate them to enact a particular moment of life. To bring such life into lifeless objects in order to make a masterpiece out of it, we need to consider certain aspects before doing so. Certain type of intelligence has to be applied in order to make such games.

The AI element must appear to be acting logical, cause and effect manner irrespective of what is actually happening within the underlying code. So, if the game elements are appearing to behave rationally within their existence, the viewer will fill in the rest. Thus, one of the most important rules for AI to use in games is the appearance of intelligence of throughout.


Let us have a look at 3 case studies for the usage of AI in Games:

. . .

CASE STUDY 1 : Conway's 'Game of Life'


The 'Game of Life' was created by John. H. Conway in 1970. This is most famous example of cellular automation. It is also an example of zero player game ; once you set the initial stage, it does not require any further input from the player.

Rules of Conway's Game of Life:

Rule 1 :- Any live cell with fewer than two live neighbors dies, as if by loneliness.
Rule 2 :- Any live cell with more than three live neighbors dies, as if by overcrowding.
Rule 3 :- Any live cell with two or three live neighbors lives, unchanged to the next automation.
Rule 4 :- Any dead cell with exactly three live neighbors comes to life.

Initial Grid ; Smile indicates alive cell, Crying indicates dead

If only rule 1 taken in consideration w.r.t to first grid

If only rule 2 is taken in consideration ; the arrowed cells will die if rule 1 is applied.

Aftermath generation of the image after crying and arrow-marked cells dies

If Rule 3 is considered, then this is following generation

Taking rule 4 in consideration w.r.t. image above this image.


Types of colonies:

1. Still life :- The last man standing (Results in a stable colonies which will not change). These colonies will never change and will stay as it is.


2. Oscillator :- These are cell colonies that move between states and return to their initial state after number of iterations.


3. Switch Engine :- It just explodes, indefinitely. (Try the below drawn pattern in some emulator to know yourself)


4. Space Ship :- As these type of pattern iterate, it seems visually that they are in some kind of movement while performing iterations.



The Finding :- Great Complexity can arise from smaller and simple rule set.

. . .

CASE STUDY 2 : Robotron 2084

Action of this game takes place on single screen. You have to kill all enemies on the screen and save humans. This game is designed in a way that we will be forced to face enemies in a wave where in each wave, we will get heavily outnumbered. Each enemy will have a different appearance and different logic i.e attack style, type of attack or approach towards player. To play this game today and understand the case study, visit this link.

So lets us dive deep to understand this case study.

Types of Enemies:


1. Grunt :- Grunt simply chases player. In every frame of the game, he just tends to move closer to the player. In fact, Grunt doesn't actually have to know the exact location of the player to chase him, he just needs to know direction to move into.


This code is enough for grunt to determine in which location he has to move in. The above code is enough to normalize the direction for grunt to let him know where to move.

2. Hulk :- Hulk moves only up, down, left and right. His job is to block bullets which are fired by the player. The logic for Hulk is quite simple as his job is to just move on either horizontal or vertical axis.


"Complexity is overlaid Simplicity!!"

3. Enforcer :- Probably the most trickiest enemy to face during the course of the whole game. This enemy wanders as a red sphere and when this sphere is close to the player, it instantly gets up and shoots player.


4. Brain :- The Brain will intend to shoot at player but at the same time, it will also chase humans. If the Brain reaches Human, then it will turn the Human into zombie Prog, which will in turn target the player remorselessly, chasing him down and destroying himself on the player, damaging health of player of course.


5. Tank :- Tanks are similar to enforcers but with one change ; the bullets fired by the Tank will bounce off from the walls and will reflect back. The figure on the left will be the one spawning on the map and once it will come in firing position within the range of the player, it will take the form on the right and will shoot at the player.



6. Electrode Obstacle :- These obstacles will instantly kill you if you bump into them. They have different characteristic than other enemies as they will not shoot but instead just randomly spawn as ideal thing on the map. The player must make sure that they don't get bumped into them as it will result instant killing of them.

 The Electrode obstacles


So these are all the enemies which will player face in the game. As we witnessed, every enemy has different appearance, different attack type and projectile and also different behavior. We have already seen that "Complexity is overlaid Simplicity". But more than that , the AI of the game can be augmented by the core design. The machinations of designer themselves is great example of it. Also it is equally important to create a sense that there is an over-arching intelligence to enemy invasion force which is present in the game. With the implementation of fully fledged AI and distinct behavior of different enemy units, is what makes game more interesting to play.

What we learnt from this :- You can make it compelling experience and appearance of intelligence of some very simple coded enemies, when they work together in coherent fashion.

. . .

CASE STUDY 3 :- Gauntlet & A* Pathfinding

Gauntlet was released in 1985 and was credited as the first multiplayer dungeon crawler. It was designed by Atari Game Designer Ed Logg, who has previously worked on 'Asteroids' and 'Centipedes'.


Player has to choose among the 4 in-game characters ; Thor, Valkyrie, Wizard and Elf. Each of these character has a special ability which we have to utilize to complete our quest.

1. Thor :- Strongest in Hand-to-Hand Combat, Deals more damage than others.
2. Valkyrie :- Best Armor, Takes least damage from enemies.
3. Wizard :- Specialized in ranged attacks as well as useful for usage of spells which will turn a tide if needed.
4. Elf :- Fastest among all, can easily outrun any enemy unit.

The game is basically in top-down view. We need to collect treasures, kill enemies and proceed forward.

Enemies:

1. Ghost :- They spawn infinitely. They do total kamikaze (suicide) attacks on players. Player must destroy the pile of bones from where they spawn to stop them from coming.


Ghost

2. Demons :- They have melee biting attack and range fireball attack. The fireball damage is splash so it will damage the heroes as well as enemies who are around the attack site.

Demon


3. Grunt :- These are similar to Ghosts, but they have a clubbing melee attack. It is recommended to keep them at range and kill them at distance.

Grunt

4. Purple Mage :- This enemy can go invisible to avoid your attack. Instead destroy the generators which are responsible for production of this unit.

Purple Mage


5. Lobbers :- This unit hurls stones at players from behind the walls. They will tend to run away cowardly when you are in state to attack them. They simply attack you when you are not able to attack them.

Lobber


6. Death :- This unit will chase you and drains your health by touching you. It is also immune to hand attacks and can be destroyed only with magic.

Death

Let us discuss A* Path finding algorithm:

Sometimes, even after applying AI to enemy models, they might bump into each other and might seem dumb, thus disturbing the taste of the game. We use A* Path finding algorithm on our enemy to make him navigate easily and hence make them look more intelligent.

We need:
1. A grid
2. A creature to control
3. An obstacle
4. A destination

Red box is the creature we control, Gray block is obstacle and Blue is destination.


Our world is divided into grid. Each square on the grid can be free or occupied. In an super low resolution game where the world is 5X7 and each node is a pixel, the game would be depicted exactly as you see in above image. But in the modern game we would see Pathfinding will still work as it has been overlaid onto the game world.

So first thing we need to do is search for adjacent 8 squares to move around. There are 8 adjacent square our creatures can possibly move on. So we create an Open List of all these squares where it is possible to move and Closed List will consist of that red square.



Here we are confused which pixel is best to move on for minimal destination cost. So the question is how to determine the optimal path?

The best way is to select the square with lowest F cost. So what is F?
 F = G + H

G stands for the movement cost from starting point A to a given square on grid, following a path generated to get there.

H stands for the estimated cost to move from that given square to final destination B.
A is heuristic value i.e it is a simple guess that "How far will I have to go?"









We have selected Orange as the next step. We just need have very few squares to move on, 2,3,7,8. 


At this step it is important to note that we haven't moved, we have just calculated the path.



We have our path.

This algorithm can be used for the games we discussed in the first two case studies. These are overall only a set of 3D graphics away from being in an modern game in its fundamental AI.

So we have looked upon case studies and this is one basic thing to be considered while implementing intelligence in your games.



 

Comments