Advertisement

Finite States Machines

Started by June 13, 2002 01:26 PM
16 comments, last by Tai-Pan 22 years, 5 months ago
Ive been studying Finite State Machines at college, and I would like to know how they can be used with the AI of a game, does anyone know about any tutorials about this? Thanks "Those who follow the path of the warrior must be ready to die, to stand for their convictions, live for one´s convictions, die for one´s convictions"
"Those who follow the path of the warrior must be ready to die, to stand for their convictions, live for one´s convictions, die for one´s convictions"
The book Game Programming Gems has a piece on it.
It's not what you're taught, it's what you learn.
Advertisement
Google!

Plus you can search our articles and resources section. We have a couple of AI pages listed there.

_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat

Blade Edge Software
Staff Member, GDNet
Public Relations, Game Institute

3-time Contributing author, Game Design Methods , Charles River Media (coming April/May 2002)
Online column - Design Corner at Pixelate

Unnoficial IGDA chat! [polaris.starchat.net -> #igda]
NJ IGDA Chapter - NJ developers unite!! [Chapter Home | Chapter Forum]

Drew Sikora
Executive Producer
GameDev.net

I''m no expert by far, but Finite state machines are one of the most used forms of a.i., even when other a.i. is used, it''s usually used in conjuction with FSM. Basically you can use the states to represent character''s/enemies'' physical/mental/emotional states as well as the game state. Then just use a switch case statement to check the current state each loop. That''s about the extent of my knowledge on the subject


- Free Your Mind -
- Free Your Mind -
Any time you can tell if a game is saying "if this then that" it is a form of finite state machine. I think you would be hard pressed to find a game that DOESN''T use a FSM.

Dave Mark
President and Lead Designer
Intrinsic Algorithm Development

"Reducing the world to mathematical equations!"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Really? If my enemy moves according to the rule: "If there is a health supply in front of you, then move forward.", then it's a FSM?

I thought it had to maintain a state in memory from one game cycle to the next to be considered a FSM. No?

Like, in the original Mario Bros., there wasn't any FSM at all.

Cédric

[edited by - cedricl on June 17, 2002 11:26:54 AM]
Advertisement
In a way, the state would be "health detected" and then the commands to go carry that out would follow... e.g. "move to health".

As for Mario Bro... there were states regarding the animation and character state. e.g. walking, running, jumping, swimming. Based on those, there were limitations on what you and the character could do.

Dave Mark
President and Lead Designer
Intrinsic Algorithm Development

"Reducing the world to mathematical equations!"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

If ''go to health supply'' is my only rule, then the state isn''t persistent, so it''s not really a state. If, at the next frame, the health has been hidden by something (a wall, another enemy), then my soldier won''t continue moving forward. The program logic doesn''t remember a thing about what it was doing at the previous frame.

In Mario 64, I would say that the most basic enemies were fsms, because when they saw you, they jumped and pursued you. They kept running for 3-4 seconds even if they could no longer see you.

From what I''ve read, I would say that a FSM must stay in a particular state until a stimuli changes its state. This does not fit the health-driven soldier''s AI.

Oh, and this is all IMVHO. I don''t know much about AI to really argue about something like that. I tried to find a definition of FSMs with Google, but it didn''t really answer my question...

Cédric
In your health problem, you answered your own question. If the health is now OUT of sight, that is an environment change that would possibly kick the dude OUT of the state "Health detected". Of course, smarter AI would be to memorize the location of the detected health and move toward it, checking to see if it is there. Also, it may not be your ONLY rule in that state. For example, if the event "under fire" is detected, it may change the state you are in and decided to go into combat mode rather than getting the health. This is all very simplistic, of course.

Dave Mark
President and Lead Designer
Intrinsic Algorithm Development

"Reducing the world to mathematical equations!"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Also consider multi-level states.

"Escorting ship A" is the primary state.

The secondary states that change all the time might be:
"Escort target"
"Evade Missile"
"Attack target"
"Avoid collision"

As each state ends, the primary state would determine the next state to enter.
It's not what you're taught, it's what you learn.

This topic is closed to new replies.

Advertisement