{"id":22760272,"url":"https://github.com/aptacode/statenet","last_synced_at":"2026-04-04T02:01:12.887Z","repository":{"id":43155524,"uuid":"213370189","full_name":"Aptacode/StateNet","owner":"Aptacode","description":"A small .Net Standard library used to model simple State Machines","archived":false,"fork":false,"pushed_at":"2022-03-15T20:56:54.000Z","size":9454,"stargazers_count":14,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-11T13:36:53.890Z","etag":null,"topics":["aptacode","csharp","dotnet","dotnet-core","dotnet-standard","state-machines","wpf"],"latest_commit_sha":null,"homepage":"https://aptacode.com/opensource/statenet/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aptacode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-07T11:52:21.000Z","updated_at":"2023-09-27T03:13:29.000Z","dependencies_parsed_at":"2022-09-15T01:02:02.953Z","dependency_job_id":null,"html_url":"https://github.com/Aptacode/StateNet","commit_stats":null,"previous_names":["timmoth/aptacode.statenet","timmoth/statenet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aptacode/StateNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aptacode%2FStateNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aptacode%2FStateNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aptacode%2FStateNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aptacode%2FStateNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aptacode","download_url":"https://codeload.github.com/Aptacode/StateNet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aptacode%2FStateNet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31384847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"online","status_checked_at":"2026-04-04T02:00:07.569Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aptacode","csharp","dotnet","dotnet-core","dotnet-standard","state-machines","wpf"],"created_at":"2024-12-11T09:06:25.114Z","updated_at":"2026-04-04T02:01:12.858Z","avatar_url":"https://github.com/Aptacode.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003cdiv style=\"width:640;height:320\"\u003e\n       \u003cimg style=\"width: inherit\" src=\"https://raw.githubusercontent.com/Timmoth/Aptacode.StateNet/Development/Resources/Images/Banner.jpg\"\u003e\n\u003c/div\u003e\n\u003c/p\u003e\n\n## A .Net Standard library used to model complicated State Machines\n\n[![Discord Server](https://img.shields.io/discord/533275703882547200?logo=discord)](https://discord.gg/D8MSXJB)\n[![NuGet](https://img.shields.io/nuget/v/Aptacode.StateNet.svg?style=flat)](https://www.nuget.org/packages/Aptacode.StateNet/)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1d08da0b20b0407682ed6cf71f7bd3a1)](https://www.codacy.com/gh/Aptacode/StateNet/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=Aptacode/StateNet\u0026amp;utm_campaign=Badge_Grade)\n![last commit](https://img.shields.io/github/last-commit/Aptacode/StateNet?style=flat-square\u0026cacheSeconds=86000)\n[![Build Status](https://dev.azure.com/Aptacode/StateNet/_apis/build/status/Aptacode.StateNet?branchName=Development)](https://dev.azure.com/Aptacode/StateNet/_build/latest?definitionId=21\u0026branchName=Development)\n\n### Overview\n\nStateNet's primary purpose is to create a simple way to define and control the flow through pages of an application. However, since its inception the library has grown versatile with usecases ranging from X to Y.\n\n### Usage\n\nAt its core, StateNet works by defining a network of states, and how those states are connected. Inter-state connections are defined by a list of 'Connections' for a given 'Input' each of which have dynamically-computed probabilities.\n\nFor example, consider a network that defines the traffic lights at a pedestrian crossing. The network will have these states:\n -Red\n -Yellow\n -Green\n -Pending Pedestrians\n\nThe network's state will be `Green` until a pedestrian Triggers `Crossing`. An equation will then check if the `Green` state has been active for long enough. If it has, then the odds of moving to `Yellow` are 100%. If it hasn't been long enough, then the probability of transitioning to `Pending Pedestrians` is 100%. Once in either the `Yellow` or `Red` state, a Trigger such as 'timer-check' might fire every second. Every time `timer-check` fires, the state will only change back to `Green` if enough time has passed for pedestrians to have crossed.\n\n#### How to Configure the Network\nList all of the states your application needs. Then consider the relationships between those states in order to determine your system's Inputs (state transition trigger events). Create a connection by defining a source state, input, destination state and an expression which determines the weight of the connection at runtime.\n\nWeights can be as simple or dynamic as you need. For example, a dice will have 6 states, 1 Trigger (`roll`), and each state-connection (all 36 of them [6X6]) has a hard coded weight of 16.66%. A more complex system might use boolean logic, comparisons or arithmatic expressions to determine the connection weight based on the transition history.\n\n\n```csharp\n    //Defining the network\n    var network = NetworkBuilder.New.SetStartState(\"A\")\n\t.AddConnection(\"A\", \"Next\", \"B\", new ConstantInteger\u003cTransitionHistory\u003e(1))\n        .AddConnection(\"B\", \"Next\", \"A\", new ConstantInteger\u003cTransitionHistory\u003e(1))\n\t.Build().Network;\n\n    //Running the engine\n    var engine = new StateNetEngine(network, new SystemRandomNumberGenerator());\n    engine.OnTransition += (transition) =\u003e Console.WriteLine(transition);\n    var state1 = engine.CurrentState;   //A\n    var state2 = engine.Apply(\"Next\");  //B\n    var state2 = engine.Apply(\"Next\");  //A\n\n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faptacode%2Fstatenet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faptacode%2Fstatenet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faptacode%2Fstatenet/lists"}