# Help with AI

## Recommended Posts

I'm trying to expand my game development knowledge, and I've come to AI. My questions are: 1)What is one of the easier parts of AI (so that I can ease myself in)? 2)Are there any really good books that I should look into? I pretty much know nothing about AI, other than what I've looked into on path finding (ok, so I don't know anything). Thanks!

##### Share on other sites
Try the state driven agent article at my website. That'll ease you in nicely

If you enjoy that, you might like to consider buying my book... it'll show you how to do all the stuff found in the binaries here:

http://www.wordware.com/files/ai/

##### Share on other sites
Mr. AI-Junkie have written very good articles, and I'd recommend them.

Easing you in into the AI world should be finite state machines. Since fup's article is abit large and goes to great length to be correct, I thought I could sum it up in a (slightly less correct) summary.

## This is how a finite state machine can work:

The complete behaviour of the agent (the AI character) is split up into small manageable parts.

Let's say the game world is a forest enviroment. Somewhere in the game loop you check the enviroment around the agent.
It can detect things such as "wolf nearby" and "berries ahead".

The agent is a deer. You've thought about the behaviour it should have, and have decided to seperate it into four parts: Eating, Walking, and Fleeing.

Each one of these is a STATE, and is how the technique got it's name.

The deer can only do one of these at any given time. So the deer is set to a specific state. Another part (the action-performer) in the game loop checks which state the deer is in, and performs a chunk of code associated with that state.
This is the action-performer:

Handle_States()
{
If (state==Walking)
{
randomly turn around;
walk forward;
}

If (state==Fleeing)
{
if (not facing away from wolf) then turn away from wolf;
move forward very quickly;
}

If (state==Eating)
{
increase deer_health;
}
}

When created, the deer spawns with it's STATE set to Walking. The action-performer thus makes the deer move around. The sensory-checker doesn't detect any changes, and the deer keeps on moving around for a while.
Then the sensory-checker finds berries ahead, and instantly sets the deer state to Eating.
This is the sensory checker:

Check_Senses()
{
else if (wolf nearby) then state=Fleeing;
else state=Walking;
}

Instead of walking, the action-performer now performs the action of the deer eating berries.
A minute later a wolf comes by, the deer detects this and is set into Fleeing-state.

That was a brief description of how you should imagine a finite state machine. My recommendation is that it should be your first attempt at AI.

Good luck!

##### Share on other sites
Thanks guys! fup, that article is awesome, I'll definately be looking into buying your book.

Thanks again!

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628277
• Total Posts
2981770

• 10
• 11
• 17
• 10
• 9