Document about a limitation about transitions

Open Beginner friendly
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp
Domain
documentation

Research direction

Read the existing documentation to find where stack automatons, transitions, and actions are explained; the issue does not name a documentation file or test. Add an explanation of the limitation and the described workaround of pushing a target state during an action. Done when the documentation covers the problem and solution clearly.

Written by the indexing model from the issue text.

Description

documentation

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.

Dominant language
C#
Stars
0
Forks
1
Avg merge
1h 1m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Natvs/Nt.Automaton

All issues in Natvs/Nt.Automaton

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.