{"id":410,"date":"2025-07-08T17:07:54","date_gmt":"2025-07-08T07:07:54","guid":{"rendered":"https:\/\/nonlinearexperience.com\/?p=410"},"modified":"2025-07-10T16:03:06","modified_gmt":"2025-07-10T06:03:06","slug":"statemachines","status":"publish","type":"post","link":"https:\/\/nonlinearexperience.com\/index.php\/2025\/07\/08\/statemachines\/","title":{"rendered":"State machines"},"content":{"rendered":"<h1 class=\"wp-block-post-title\">State machines<\/h1>\n\n\n<p class=\"wp-block-paragraph\">See also:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">System:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Is what he says here ACTUALLY true? I think it comes down to semantics. Still, an interesting video&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8216;If you&#8217;re not using state machines as the fundamental organising principle behind your game, then you&#8217;re doing it wrong&#8230;&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How NES Games Use State Machines For Everything\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/8lZ53Sx5oc0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gameprogrammingpatterns.com\/state.html\">https:\/\/gameprogrammingpatterns.com\/state.html<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/shaggydev.com\/2021\/11\/01\/state-machines-intro\">https:\/\/shaggydev.com\/2021\/11\/01\/state-machines-intro<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gameprogrammingpatterns.com\/state.html\">https:\/\/gameprogrammingpatterns.com\/state.html<\/a><\/p>\n\n\n\n<div class=\"wp-block-merpress-mermaidjs diagram-source-mermaid\"><pre class=\"mermaid\">---\ntitle: NES Controller\n---\nstateDiagram-v2\n    direction LR\n    S1 --> S2\n    S2 --> S1\n\nS3 --> S4\n    S4 --> S3\n<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What the machine recons<\/p>\n\n\n\n<div class=\"wp-block-merpress-mermaidjs diagram-source-mermaid\"><pre class=\"mermaid\">stateDiagram-v2\n    [*] --> Idle\n    Idle --> Walking: Move\n    Walking --> Idle: Stop\n    Walking --> Attacking: Attack\n    Idle --> Attacking: Attack\n    Attacking --> Idle: Done\n    Idle --> Hit: Enemy Attack\n    Hit --> Dead: HP &lt;= 0\n    Hit --> Idle: Recover\n<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-merpress-mermaidjs diagram-source-mermaid\"><pre class=\"mermaid\">stateDiagram-v2\n    [*] --> Idle\n    Idle --> Patrolling: Timer\n    Patrolling --> Chasing: Player in Sight\n    Chasing --> Attacking: In Range\n    Attacking --> Chasing: Player Moves\n    Chasing --> Patrolling: Player Lost\n    Idle --> Hit\n    Hit --> Dead: HP &lt;= 0\n    Hit --> Idle: Recover\n<\/pre><\/div>\n\n\n\n<div class=\"wp-block-merpress-mermaidjs diagram-source-mermaid\"><pre class=\"mermaid\">stateDiagram-v2\n    [*] --> Unavailable\n    Unavailable --> Available: NPC Offers\n    Available --> Active: Accept\n    Active --> Completed: Objective Done\n    Completed --> TurnedIn: Player Talks to NPC\n<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/xstate.js.org\/docs\">https:\/\/xstate.js.org\/docs<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/jakesgordon\/javascript-state-machine\">https:\/\/github.com\/jakesgordon\/javascript-state-machine<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/jotai.org\">https:\/\/jotai.org<\/a> &#8211; Jotai takes an atomic approach to global React state management.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gamedevacademy.org\/what-is-a-state-machine-complete-guide\">https:\/\/gamedevacademy.org\/what-is-a-state-machine-complete-guide<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>See also: System: Is what he says here ACTUALLY true? I think it comes down to semantics. Still, an interesting video&#8230; &#8216;If you&#8217;re not using state machines as the fundamental organising principle behind your game, then you&#8217;re doing it wrong&#8230;&#8221; https:\/\/gameprogrammingpatterns.com\/state.html https:\/\/shaggydev.com\/2021\/11\/01\/state-machines-intro https:\/\/gameprogrammingpatterns.com\/state.html What the machine recons https:\/\/xstate.js.org\/docs https:\/\/github.com\/jakesgordon\/javascript-state-machine https:\/\/jotai.org &#8211; Jotai takes an atomic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"wp-custom-template-nlx-the-knowledge-page","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-410","post","type-post","status-publish","format-standard","hentry","category-the-knowledge"],"_links":{"self":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/comments?post=410"}],"version-history":[{"count":10,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/410\/revisions"}],"predecessor-version":[{"id":467,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/410\/revisions\/467"}],"wp:attachment":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/media?parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/categories?post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/tags?post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}