import { LoadedMachineConfiguration } from "../../src/types"; import { StateMachine } from "../../src/state-machines/state-machine"; export class VR_TUTORIAL_MOVE_BASICS_STATE_MACHINE extends StateMachine { constructor(options: LoadedMachineConfiguration) { const { context } = options; super([ { "context": { "errorCounter": 0, "stepCounter": 0, ...context }, "id": "VR_TUTORIAL_MOVE_BASICS", "initial": "ready", "states": { "ACKNOWLEDGE_MOVEMENT": { "exit": [], "meta": { "CA": { "utterance": "ACK_MOVE" } }, "on": { "INSTANT": "NEW_STEP" }, "type": "" }, "DESCRIBE_MOVE": { "exit": [], "meta": { "CA": { "utterance": "DESCRIBE_MOVE_NEW" } }, "on": { "MOVE(*)": [ { "actions": [ "errorCounterEQUAL" ], "cond": "", "target": "REINFORCEMENT" } ], "TIMER_TASK": "ERROR_COUNTER1" }, "type": "" }, "ERROR_COUNTER1": { "exit": [], "meta": {}, "on": { "INSTANT": [ { "actions": [ "errorCounterINCREMENT" ], "cond": "errorCounterLOWER3", "target": "DESCRIBE_MOVE" }, { "actions": [ "errorCounterINCREMENT" ], "cond": "errorCounterGREATER2", "target": "GOODBYE_CA" } ] }, "type": "" }, "ERROR_COUNTER2": { "exit": [], "meta": {}, "on": { "INSTANT": [ { "actions": [ "errorCounterINCREMENT" ], "cond": "errorCounterLOWER3", "target": "REINFORCEMENT" }, { "actions": [ "errorCounterINCREMENT" ], "cond": "errorCounterGREATER2", "target": "GOODBYE_CA" } ] }, "type": "" }, "GOODBYE_CA": { "exit": [], "meta": { "CA": { "utterance": "GOODBYE_CA" }, "VR": [ { "name": "task_completed" } ] }, "on": { "INSTANT": "end" }, "type": "" }, "INTRO_MOVE_BASICS": { "exit": [], "meta": { "CA": { "utterance": "TUTORIAL_INTRO_MOVE_NEW" } }, "on": { "INSTANT": "DESCRIBE_MOVE" }, "type": "" }, "NEW_STEP": { "exit": [], "meta": { "CA": { "utterance": "MOVE_AGAIN" } }, "on": { "INSTANT": "REINFORCEMENT" }, "type": "" }, "REINFORCEMENT": { "exit": [], "meta": { "CA": { "utterance": "POSITIVE_REINFORCEMENT" } }, "on": { "INSTANT": [ { "actions": [ "" ], "cond": "stepCounterGREATER2", "target": "TUTORIAL_POSITIVE_REINFORCEMENT" } ], "MOVE(*)": [ { "actions": [ "stepCounterINCREMENT" ], "cond": "stepCounterLOWER3", "target": "ACKNOWLEDGE_MOVEMENT" } ], "TIMER_TASK": [ { "actions": [ "errorCounterINCREMENT" ], "cond": "", "target": "ERROR_COUNTER2" } ] }, "type": "" }, "TUTORIAL_POSITIVE_REINFORCEMENT": { "exit": [], "meta": { "CA": { "utterance": "TUTORIAL_POSITIVE_REINFORCEMENT" }, "VR": [ { "name": "task_completed" }, { "name": "positive_reinforcement" } ] }, "on": { "INSTANT": "end" }, "type": "" }, "end": { "exit": [], "meta": { "VR": [ { "name": "task_completed" } ] }, "on": { "INSTANT": "end" }, "type": "final" }, "ready": { "exit": [], "meta": {}, "on": { "READY": "INTRO_MOVE_BASICS" }, "type": "" } } }, { actions: { errorCounterEQUAL: (context:any) => {context.errorCounter=0;}, errorCounterINCREMENT: (context:any) => {context.errorCounter++;}, stepCounterINCREMENT: (context:any) => {context.stepCounter++;} }, guards: { errorCounterGREATER2: (context:any) => {return context.errorCounter > 2;}, errorCounterLOWER3: (context:any) => {return context.errorCounter < 3;}, stepCounterGREATER2: (context:any) => {return context.stepCounter > 2;}, stepCounterLOWER3: (context:any) => {return context.stepCounter < 3;} } } ]); } }