Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
For those not familiar with state machines, I'd go read up on them quickly.

Has anyone found a good use in programming for states? Outside of robot design (ai specifically), I haven't found a real good use for states and was wondering if you guys have any good examples.

Obviously there are states at a small level in that a key is pressed or not and stuff. I'm talking about high level design.

Edit: I should elaborate that I do realize most programming breaks down to a huge set of states with broad input (ie proboards actions = states and thread IDs = input)


Last Edit: Feb 24, 2011 17:47:06 GMT by Chris

Simie

Simie Avatar

******
ProScripter

1,052


May 2006
Entities in game use them extensively. I'm also using a primitive state machine in my UI for an app I'm developing.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Simie Avatar
Entities in game use them extensively. I'm also using a primitive state machine in my UI for an app I'm developing.


Got any examples in games? Nothing comes to mind just thinking of them.

Simie

Simie Avatar

******
ProScripter

1,052


May 2006
Game AI, mostly. I'd imagine its very similar to robot AI. A door in a game might have 4+ states, open,closed,closing,opening,locked,unlocked


Last Edit: Feb 24, 2011 17:49:47 GMT by Simie

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Game AI would be a good example as well. :P I relate that to robot AI which I mentioned above, but also a reasonable thing.

I don't consider a door to be a state machine by the original definition I was taught... I consider it just a standard class with properties:
class Door {
locked = false
closed = false
}


Something like that. (Pseudo-code ftl.) However, I can see where that makes sense. :P I was talking more along the lines of where a large portion of the code switches based on the state. Web-apps are the best example (which is why I mentioned PB) in that action is the state and thus they switch the entire program based on that.

I didn't think to look at small pieces of code as a state machine though, so doors are a good example. :P

Eric

Eric Avatar



1,442


November 2005
To be honest, no, not really. I never intentionally use them. I can easily see the use in a game though.

Search of "state machine uses":
www.ibm.com/developerworks/library/l-python-state.html

newBookmarkLockedFalling