Warehouse
"Practical wisdom is only learnt in the school of experience." -Samuel Smiles
PROJECTS NEWS MESSAGES MAILING LIST  
AI Game Development
Learn how to create smart creatures in computer games that learn and react to their environment. Neural networks, genetic algorithms, reinforcement learning and more!
More information at Amazon US UK
Help Needed in AI in 3D Games
Urgent
 
Help Needed...Urgent......

Hi Everybody...I've just started 3D Game Programming and frankly speaking have got very little idea about it..but surely find it pretty exciting....I wanted to know if anybody out there can help me with the development of the Enemy character in my game...I'm making a 3D shooting game..Just want to add the enemy character who can run, hide and attack the player...I'm Using Morfit as a 3D Engine and VC++ as the language...Plz reply me soooon...i'm stuck and badly neeed some help......If some one has worked on it, kindly can u mail me the Source of that thing...its my college project and not a commercial product...

Byeeeeeeeeee....
Take care.....

1 posts.
Wednesday 09 October, 22:28
Reply
Help Needed in AI in 3D Games

Think I can help you on your way...

For the following, I'm assuming that you are already able to make the enemy walk and turn.

Easiest way I can think of, is using a waypoint system and a state machine.

Waypoint system: You specify locations (waypoints) in your environment (ie. in a level editor), and for each location you specify the connections to other (nearby) waypoints. This way you can create a grid or paths your enemy can walk on. Good thing about this is that you don't have to worry about collision detection (at least not with the static environment)

State machine: Can be implemented as a switch/case statement. You will need about three states: Guard, run, attack...

A short (pseudo code):

switch (currentState)
{
case STATE_GUARD:
{
// Do nothing but standing

// Check whether to change to another state
if (distanceToPlayer < 5.0f)
{
currentState = STATE_ATTACK;
}
}
break;

case STATE_ATTACK:
{
// Shoot gun/use blade/whatever

if (distanceToPlayer < 3.0f)
{
currentState = STATE_RETREAT;
}
}
break;

case STATE_RETREAT:
{
// Shoot gun/use blade/whatever
WalkAway();

// WalkAway should disable state machine until a certain distance (ie > 5.0f)
currentState = STATE_GUARD;
}
break;
}

Note that the above piece of code is missing something trivial: Pathfinding. Easiest is to implement WalkAway something like this.

void WalkAway()
{
for (int i=0;i<currentWaypoint.NumConnections;i++)
{
if (GetDistanceBetween(currentWaypoint, currentWaypoint.Connection[i]) > DistanceToPlayer)
{
// Do your enemy walk code here
WalkToWaypoint(currentWaypoint.Connection[i]);
return;
}
}
}

Hope this makes any sense!

If not, drop me a mail on [email protected]

9 posts.
Monday 14 October, 09:17
Reply