Initial commit.

This commit is contained in:
gmp
2018-10-17 18:21:25 -04:00
commit 9531a1a5d8
2 changed files with 93 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"fmt"
"gitlab.wow.st/gmp/tile/state"
)
type Thing struct {
*state.StateMachine
val int
}
func main() {
fmt.Println("Creating state machine.")
s := state.NewStateMachine("Start")
s.Arc("Start", "Thinking", func() {fmt.Println("Starting to Think")})
s.Arc("Thinking", "Start")
s.Arc("Thinking", "Done", func() {fmt.Println("Going to Done")})
fmt.Println("Sending Done")
s.State <-"Thinking"
s.State <-"Start"
s.State <-"Thinking"
s.State <-"Done"
fmt.Println("Finished.")
t := &Thing{}
t.StateMachine = state.NewStateMachine("Start")
t.Arc("Start","End",func() {fmt.Println("Hi!")})
t.State <- "End"
}