Dark Basic/Enemy A.I.

AI is a term used to describe how intelligent your computer controlled game characters are. There are several types of A.I ranging from retro game A.I. stealth game A.I. sports games A.I. and strategy games A.I. I'm basically going to fill you in on what you should consider when making A.I. for a stealth game.Guards for a typical stealth game will have 4 main states namely unconcious, normal, confused and allerted.

PHYSICAL STATES



Unconcious State
Characterised by the guard sleeping, knocked out, killed or disabled in some form. In this state the guard cannot see or hear anything and cannot act to any changes in thier environment. If the guards had been knocked out they could still recover with time, if they where sleeping they could wake up if they here a big sound or are hit by something, all these could cause them to upstage to the normal state (unless they are already dead).

Normal State
Charactersied by the guards patrolling an area of the stage, standing guard, going about thier business etc In this state the guard can see and hear all, if the guard here's something they immediately look in the direction or go and investigate (upstage to confused state). If the guard sees something but not sure what it is, the upstage to the confused state and go and check it out, however if they clearly see an enemy they upstage straight to the allerted state.

Confused State
Characterised by the guard hearing a noise or seeing a strange image, naturally the guard either stares in the direction of the sound/image or walks over there to take a closer look. If the guard here's a noise, walks over and still sees or here's nothing then he returns to his former position or simillar and downstages to the normal state. same goes with images, if he sees something and moves closer and finds the image has gone he downstages, however if he clearly sees an enemy then he upstages to the allerted stage.

Allerted Stage
Characterised by the guard chasing the enemy guns blazing, attacking with a weapon or simillar etc in some cases the guard/enemy gives chase, in others they may go and sound a warning. A timer could be used and incremented when the enemy is out of view, if the timer reaches a certain value then the guard dowstages to the confused state because he has lost his target, alternatively he could attack it's target until killed or captured.

ENEMY AI DEMO



You didn't think i was going to present you with all this theory and not give you a demo to back it up now did you? As a matter of fact, i even wrote the demo first, 3+ years ago to be precise for my game called Ninja Scroll that i terminated. You can find more info on the game here but for now, let me explain what this demo seeks to proove.

General Overview
A lite version of the game stripped down to showcase my progress in the AI. I cannot guarantee that the program will work on your system but it was made using dark basic classic which is pretty stable, that's your only assurance . You can download the program below.

The Controls
Just a brief description of the controls available in the demo. There are 3 main stances, Normal, Stealth and Combat. The Normal stance allows you to move quickly but makes a lot of noise. The Stealth stance allows you to move slowly and quietly. The Combat stance enables all the fighting moves that can be executed using the mouse. To retrieve your thrown items move close to them until their highlighted then left mouse click to collect them back. Obviously if you kill a man with a bullet you can't retrieve it!

The HUD
Refer to the screenshot of the game while reading the list below for a brief description of the items on the HUD, what they are, what they do and how they aid the stealth aspect of the game. I was seriously planning on adding a smell item on the HUD but never got around to doing it, oh well, there are other games.

The Enemy AI
Nothing special, pretty straightforward. It's not a matter of trying to interprete the (my) code but more about trying to understand the underlying principles (like why i wrote this particular line of code) and creating your own code from what you learnt. Understanding other people's code is very hard! As for testing the A.I., try doing the following within the program.

Final Notes
Code is old school, i could find better ways of doing some of the stuff in there now that i'm a better coder than i was back then. As i've repeatedly said the game wasn't finnished so stuff like sword attacks won't work on the enemy, enemy won't attack you (just stand there stairing at you like a zombie), bugs, glitches etc.


Name: Ninja Scroll Enemy AI Demo (.exe)
Author: Dienye Boham
Version: v1.0
Size: 2.64MB
Date uploaded: 29/11/05
Download link: Download here


updated 13.10.06