stateMachine
as global func/type
typealias StateMachineType = () -> Int
func makeStateMachine(maxState:Int) -> StateMachineType{
var currrentState: Int = 0
return {
currrentState++
if currrentState > maxState {
currrentState = 0
}
return currrentState
}
}