Home / Articles / Building a Local Angry Birds Clone With Qwen3.8-27B and Pi

This article is published in English.

Building a Local Angry Birds Clone With Qwen3.8-27B and Pi

Learn how to set up a fully local AI coding workflow using LM Studio and the Pi agent to build a playable Angry Birds level with Qwen3.8-27B.

1952 words

A few weeks ago, a small side project set out to answer a slightly absurd question: could you build a single playable level of Angry Birds — physics engine, slingshot mechanic, collapsing towers, the whole package — using only a local model running on ordinary consumer hardware? No cloud API keys, no metered billing, no code leaving the machine.

It worked. Birds flew across the screen, wooden blocks toppled over, pigs got squashed on impact. The model powering all of this was Qwen3.8-27B, running inside LM Studio and orchestrated by Pi, an open-source terminal-based coding agent. What follows is the complete setup: an introduction to the model and why it punches above its weight despite fitting on a single Mac, plus the exact steps for installing LM Studio, installing Pi, and connecting the two so that Pi routes its requests to your local model rather than a hosted provider.

Why go local at all?

The straightforward motivation is cost and control. Running everything locally gets you:

  • Zero API charges no matter how many hours you spend iterating on a hobby project.
  • Code that never leaves your own machine — a real advantage if you're working on anything you'd prefer not to upload to a third party.
  • No rate limiting and no mid-session "usage cap reached" interruptions.

What you give up is raw generation speed and, traditionally, output quality. That gap, though, has narrowed much faster than most people assume, and Qwen3.8-27B is a solid demonstration of how capable a roughly 27-billion-parameter model can become once it's trained carefully and quantized well for consumer-grade hardware.

Meet the model: Qwen3.8–27B

Qwen3.8-27B comes from Alibaba's Qwen team. It's a dense model with vision support, released under the Apache 2.0 license, so it's free to use even in commercial projects. Before committing to a 16+ GB download, here are the specs worth knowing:

Architecture

  • 27 billion parameters, spread across 64 layers with a 5,120-dimension hidden size
  • A hybrid attention scheme: repeated blocks pairing linear "Gated DeltaNet" attention with a standard gated-attention layer, which helps the model stay fast even as context grows
  • A native context window of 262,144 tokens, expandable up to 1,000,000
  • Training that incorporates multi-token prediction, which gives a real boost to local inference speed

