LfrlAnvil.Computable.Automata 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package LfrlAnvil.Computable.Automata --version 0.1.1
NuGet\Install-Package LfrlAnvil.Computable.Automata -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LfrlAnvil.Computable.Automata" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LfrlAnvil.Computable.Automata --version 0.1.1
#r "nuget: LfrlAnvil.Computable.Automata, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LfrlAnvil.Computable.Automata as a Cake Addin
#addin nuget:?package=LfrlAnvil.Computable.Automata&version=0.1.1

// Install LfrlAnvil.Computable.Automata as a Cake Tool
#tool nuget:?package=LfrlAnvil.Computable.Automata&version=0.1.1

(root) NuGet Badge

LfrlAnvil.Computable.Automata

This project contains structures and algorithms related to the automata theory.

Documentation

Technical documentation can be found here.

Examples

Following is an example of a deterministic finite state machine (FSM):

public enum TurnstileState
{
    Locked = 0,
    Unlocked = 1
}

public enum TurnstileInput
{
    Coin = 0,
    Push = 1
}

public enum TurnstileOutput
{
    Unchanged = 0,
    Locked = 1,
    Unlocked = 2
}

// creates a new state machine builder that will represent a turnstile state machine
var builder = new StateMachineBuilder<TurnstileState, TurnstileInput, TurnstileOutput>( TurnstileOutput.Unchanged );

// registers a 'Locked' => 'Locked' transition with 'Push' input, that returns the default 'Unchanged' output
builder.AddTransition(
    source: TurnstileState.Locked,
    destination: TurnstileState.Locked,
    input: TurnstileInput.Push );

// registers a 'Locked' => 'Unlocked' transition with 'Coin' input that returns the 'Unlocked' output
builder.AddTransition(
    source: TurnstileState.Locked,
    destination: TurnstileState.Unlocked,
    input: TurnstileInput.Coin,
    handler: StateTransitionHandler.Create<TurnstileState, TurnstileInput, TurnstileOutput>( _ => TurnstileOutput.Unlocked ) );

// registers an 'Unlocked' => 'Unlocked' transition with 'Coin' input, that returns the default 'Unchanged' output
builder.AddTransition(
    source: TurnstileState.Unlocked,
    destination: TurnstileState.Unlocked,
    input: TurnstileInput.Coin );

// registers an 'Unlocked' => 'Locked' transition with 'Coin' input that returns the 'Locked' output
builder.AddTransition(
    source: TurnstileState.Unlocked,
    destination: TurnstileState.Locked,
    input: TurnstileInput.Push,
    handler: StateTransitionHandler.Create<TurnstileState, TurnstileInput, TurnstileOutput>( _ => TurnstileOutput.Locked ) );

// marks the 'Locked' state as initial
builder.MarkAsInitial( TurnstileState.Locked );

// builds the state machine
var machine = builder.Build();

// creates a traversable instance of the state machine that starts at the initial 'Locked' state
var instance = machine.CreateInstance();

// applies 'Push' input to the current 'Locked' state,
// which does not change the state and returns 'Unchanged' output
var result = instance.Transition( TurnstileInput.Push );

// applies 'Coin' input to the current 'Locked' state,
// which changes the state to 'Unlocked' and returns 'Unlocked' output
result = instance.Transition( TurnstileInput.Coin );

// applies 'Coin' input to the current 'Unlocked' state,
// which does not change the state and returns 'Unchanged' output
result = instance.Transition( TurnstileInput.Coin );

// applies 'Push' input to the current 'Unlocked' state,
// which changes the state to 'Locked' and returns 'Locked' output
result = instance.Transition( TurnstileInput.Push );
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 38 6/16/2024
0.2.0 37 6/16/2024
0.1.1 76 5/29/2024
0.1.0 76 5/26/2024