{"id":19099517,"url":"https://github.com/dentrax/finite-state-machine","last_synced_at":"2025-04-30T16:20:17.611Z","repository":{"id":103621333,"uuid":"121166716","full_name":"Dentrax/Finite-State-Machine","owner":"Dentrax","description":"Finite State Machine Library for .NET Core (with EASY and ADVANCED implementation)","archived":false,"fork":false,"pushed_at":"2018-02-24T20:16:00.000Z","size":36,"stargazers_count":19,"open_issues_count":0,"forks_count":16,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T05:15:46.208Z","etag":null,"topics":["algorithm","algorithms","automata-theory","csharp","csharp-examples","csharp-notes","deterministic-finite-automata","event-handling","finite-state-machine","fsm","state-machine","theory"],"latest_commit_sha":null,"homepage":null,"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/Dentrax.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-11T21:00:34.000Z","updated_at":"2024-07-05T10:58:18.000Z","dependencies_parsed_at":"2023-05-24T00:15:44.263Z","dependency_job_id":null,"html_url":"https://github.com/Dentrax/Finite-State-Machine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FFinite-State-Machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FFinite-State-Machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FFinite-State-Machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dentrax%2FFinite-State-Machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dentrax","download_url":"https://codeload.github.com/Dentrax/Finite-State-Machine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251739858,"owners_count":21635936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["algorithm","algorithms","automata-theory","csharp","csharp-examples","csharp-notes","deterministic-finite-automata","event-handling","finite-state-machine","fsm","state-machine","theory"],"created_at":"2024-11-09T03:51:07.888Z","updated_at":"2025-04-30T16:20:17.605Z","avatar_url":"https://github.com/Dentrax.png","language":"C#","readme":"\u003ch1 align=\"center\"\u003eFinite State Machine Public Source Repository\u003c/h1\u003e\n\n[What It Is](#what-it-is)\n\n[How To Use](#how-to-use)\n\n[Requirements](#requirements)\n\n[About](#about)  \n\n[Collaborators](#collaborators)  \n\n[Branches](#branches) \n\n[Copyright \u0026 Licensing](#copyright--licensing)  \n\n[Contributing](#contributing)  \n\n[Contact](#contact)\n\n## What It Is\n\n**Finite State Machine with .NET Core**\n\nFinite State Machine guide for .NET Core language is an easy and advanced way to learn how algorithms works in theory.\n\n**Uses : `.NET Core`** -\u003e **[Official .NET Core](https://dotnet.github.io/)**\n\n**Finite State Machine**\n\nA finite-state machine, or FSM for short, is a model of computation based on a hypothetical machine made of one or more states. Only a single state can be active at the same time, so the machine must transition from one state to another in order to perform different actions.\n\nFSMs are commonly used to organize and represent an execution flow, which is useful to implement AI in games. The \"brain\" of an enemy, for instance, can be implemented using a FSM.\n\n![Preview Thumbnail](https://cdn.tutsplus.com/gamedev/uploads/2013/10/fsm_enemy_brain.png)\n\n![Preview Thumbnail](http://www.i-programmer.info/images/stories/BabBag/FiniteState/fig2.PNG)\n\n![Preview Thumbnail](https://praveenthomasln.files.wordpress.com/2012/04/figure-1-state-machines.png)\n\n![Preview Thumbnail](https://cdn.tutsplus.com/gamedev/uploads/2013/12/fsm_steering_enemy_brain.png)\n\nReference: https://gamedevelopment.tutsplus.com/tutorials/finite-state-machines-theory-and-implementation--gamedev-11867\n\n**Who is the target audience?**\n\nThis course is meant for anyone who wants to learn Finite State Machine algorithm and theory in C#. The examples are made with C# using .NET Core.\n\n* Warning : This course assumes you have some C# knowledge, and `does not teach C# itself.`\n\n* Warning : These example tutorials are not a \"How to make State Machine\" or \"How State Machines works\" and will not teach \"State Machine techniques\"\n\n## How To Use\n\nExample Usage\n--------------------------\n\n![Preview Thumbnail](https://raw.githubusercontent.com/Dentrax/Finite-State-Machine/master/images/console.png)\n\n`StateType` -\u003e Main states (like Booting, Launching, Initializing, etc.)\n\nClasses\n--------------------------\n\n| Class\t\t\t| Access Modifier   | Explanation\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| ------------- |:-----------------:|:-------------------------------------------------------------------------:|\n| `StateBase`\t| Abstract\t\t    | Main state base. When creating a new state, you need to inheritance this\t|\n| `StateInfo`\t| Abstract\t\t    | Use this to move information between states. But not mandatory\t\t\t|\n\n\nStateBase\n--------------------------\n\n| Function\t|  Access Modifier  | Explanation                                                   |\n| --------- |:-----------------:|:-------------------------------------------------------------:|\n| `Begin`\t| Public Override   | Trigger when a state is initializing           \t            |\n| `Load`    | Public Override   | Need to call manually, after state was initialized            |\n| `Update`\t| Public Override   | Need to call manually, if you want the update with deltaTime\t|\n| `End`\t    | Public Override   | Trigger when a state is terminating                           |\n\nEvents\n--------------------------\n\n| Event\t\t\t                |  Type  | Explanation                                      |\n| ----------------------------- |:------:|:------------------------------------------------:|\n| `FiniteStateBeganEventArgs`\t| Action | Trigger when a state is initialized with Begin()\t|\n| `FiniteStateChangeEventArgs`  | Action | Trigger when a state is changed to another\t    |\n| `FiniteStateEndedEventArgs`\t| Action | Trigger when a state is terminated with End()\t|\n\nState Machine\n--------------------------\n\n| Function\t\t|  Args              | Explanation                              |\n| ------------- |:------------------:|:----------------------------------------:|\n| `Initialize`  | -                  | Initialize the FSM\t                    |\n| `AddState`\t| -                  | Add a State to FSM\t                    |\n| `MoveTo`      | StateType, OnEvent | Change the current State to given State  |\n\nExample State\n--------------------------\n\n```csharp\n\npublic sealed class ExampleState : StateBase {\n\n    public ExampleState(FiniteStateMachine fsm, StateType stateKey) : base(fsm, stateKey) {\n        //Your Constructor() codes\n    }\n\n    public override void Begin(FiniteStateChangeEventArgs eventArgs, StateType previousStateKey) {\n        //Your Begin() codes \n    }\n\n    public override void End() {\n        //Your End() codes\n    }\n\n    public override void Load() {\n        //Your Load() codes\n    }\n\n    public override void Update(float deltaTime) {\n        //Your Update() codes\n    }\n}\n\n```\n\nExample StateInfo\n--------------------------\n\n```csharp\n\npublic sealed class ExampleStateInfo : StateInfo {\n\n    //Your variables, events, functions, etc.\n\n    public override string ToString() {\n        //Example ToString()\n    }\n}\n\n```\n\nExample Usage\n--------------------------\n\n```csharp\n\nFiniteStateMachine.Instance.Initialize();\nFiniteStateMachine.Instance.AddState(new Example1State(FiniteStateMachine.Instance, StateType.EXAMPLE1));\nFiniteStateMachine.Instance.AddState(new Example2State(FiniteStateMachine.Instance, StateType.EXAMPLE2));\nFiniteStateMachine.Instance.AddState(new Example3State(FiniteStateMachine.Instance, StateType.EXAMPLE3));\n\n\nFiniteStateMachine.Instance.MoveTo(StateType.EXAMPLE1, new FiniteStateChangeEventArgs(StateType.EXAMPLE1, new ExampleStateInfo()));\nFiniteStateMachine.Instance.MoveTo(StateType.EXAMPLE2, new FiniteStateChangeEventArgs(StateType.EXAMPLE2, new ExampleStateInfo()));\nFiniteStateMachine.Instance.MoveTo(StateType.EXAMPLE3, new FiniteStateChangeEventArgs(StateType.EXAMPLE3, new ExampleStateInfo()));\n\n```\n\nExample Event Handling\n--------------------------\n\n```csharp\n\nFiniteStateMachine.Instance.OnStateBegan += new Action\u003cFiniteStateBeganEventArgs\u003e(this.OnFiniteStateBegan);\nFiniteStateMachine.Instance.OnStateEnded += new Action\u003cFiniteStateEndedEventArgs\u003e(this.OnFiniteStateEnded);\nFiniteStateMachine.Instance.OnStateChange += new Action\u003cFiniteStateChangeEventArgs\u003e(this.OnFiniteStateChange);\n\npublic void OnFiniteStateBegan(FiniteStateBeganEventArgs e) {\n    //Trigger when OnFiniteStateBegan\n    //Began: e.Type\n}\n\npublic void OnFiniteStateChange(FiniteStateChangeEventArgs e) {\n    //Trigger when OnFiniteStateChange\n    //RequestedType: e.RequestedType\n    //StateInfo: e.StateInfo (Returns null, if no parameters are given)\n}\n\npublic void OnFiniteStateEnded(FiniteStateEndedEventArgs e) {\n    //Trigger when OnFiniteStateEnded\n    //End: e.Type\n}\n\n```\n\n\n## Requirements\n\n* You should be familiar with .NET Core family\n* You will need a text editor (like VSCode) or IDE (Visual Studio)\n* You will need a computer on which you have the rights to install .NET Core\n\n## About\n\nFinite State Machine was created to serve three purposes:\n\n**Finite State Machine is a basically State Machine learning repository which base state-machine library coded in C# language**\n\n1. To act as a guide to learn Finite State Machine with enhanced and rich content using `.NET Core`.\n\n2. To act as a guide to exemplary and educational purpose.\n\n3. To create an advanced State-Machine with few lines.\n\n## Collaborators\n\n**Project Manager** - Furkan Türkal (GitHub: **[dentrax](https://github.com/dentrax)**)\n\n## Branches\n\nWe publish source for the **[Finite-State-Machine]** in single rolling branch:\n\nThe **[master branch](https://github.com/dentrax/Finite-State-Machine/tree/master)** is extensively tested by our QA team and makes a great starting point for learning the algorithms. Also tracks [live changes](https://github.com/dentrax/Finite-State-Machine/commits/master) by our team. \n\n## Copyright \u0026 Licensing\n\nThe base project code is copyrighted by Furkan 'Dentrax' Türkal and is covered by single licence.\n\nAll program code (i.e. C#) is licensed under MIT License unless otherwise specified. Please see the **[LICENSE.md](https://github.com/Dentrax/Finite-State-Machine/blob/master/LICENSE)** file for more information.\n\n**References**\n\nWhile this repository is being prepared, it may have been quoted from some sources. \nIf there is an unspecified source, please contact me.\n\n## Contributing\n\nPlease check the [CONTRIBUTING.md](CONTRIBUTING.md) file for contribution instructions and naming guidelines.\n\n## Contact\n\nFinite-State-Machine was created by Furkan 'Dentrax' Türkal\n\n * \u003chttps://www.furkanturkal.com\u003e\n \nYou can contact by URL:\n    **[CONTACT](https://github.com/dentrax)**\n\n\u003ckbd\u003eBest Regards\u003c/kbd\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdentrax%2Ffinite-state-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdentrax%2Ffinite-state-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdentrax%2Ffinite-state-machine/lists"}