<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohammad Rafaquat Alam</title>
    <description>The latest articles on DEV Community by Mohammad Rafaquat Alam (@raf-xtgt).</description>
    <link>https://dev.to/raf-xtgt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4090303%2F976d50ca-3674-4b4e-9756-c676cb43b4d8.jpg</url>
      <title>DEV Community: Mohammad Rafaquat Alam</title>
      <link>https://dev.to/raf-xtgt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raf-xtgt"/>
    <language>en</language>
    <item>
      <title>I built a jungle survival browser game where you co-op with an AI agent</title>
      <dc:creator>Mohammad Rafaquat Alam</dc:creator>
      <pubDate>Fri, 04 Sep 2026 05:20:15 +0000</pubDate>
      <link>https://dev.to/raf-xtgt/i-built-a-jungle-survival-browser-game-where-you-co-op-with-an-ai-agent-4503</link>
      <guid>https://dev.to/raf-xtgt/i-built-a-jungle-survival-browser-game-where-you-co-op-with-an-ai-agent-4503</guid>
      <description>&lt;p&gt;This is my first post here. I figured I should start somewhere, and a hackathon project is as good a reason as any.&lt;/p&gt;

&lt;h2&gt;
  
  
  The background
&lt;/h2&gt;

&lt;p&gt;I have been writing business software for about three years. Dashboards, APIs, data pipelines. It pays the bills but it stopped being fun a while ago. When I saw the &lt;a href="https://webmcp.devpost.com/" rel="noopener noreferrer"&gt;WebMCP Challenge&lt;/a&gt; hackathon, I decided to build something I would actually want to play when it was done.&lt;/p&gt;

&lt;p&gt;This is also my first game. Never touched game loops, sprite rendering, or canvas animation before this week.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;Erwin's Survival is a browser game where a human and an AI agent play together. The human explores a jungle, collects resources, and builds a base. The AI reads the game state through WebMCP tools and places defenses before each night attack.&lt;/p&gt;

&lt;p&gt;The game has three simple phases that repeat for three days:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Morning:&lt;/strong&gt; You move with WASD, cut through jungle, collect wood/stone/rope/herbs. You build a base at the crash site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dusk:&lt;/strong&gt; The AI takes over. It reads the threat (how many slimes, from which sides) and calls WebMCP tools to place spike traps, barricades, and fires around the base.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Night:&lt;/strong&gt; Slimes crawl in along three roads. You aim with arrow keys and shoot with spacebar. The defenses the AI placed catch what you miss.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Survive 3 nights and rescue arrives.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpko6g6eq9dl6hqyg5c19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpko6g6eq9dl6hqyg5c19.png" alt="Dusk phase: the AI places defenses while the player watches" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How the AI part works
&lt;/h2&gt;

&lt;p&gt;The game uses &lt;a href="https://developer.chrome.com/docs/extensions/develop/concepts/webmcp" rel="noopener noreferrer"&gt;WebMCP&lt;/a&gt;, which lets a website expose tools that an external AI agent can discover and call. The game registers 5 tools. Four of them only exist during the dusk phase:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;get_game_state&lt;/code&gt; — always available, returns health/inventory/position&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get_planning_context&lt;/code&gt; — dusk only, returns expected enemies and defense options&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;place_spike_trap({side})&lt;/code&gt; — costs 2 wood + 1 stone&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;build_barricade({side})&lt;/code&gt; — costs 3 wood&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;set_fire({side})&lt;/code&gt; — costs 1 wood + 1 herbs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When night falls, the defense tools are unregistered. The AI's job is done until the next dusk.&lt;/p&gt;

&lt;p&gt;I tested it with Chrome's WebMCP flag and the Model Context Tool Inspector extension by François Beaufort. You type something like "plan the defense" and the AI calls the tools one by one. Each call updates the game map in real time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgj86jp3ifpprd8u139ej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgj86jp3ifpprd8u139ej.png" alt="Night phase: slimes approach while the player defends" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The thing I got wrong first
&lt;/h2&gt;

&lt;p&gt;The first version had the AI doing everything: gather water, eat berries, chop wood, craft items. All through WebMCP tools. It worked, but it was boring. Typing "gather water" to an AI when pressing R does the same thing is just friction.&lt;/p&gt;

&lt;p&gt;On day 2, I scrapped that and gave the AI only the planning phase. That was the right call. The keyboard handles actions. The AI handles strategy. Both halves got better once I stopped forcing everything through one channel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vanilla JS + HTML Canvas + Vite&lt;/li&gt;
&lt;li&gt;No framework. About 1500 lines of JS across 9 modules&lt;/li&gt;
&lt;li&gt;Pixel art from a mix of free and paid asset packs ($3.20 total)&lt;/li&gt;
&lt;li&gt;Deployed on Vercel as a static site&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Asset credits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Bow and arrows: &lt;a href="https://sweeetpotatoo.itch.io/top-down-characters" rel="noopener noreferrer"&gt;sweeetpotatoo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Terrain, trees, campfires, barricades: &lt;a href="https://toffeecraft.itch.io/forest-nature-pack" rel="noopener noreferrer"&gt;ToffeeCraft&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Red slime enemies: &lt;a href="https://free-game-assets.itch.io/pixel-art-slime-enemies-top-down-sprite-pack" rel="noopener noreferrer"&gt;Free Game Assets&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Erwin character sprite and grass tiles: &lt;a href="https://nogardlab.itch.io/stardew-farm-pixel-art-top-down-assets" rel="noopener noreferrer"&gt;nogardlab&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it / look at the code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Play:&lt;/strong&gt; &lt;a href="https://jungle-base.vercel.app/" rel="noopener noreferrer"&gt;jungle-base.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://github.com/raf-xtgt/jungle-base" rel="noopener noreferrer"&gt;github.com/raf-xtgt/jungle-base&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demo video:&lt;/strong&gt; &lt;a href="https://www.youtube.com/watch?v=TYEkmSEia8U" rel="noopener noreferrer"&gt;youtube.com/watch?v=TYEkmSEia8U&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to test the WebMCP tools, you need Chrome 146+ with the &lt;code&gt;chrome://flags/#enable-webmcp-testing&lt;/code&gt; flag enabled, plus the Model Context Tool Inspector extension. Or just add &lt;code&gt;?debug=true&lt;/code&gt; to the URL for manual buttons.&lt;/p&gt;

&lt;p&gt;Three days, one game, a lot of sprite cropping. It was fun. Might do more of these.&lt;/p&gt;

</description>
      <category>webmcp</category>
      <category>vite</category>
      <category>gamedev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
