# Switchback Defense: Grove Bastion

> Place turrets to bend enemy routes through a woodland battlefield. Actual A* paths, combat and upgrades drive the defense.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Game creation](https://www.sandbase.ai/skills/games)
- Version: 0.1.0
- Runs online: yes
- Page: https://www.sandbase.ai/skills/games/switchback-defense

## What you get

Bring a battlefield, defenders and an optional palette. The Skill returns a downloadable Skill, interactive demos and example videos.

## Install

Download the Skill package from https://www.sandbase.ai/skills/games/switchback-defense (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/switchback-defense create <your battlefield> with editable layouts, actual live pathfinding and upgradeable defenses
```

## How it works

1. **Describe the battlefield in slots** Switchback Defense starts from prompt slots for a battlefield and its defenders. node scripts/fill-prompt.mjs --slots assets/prompts/examples/grove-bastion.json --out prompt.md renders the sample, and node scripts/new-project.mjs --out my-bastion generates the project. Grove Bastion provides three editable layouts, four turret roles, six enemy archetypes and one hundred progressively stronger waves, in English and Simplified Chinese.
2. **Edit layouts and combat locally** Your coding agent edits src/layouts.json for geometry and palette and tunes turret and unit parameters in src/sim.mjs, keeping the pathfinding and combat loop intact. It needs Node 22.4 or later and npm dependencies, with no keys, external models or assets, model calls or storage. Invalid layout data fails validation, and each layout needs an open entrance-to-exit route.
3. **Build and check live rerouting** npm run build:single writes one offline HTML file, and npm run shoot -- --file dist-single/index.html runs bilingual interaction checks in Chrome. Confirm that placing a turret reroutes enemies, that a placement sealing the route is rejected before coins are charged, and that towers upgrade, sell and fire. Deliver the editable source, the HTML and the reports.

## FAQ

### What is Switchback Defense?

Switchback Defense is a playable 3D tower defense game where your turret maze bends live enemy routes. Choose a turret and click or tap an empty tile, select towers to upgrade or sell, and send the next wave after clearing the last. You can toggle the path, pause, accelerate or restart.

### Are Switchback Defense enemy routes prerecorded?

No. Switchback Defense recomputes routes with A* from the actual obstacles and moving unit destinations after each placement. Moving units finish their current segment without teleporting, and a placement cannot seal the spawn or a moving ground unit.

### Does Switchback Defense need a model key?

No. Switchback Defense needs no keys, external models or assets, model calls or storage, and the built game runs offline. Building it only installs npm dependencies, so no SandBase charge applies.

### Do flying units in Switchback Defense follow the maze?

No. Switchback Defense sends flying units straight to the gate, ignoring the maze, while they remain vulnerable to towers. Ground units are the ones that reroute around placements.

### Can I add a battlefield to Switchback Defense?

Yes. Switchback Defense reads its battlefields from src/layouts.json; add a valid layout with an open route from entrance to exit and rebuild. Invalid layout data fails validation instead of producing a broken map.

### What ends a Switchback Defense game?

Switchback Defense ends the game when you lose all lives, and you restart to play again. The UI reports a graphics startup failure if 3D cannot start, and missing Chrome stops the browser checks. Only optional synthesized tones are bundled, muted until a gesture enables them.

## Examples

- Switchback Defense interactive battlefield (scene)
- Switchback Defense: Grove Bastion (video)
