Advertisement

Help with AI

Started by October 20, 2005 09:24 PM
2 comments, last by Programmer16 19 years, 1 month ago
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!
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/
Advertisement
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)	{		if (head is not bent down) then bend down head;		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(){	if (berries ahead) then state=Eating;	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!
----------------------~NQ - semi-pro graphical artist and hobbyist programmer
Thanks guys! fup, that article is awesome, I'll definately be looking into buying your book.

Thanks again!

This topic is closed to new replies.

Advertisement