while(true){ DrawFrame(); if(Soldier.See(health)) Soldier.MoveForward(1 unit) if(Soldier.UnderFire()) Soldier.MoveBackward(1 unit)}
Soldier isn''t in any particular state at any point in time. In fact, I could replace it with any other Soldier, and get the exact same behavior, because they don''t hold any state. If they did hold a state, then replacing a Soldier that is in the state BERZERK with a soldier that is in the state FEARFORHISLIFE would not yield the same results. My perception is that a fsm soldier''s code would look like this:
while(true){ DrawFrame(); if(Soldier.See(health)) Soldier.state = SEEINGHEALTH if(Soldier.UnderFire()) Soldier.state = UNDERFIRE switch(Soldier.state){ case SEEINGHEALTH: Soldier.MoveForward(); break; case UNDERFIRE: Soldier.MoveBackward(); break; };}
So even if the soldier stops seeing health, it will still keep it in mind, because Soldier.state persists from one frame to another.
But I''m probably confusing ''memory'' and ''finite-state machines''.
Cédric