Last active
September 27, 2015 13:37
-
-
Save neilmanuell/1277913 to your computer and use it in GitHub Desktop.
AS3 API for TryHarderStateMachine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fsm | |
.configureState( StateNames.HAPPINESS ) | |
.withEntryGuards( OnlyIfHappy, OnlyIfSmiling ) | |
.withExitiGuards( OnlyIfAnxious ) | |
.withTargets( StateNames.SADNESS, StateNames.ECSTACY ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fsm | |
.configure( ProcessNames.GET_HAPPY ) | |
.ifCurrentState( StateNames.FRUSTRATED ) | |
.transition( StateNames.ANNOYED, StateNames.EXPECTATION ) | |
.ifCurrentState( StateNames.EXPECTATION ) | |
.transition( StateNames.EPIPHANY, StateNames.HAPPINESS ) | |
.elseThrowError(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fsm.mapProcess( ProcessNames.GET_HAPPY ) | |
.to( HappyEvent.GET_HAPPY ) | |
.unlock( StateNames.EXPECTATION ).after( HappyEventTrigger ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fsm | |
.during( StateNames.HAPPINESS) | |
.cancellation | |
.always.execute( DoThis, DoThat ).onApproval( OnlyIfThat ) | |
.and.always.execute( DoTheOther ) | |
fsm | |
.during( StateNames.HAPPINESS) | |
.tearDown | |
.always.execute( DoThisCmd ).onApproval( OnlyIfThis ) // executed only if all guards approve | |
.and.always.execute( DoThatCmd ).onApproval( OnlyIfThat ) // executed only if all guards approve | |
.and.always.execute( DoTheOther ) //always executed; | |
fsm | |
.during( StateNames.HAPPINESS ) | |
.cancellation | |
.either.execute( DoThis, DoThat ).onApproval( OnlyIfThat ) // executed only if all guards approve | |
.or.execute( DoTheOther ) // executed only if previous commands are not executed | |
.and.always.execute( SomethingElse) // always executed | |
Very interesting... It would be great to see a basic implementation example to see how it stacks up against the traditional FSM approach.
cheers... am working one up in tandem as a robotlegs 2 extension
Cool... looking forward to taking a look when you're done.
maybe a while, got a full plate at the mo :)
yeah no worries mate, I know the feeling...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
States (nodes)
Processes
Command Mapping