Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

View Poll Results: Have you heard of state machines before
What machines? 7 70.00%
Yeah, I've heard of them 1 10.00%
Not only have I heard of them, but I've used them a few times 1 10.00%
Have I heard of them? I use them on a regular basis 1 10.00%
Voters: 10. You may not vote on this poll

 
 
Thread Tools Display Modes

 
State Machines
Reply
Posted 2002-04-16, 11:41 AM
Okay, how many of you guys have heard of state machines?

State machines are functions that perform a small amount of a task each time they are called and keep track of their position in the process using a state variable. State machines are used for multi-tasking; a main loop can call several state machines each time through so each function gets time to perform its duties.

Maybe I can even find time to come up with an example and an excercise if people are interested
--WetWired
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2002-04-17, 05:28 PM in reply to WetWired's post "State Machines"
what r u talking about?
Sovereign's REAL sig
Old
Profile PM WWW Search
GameCube is neither ape nor machine; has so far settled for the in-betweenGameCube is neither ape nor machine; has so far settled for the in-between
 
 
GameCube
 



 
Reply
Posted 2002-04-18, 07:18 AM in reply to WetWired's post "State Machines"
Quote:
State machines are functions that perform a small amount of a task each time they are called and keep track of their position in the process using a state variable. State machines are used for multi-tasking; a main loop can call several state machines each time through so each function gets time to perform its duties.
That's what I'm talking about

If I somehow find time between working on my phpBB style, setting up phpBB on my Linux box, and creating my new website design, I might come up with a simple example program
--WetWired
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2002-04-18, 04:29 PM in reply to WetWired's post "State Machines"
Never heard of 'em.
I think I'm lost.
Old
Profile PM WWW Search
Badass Gandhi is neither ape nor machine; has so far settled for the in-betweenBadass Gandhi is neither ape nor machine; has so far settled for the in-between
 
Badass Gandhi
 



 
Reply
Posted 2002-06-13, 03:30 PM in reply to WetWired's post "State Machines"
Something like, there's a main function... and 3 sub functions...

Main
SmallFunc
MedFunc
LargeFunc


And then, Main calls each one, but each one only goes a certain ways through..
SmallFunc, a few commands
MedFunc, a few commands more than SmallFunc
LargeFunc, a few commands more than MedFunc

So that, all of the functions complete at about the same time? Is that what you mean?
Old
Profile PM WWW Search
BlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzBlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
BlueCube
 



 
Reply
Posted 2002-06-14, 07:45 AM in reply to WetWired's post "State Machines"
Essentially, that's the way the program appears to work to the user, but how it works is each function has a state variable and a switch statement, so the first time it's called it might do the code for state 0, then set the variable to state 1, next time it's called it'll do the code for state 1, then it might set the state to 50 to do that code next time, or stay in state 1 while waiting for something. All the functions are called in a loop in the main function and each does a little part of what they do each time they are called so it appears as if they are running at the same time.

It's a simple concept, though hard to explain on a msg board...
--WetWired
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2002-06-15, 09:34 AM in reply to WetWired's post "State Machines"
Okay, I know what you're talking about now...

switch (melmac)
{
case 0: {run code here; melmac = 1; break;}
case 1: {run code here; do calculations; if (bob == 5) melmac = 2; else melmac = 3; break;}
case 2: {cout << "Bob equaled five!"; break;}
case 3: {cout << "Stupid Bob, it didn't equal five!"; break;}
}

Will only run one case statement each time through (might be a bit off, haven't programmed in C++ in a few months...)
Old
Profile PM WWW Search
BlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzBlueCube enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
BlueCube
 



 
Reply
Posted 2002-06-16, 03:12 AM in reply to WetWired's post "State Machines"
nope never heard of it
Old
Profile PM WWW Search
Sum Yung Guy seldom sees opportunities until they cease to beSum Yung Guy seldom sees opportunities until they cease to beSum Yung Guy seldom sees opportunities until they cease to beSum Yung Guy seldom sees opportunities until they cease to be
 
 
Sum Yung Guy
 



 
Reply
Posted 2002-06-16, 08:20 AM in reply to WetWired's post "State Machines"
but they seem pretty useful...
Old
Profile PM WWW Search
Randuin is neither ape nor machine; has so far settled for the in-between
 
 
Randuin
 



 
Reply
Posted 2002-07-02, 04:52 PM in reply to WetWired's post "State Machines"
never heard of
Old
Profile PM WWW Search
ZERONX is neither ape nor machine; has so far settled for the in-betweenZERONX is neither ape nor machine; has so far settled for the in-between
 
ZERONX
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 03:10 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.