Advertisement

Finite State Machine & Game Prog Gems

Started by March 09, 2004 08:29 AM
3 comments, last by exodus7 20 years, 11 months ago
Hi I''m trying to implement a Finite state machine using the example given in Game Programming Gems 1. Only problem is I get a syntax error regarding the STL . e.g. typedef map< int, FSMstate*, less > State_Map; error C2143: syntax error : missing '';'' before ''<'' I''ve never used STL maps before so I don''t understand the probelm, this is how it is written in the book. Can onn help? Cheers
there is only one way
Did you use the "using namespace std;" ?

Else you''ll have to

typedef std::map< int, FSMstate*, less > State_Map;

You also need to

#include <map>

Hope this helps

Eric
Advertisement
that probably should read

typedef std::map< int, FSMstate*, std::less<int> > State_Map;


notice the space between the two > >

the less parameter specifies the criteria by which the elements in the map are to be sorted. std::map uses less by default so you could write the typedef as

typedef std::map<int, FSMstate*> State_Map;


don''t forget to

#include <map>
lol. Eric, you got there just before me...
You may also want to look at Steve Rabin''s Finite State Machine Language that is in that book as well as "AI Wisdom". That''s slicker than... uh... graphite.

Dave Mark - President and Lead Designer
Intrinsic Algorithm -
"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!"

This topic is closed to new replies.

Advertisement