Benchmark results (as reported by Qwen, with comparisons to Anthropic's Opus 4.6 Max where relevant):

The headline takeaway is that a 27B model manages to match or even beat a frontier closed-weight model on coding and agentic benchmarks, which explains why it's a viable everyday choice for something like the Pi agent. These are self-reported figures, so some skepticism is warranted until independent testing catches up — but the hands-on results from the Angry Birds build described later line up with the claims.

One thing to be aware of upfront: Qwen3.8-27B has extended "thinking" (reasoning) enabled by default, set to the xhigh effort tier. That's valuable for genuinely difficult tasks, but it also means the model can burn through thousands of reasoning tokens on trivial requests that don't need that much deliberation. For routine coding-agent work, turning the reasoning effort down to medium or low inside LM Studio's model settings makes responses noticeably faster without much loss in quality. Reserve xhigh for problems that actually demand it.

Available quantizations for running the model locally include GGUF and MLX, each offered at 4-bit, 5-bit, 6-bit, and 8-bit precision. MLX is the variant built specifically for Apple Silicon.

For Mac users, memory requirements roughly break down as follows, which should guide which quantization level makes sense for your hardware:

As a reference point, a Mac mini built around the M4 chip with 32 gigabytes of shared system memory can run the 4-bit quantized version at somewhere around 5 to 6 tokens generated per second. That's not fast in absolute terms, but it's entirely workable for an agent whose job is writing and editing code rather than streaming prose live. On more powerful Apple Silicon chips — the Max or Ultra tiers — or on a capable Nvidia GPU, throughput climbs considerably; some reports place quantized performance in the 15-30 tokens-per-second range on stronger consumer setups.

Step 1: Install LM Studio

LM Studio is the desktop application responsible for loading the model locally and exposing it through an OpenAI-compatible API server. That server is the piece Pi will actually communicate with.

Grab it from the official download page — macOS, Windows, and Linux builds are all available.

Install it the way you would any other desktop program, then launch it.

Step 2: Download Qwen3.8–27B inside LM Studio

  1. Inside LM Studio, open the model search/discovery panel.
  2. Look up qwen/qwen3.8-27b, or go directly to its model page on LM Studio's site.
  3. Choose the quantization level that fits your hardware based on the memory breakdown mentioned earlier — for most machines with 24 to 32 GB of RAM, the MLX 4-bit build hits the right balance. If you'd like to inspect the weights before downloading, the same community-quantized files can be browsed directly on Hugging Face.
  4. Download the model, then load it from either the Chat tab or the My Models tab. While it's loading, set a context length that fits comfortably within your available memory — 16K is a reasonable default, and you can raise it if you have room to spare.
  5. Before continuing, open the model's settings panel and lower Reasoning Effort from xhigh down to medium or low for coding and agentic tasks, for the same reasons discussed earlier.

Step 3: Start LM Studio's local server

This step trips up a lot of people — loading a model into the chat interface does not automatically make it available as an API.

  1. Switch to the Developer tab in LM Studio.
  2. Flip on Start Server.
  3. By default, this publishes an OpenAI-compatible endpoint at http://localhost:1234/v1.

You can confirm it's running from a terminal:

curl http://localhost:1234/v1/models

The JSON response should list qwen/qwen3.8-27b (or whatever the precise identifier turns out to be) — make a note of that exact string, since you'll need it shortly.

Step 4: Install Pi

Pi is an open-source, terminal-based coding agent. It's bring-your-own-key and model-agnostic, designed from the start to work equally well with cloud providers and with local OpenAI-compatible servers such as LM Studio or Ollama.

The official installer:

curl -fsSL https://pi.dev/install.sh | sh

Or, if you'd rather use npm:

npm install -g @earendil-works/pi-coding-agent

Confirm the installation succeeded:

pi --version

Full documentation is available at pi.dev/docs/latest.

Step 5: Point Pi at your local LM Studio model

Pi keeps its provider configuration in ~/.pi/agent/models.json. Open that file (creating it if it doesn't exist yet) and add an entry that references LM Studio's local server:

{
  "providers": {
    "lmstudio": {
      "baseUrl": "http://localhost:1234/v1",
      "api": "openai-completions",
      "apiKey": "lm-studio",
      "models": [
        {
          "id": "qwen/qwen3.8-27b",
          "input": ["text"],
          "contextWindow": 65536,
          "reasoning": true
        }
      ]
    }
  }
}

A handful of details here are easy to get wrong:

  • baseUrl needs to exactly match the address shown in LM Studio's Developer tab, which defaults to http://localhost:1234/v1.
  • apiKey can hold any placeholder text — LM Studio's local server won't validate it, but Pi won't display the model unless the field is populated.
  • models[].id has to match, character for character, whatever LM Studio returns from curl http://localhost:1234/v1/models. A small discrepancy here is the single most frequent reason a local model doesn't appear where expected.
  • contextWindow should mirror the context length you actually configured when loading the model, rather than the model's absolute maximum.

You can also make it the default provider by editing ~/.pi/agent/settings.json:

{
  "defaultProvider": "lmstudio",
  "defaultModel": "qwen/qwen3.8-27b"
}

After restarting Pi — or running /model inside a session that's already open — select lmstudio / qwen/qwen3.8-27b. From that point forward, every request Pi issues stays on your own machine; nothing is sent outside your local network.

Building the Angry Birds stage

With everything wired up, the next step was handing Pi a deliberately loose brief: build a single browser-playable level in the style of Angry Birds — a slingshot mechanic, projectile physics, a stack of blocks that can be knocked apart, and a pig to topple — all packed into one self-contained HTML/JS/Canvas page.

The interesting part wasn't just that it produced a working build on the first genuine attempt — that happened only after dropping the reasoning effort down to medium. At xhigh, the model burned through a huge number of tokens second-guessing elementary physics constants before it ever wrote a line of code. Once tuned correctly, it reasoned soundly about:

  • Drag-to-launch mechanics and projectile motion for the slingshot
  • A basic physics loop covering gravity, collisions, and blocks tipping over
  • Keeping the whole thing as a single, clean JavaScript file it could revise across several turns without losing track of what it had already written

This is exactly the kind of agentic coding work that benchmarks like SWE-bench Pro, Terminal-Bench, and LiveCodeBench are designed to measure, and the behavior lined up with what those scores would suggest. It's not a superficial chatbot party trick — it's a model capable of sustaining a multi-file, multi-turn coding session from start to finish, fully offline, on hardware you already have sitting on your desk.

Practical tips if you're setting this up yourself

  • Default to medium reasoning effort. Save xhigh for genuinely tough architectural or algorithmic challenges. In routine coding-agent loops it mostly just adds latency without improving results.
  • Size your context window around your available RAM, not the model's theoretical ceiling. A 262K context window — or the extended 1M option — looks impressive on paper, but at roughly 64 KB of KV cache per token, long contexts consume memory extremely fast. Something in the 16K–64K range is a more realistic target for most single-GPU machines or Apple Silicon setups.
  • Verify the model identifier carefully. The most common reason a local setup fails is a models.json entry that doesn't precisely match the ID LM Studio reports.
  • Calibrate your throughput expectations. You should expect speeds in the single digits up to the mid double digits of tokens per second, not the pace of a cloud API. That's a reasonable trade-off for running at no cost with no data leaving your machine, but it's worth planning around, particularly on lower-end hardware.

Wrapping up

Not long ago, asking a fully local model to build a playable physics-based game would have sounded ambitious. Now, a 27-billion-parameter model quantized to run comfortably on a single Mac, combined with a lightweight open-source terminal agent, managed it in an afternoon. If you have 24 GB or more of unified memory, or a reasonably capable GPU that's otherwise sitting idle, this setup is a genuinely enjoyable, zero-marginal-cost way to gauge just how far local AI coding tools have come.

Resources referenced in this guide:

The LM Studio download page is available at lmstudio.ai/download, and its listing for this particular model can be found under lmstudio.ai/models/qwen/qwen3.8-27b. The quantized MLX weights themselves are hosted on Hugging Face under the lmstudio-community namespace, listed as Qwen3.8-27B-MLX-4bit. The Pi coding agent has its own site at pi.dev, with accompanying documentation at pi.dev/docs/latest.