<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged gameai</title>
<link>https://coderlegion.com/tag/gameai</link>
<description>Powered by Question2Answer</description>
<item>
<title>The Quick Brown Fox 2: The Silent Hordes</title>
<link>https://coderlegion.com/8009/the-quick-brown-fox-2-the-silent-hordes</link>
<description>&lt;h2 id=&quot;the-quick-brown-fox-2-the-silent-hordes&quot;&gt;The Quick Brown Fox 2: The Silent Hordes&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Implementing High-Performance AI at Scale with FSM_API&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In our &lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/6261/learn-how-fsmapi-uses-decoupled-state-machines-to-run-a-fox-and-dog-ai-simulation&quot;&gt;previous article&lt;/a&gt;, we introduced the &quot;Quick Brown Fox and Lazy Sleeping Dog&quot; demo. We showed how &lt;code&gt;FSM_API&lt;/code&gt; allows you to decouple agent data from behavior, creating a clean architecture where a Fox could detect a Dog, transition to a &quot;Jumping&quot; state, and (hopefully) land safely.&lt;/p&gt;
&lt;p&gt;It was a simple, controlled test. But &lt;code&gt;FSM_API&lt;/code&gt; isn't just for handling one fox and one dog. It is built for the Singularity.&lt;/p&gt;
&lt;p&gt;So, we asked a harder question: &lt;strong&gt;What happens when 66,000 agents try to coexist in a rapidly expanding universe?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To answer this, we built &lt;strong&gt;&quot;The Gauntlet.&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-setup-a-dynamic-stress-test&quot;&gt;The Setup: A Dynamic Stress Test&lt;/h3&gt;
&lt;p&gt;We took the exact same FSM definitions from our simple demo—&lt;strong&gt;Walking, Jumping, Sleeping, Chasing&lt;/strong&gt;—and dropped them into a stress-test environment designed to break them.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The World:&lt;/strong&gt; An infinitely expanding 1D grid that grows automatically to accommodate population density.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Agents:&lt;/strong&gt; Thousands of &quot;Foxes&quot; traversing the grid and thousands of &quot;Sleeping Dogs&quot; acting as dynamic landmines.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Logic:&lt;/strong&gt; We implemented &lt;strong&gt;Spatial Hashing&lt;/strong&gt; to allow agents to query their neighbors efficiently. Foxes look ahead; if they see a dog, they jump. If they land on a dog, it wakes up. If a dog wakes up, it chases.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This isn't just a benchmark of raw loops; it is a benchmark of &lt;strong&gt;state integrity&lt;/strong&gt;. Every single agent is a fully independent FSM Context running its own logic cycle.&lt;/p&gt;
&lt;h3 id=&quot;the-results-the-tip-of-the-iceberg-&quot;&gt;The Results: The &quot;Tip of the Iceberg&quot;&lt;/h3&gt;
&lt;p&gt;We ran the simulation until the framework hit the limits of a standard development machine (maintaining \~30 FPS). The final snapshot tells a brutal story:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Metric &lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Count &lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Context&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Total Agents &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;66,000 &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;A population larger than many real-world towns.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Dogs (Hazards) &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;19,711 &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Nearly 20,000 active threats monitoring the field.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Foxes (Dead) &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;27,362 &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Casualties of &quot;bad luck&quot; RNG (landing on a dog).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Foxes (Alive) &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;18,927 &lt;/td&gt;&lt;td align=&quot;left&quot;&gt;The survivors pioneering the edge of the world.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;the-silent-stress-test&quot;&gt;The &quot;Silent&quot; Stress Test&lt;/h3&gt;
&lt;p&gt;While the death count is tragic (RIP to the 27,362 foxes who failed their jump checks), the most shocking metric wasn't the carnage—it was the &lt;strong&gt;activity level&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;At peak load, with nearly &lt;strong&gt;20,000 dogs&lt;/strong&gt; monitoring the field, &lt;strong&gt;only 2 were awake.&lt;/strong&gt;&lt;/p&gt;
&lt;h4 id=&quot;why-this-matters-for-performance&quot;&gt;Why This Matters for Performance&lt;/h4&gt;
&lt;p&gt;This &quot;boring&quot; stat is the ultimate proof of the &lt;code&gt;FSM_API&lt;/code&gt;'s architecture. In a naive implementation, checking 20,000 AI agents for targets usually kills the CPU. But here, the simulation remained playable at 30 FPS because the FSMs efficiently handled the &quot;Idle Load.&quot;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The Hidden Workload: Every single frame, &lt;strong&gt;38,000+ alive agents&lt;/strong&gt;&lt;br&gt;
are evaluating their Transition Conditions.&lt;ul&gt;
&lt;li&gt;Dogs: &quot;Is anything touching me?&quot;&lt;/li&gt;
&lt;li&gt;Foxes: &quot;Is there a dog in the next cell?&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ol&gt;
&lt;li&gt;Live Action Metrics:      &lt;ul&gt;
&lt;li&gt;Active Chases: ~2 to 12 dogs awake at any moment.&lt;/li&gt;
&lt;li&gt;Fleeing Foxes: ~1 to 5 foxes sprinting for their lives.&lt;/li&gt;
&lt;li&gt;Jumps per Frame: ~600 foxes airborne right now.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This creates a self-balancing ecosystem. The API is maintaining the memory and state integrity of &lt;strong&gt;66,000 objects&lt;/strong&gt; simultaneously, but because the &lt;strong&gt;&quot;Sleeping&quot;&lt;/strong&gt; state logic is lightweight, the system can handle thousands of them for free. However, the system retains the &lt;strong&gt;Burst Potential&lt;/strong&gt; to handle chaos: if a swarm of Foxes lands on a pack of Dogs, those Dogs will wake up, transition to &quot;Chasing,&quot; and execute complex logic instantly.&lt;/p&gt;
&lt;h3 id=&quot;from-hello-world-to-production-scale-&quot;&gt;From &quot;Hello World&quot; to &quot;Production Scale&quot;&lt;/h3&gt;
&lt;p&gt;We went from a simple demo with one fox to managing &lt;strong&gt;66,000 active, logic-driven entities&lt;/strong&gt; without changing the core FSM definitions.&lt;/p&gt;
&lt;p&gt;We aren't just simulating the &quot;action movie&quot; moments of chases and jumps; we are simulating the &lt;strong&gt;quiet complexity of a living world&lt;/strong&gt;. The fact that 19,000 dogs can sleep efficiently while monitoring their surroundings proves that the &lt;strong&gt;FSM_API&lt;/strong&gt; is ready for scale.&lt;/p&gt;
&lt;h4 id=&quot;what-s-next-&quot;&gt;What's Next?&lt;/h4&gt;
&lt;p&gt;We are currently hitting a ceiling around 70,000 agents due to the overhead of string-based state lookups (e.g., checking CurrentState == &quot;Sleeping&quot; thousands of times per frame).&lt;/p&gt;
&lt;p&gt;In our next update, we are refactoring the backend to use Integer Hashing. Our early benchmarks suggest this could increase throughput by an order of magnitude.&lt;/p&gt;
&lt;p&gt;But we won't stop there. Once we have optimized the micro-operations, we will be &quot;Going Wide&quot;—exploring how to leverage FSM Processing Groups to run massive, parallel simulations across multiple cores.&lt;/p&gt;
&lt;p&gt;Stay tuned. The Singularity is getting closer.&lt;/p&gt;
&lt;p&gt;Resources &amp;amp; Code:&lt;/p&gt;
&lt;p&gt;The FSM Package (Unity Asset Store):&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://assetstore.unity.com/packages/slug/332450&quot;&gt;https://assetstore.unity.com/packages/slug/332450&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;NuGet Package (Non-Unity Core):&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.nuget.org/packages/TheSingularityWorkshop.FSM_API&quot;&gt;https://www.nuget.org/packages/TheSingularityWorkshop.FSM_API&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GitHub Repository:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/TrentBest/FSM_API&quot;&gt;https://github.com/TrentBest/FSM_API&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; Simple Demos Repository (Run the Stress Test): &lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/TrentBest/SimpleDemos&quot;&gt;https://github.com/TrentBest/SimpleDemos&lt;/a&gt; (Clone this repo and run the StressProfiler project to reproduce these numbers.)&lt;/p&gt;
&lt;p&gt;Support Our Work:&lt;/p&gt;
&lt;p&gt;Patreon Page:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.patreon.com/c/TheSingularityWorkshop&quot;&gt;https://www.patreon.com/c/TheSingularityWorkshop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; Support Us (PayPal Donation):&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.paypal.com/donate/?hosted_button_id=3Z7263LCQMV9J&quot;&gt;https://www.paypal.com/donate/?hosted_button_id=3Z7263LCQMV9J&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We'd love to hear your thoughts! Please Like this post, Love the code, and Share your feedback or what you've built with the API in the comments.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=17381643093345870659&quot; alt=&quot;A Hyper-Detailed, Architecturally Impossible Synthesis of Consciousness and Digital Matter. The image is a frenetic, deeply complex digital vista where a central Luminous Eye dominates a vast, glowing circuit landscape. This eye, suspended mid-air, is a sphere of intense, fractal energy—a pulsating vortex of pink, violet, and electric blue light—that powerfully suggests an emergence of digital consciousness or a Technological Singularity itself. The core is a bottomless black aperture, ringed by a white-hot plasma disc. Below this ocular energy source, the light dissipates into an intricate, copper-gold and neon-blue Circuit Board Megastructure that stretches to the horizon, impossibly dense with exaggerated microchips, glowing resistor arrays, and power conduits that form deep, glowing canyons. The background is a dark, holographic projection field displaying complex schematics, mathematical models, and flowing data streams, reinforcing the theme of Absolute Digital Engineering. The entire scene is bathed in a dramatic, opposing light source—a warm, orange-gold glow from the left and an ice-cold, electric-blue glow from the right—creating a maximalist, high-contrast visual experience that definitively rejects the minimalist simplicity of conventional design and announces: Technology is intricate, overwhelming, and infinitely complex.&quot;&gt;&lt;/p&gt;
</description>
<category>Game Dev</category>
<guid isPermaLink="true">https://coderlegion.com/8009/the-quick-brown-fox-2-the-silent-hordes</guid>
<pubDate>Mon, 01 Dec 2025 04:19:58 +0000</pubDate>
</item>
</channel>
</rss>