Hi,
I have two questions for help.
1. Suppose that I need to monitor user input from console. When the input is "Love", the current state moves to the Love state. When it is Hate, the current state moves to the Hate state. My question is: How to link the user input to the transition?
I would like to use Context to represent the user input. But how can I set up a listener to monitor the input from console? Please note that it isn't a Java Swing project.
2. Suppose that the current state machine is performing a function (as below), which can generate a random double. Depending on the double value, the next state varies.
protected void ontoQuestion(FSMState from, FSMState to, FSMEvent event, String context) {
double move = new RandomBetween(0, 1);
if (move>0.5) {
// need to move to State A
} else {
// need to move to State B
}
}
My question is how to move to A or B but the supposed state to.
Thanks!