Skip to content

Document about a limitation about transitions #10

Description

@Natvs

What is this limitation?

This limitation concerns stack automatons.

Sometimes, a random value must be processed to define the transition to take. However, transitions only accept predefined values (one value for one transition exactly) and do not allow an arbitrary set of values. This is particulary limiting when the number or nature of transitions are not known at the time the state is created.

Example: it is not possible to create a transition taken only if the value respects a certain pattern.

The good news is that there are already methods to get deal with this problem. Here is one:

How to deal with the limitation

Push onto the stack

Instead of creating the transitions at state creation time, push them on the stack when performing an action.

Example:
If the count of transitions is not known, you cannot do something like the following when creating the state:

var target1 = new State();
var target2 = new State();
...
state.SetDefault(defaultState)
state.AddTransition(new Transition<int>(1, target1));
state.AddTransition(new Transition<int>(2, target2));
...

Instead, create an action, link it to the state and push the target state when performing it:

class CustomAction: IAction {

    public void Perform() {
        ...
        var target = new State();
        automaton.Push(target)    
    }
}

state.SetDefault(defaultState, new CustomAction())

This issue is to add this problem and some solutions to the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions