   StateMachine Questions
  I am not asking this question to start a fight between anyone, I am just looking for honest opinions based on experience.  I am implementing a StateMachine class for my RTS game I am working on.  After reading Programming Game AI by Example the author uses singletons for all of the states.  He does make a note that in some cases it is necessary to add a few lines of code to allocate and deallocate memory.  What does everyone recommend when multiple instances of a class are going to be created?  Say for example I have 35 soldiers that all have memory for states already allocated as opposed to them sharing states using singletons.  I have created a State Based game engine that uses a linked list to store the game states.  The states are retrieved with an id that is unique to that game state.  My next question is, what is the best way to transfer information into the state.  For example in the soldier class I have an update function that would call update the current state like this.void Update(float elapsed){m_pCurrentState->Update(this, elapsed);}Is this a good way to do transfer information to the state?  Also for rendering, should that be built into each state, or should there be a seperate State Machine for handling animations?Thanks in advance for any advice.   
  Honestly, use of a singleton, except in rare cases is normally a sign of bad overall design.  I have a good part of a engine working and not a single singleton (we did have the logger as one but that was pointless imo and removed).   ;  If you look here:http://www.gamasutra.com/gdc2005/features/20050311/isla_01.shtmlthere's a bit of stuff on how Halo 2 handled memory considerations in their state machines. They wrote their states as 'code fragments that operate on a chunk'. That is to say each agent stored a chunk of memory and handed that memory to their currently operating state to do with what it wanted. In this way you only need one chunk of memory for each level of your hierarchical FSM.;  Nice article, I'd missed it.   