---
name: switchback-defense
description: Build a playable 3D tower defense field with live pathfinding, editable layouts, upgradeable turrets, enemy waves and touch controls.
version: 0.1.0
---

# Switchback Defense

Build a maze of turrets and watch real enemy routes bend around it. Grove Bastion provides three editable battlefield layouts, four turret roles, six enemy archetypes and one hundred progressively stronger waves. English and Simplified Chinese are included.

## Example

```sh
node scripts/fill-prompt.mjs --slots assets/prompts/examples/grove-bastion.json --out prompt.md
node scripts/new-project.mjs --out my-bastion
cd my-bastion && npm ci
npm run dev
npm run build:single
npm run shoot -- --file dist-single/index.html
```

Give the filled prompt and generated project to a coding agent. Edit `src/layouts.json` for geometry and palette; tune turret and unit parameters in `src/sim.mjs`. Keep the actual pathfinding and combat loop intact. Deliver editable source, one offline HTML and bilingual verification reports.

## Interaction

Choose a turret and click or tap an empty tile. A placement reroutes enemies and cannot seal a route. Select towers to upgrade or sell; send the next wave after clearing the last. Toggle the path, pause, accelerate or restart. Desktop wheel zoom is optional. Synthesized tones remain muted until enabled by a gesture. Reduced motion starts paused.

## Verification and hosting

See `references/verification.md`. The maintainer publisher builds first-party source in an isolated temporary copy without credentials and uses a loopback-only browser server. A SandBase Sandbox may run the same commands. Headless timing does not establish physical-device performance.

## Credentials and failures

No keys, external models/assets, model calls or storage are needed. Node 22.4 or later and npm dependencies are required. Missing Chrome stops browser checks. Invalid layout data fails validation; sealed routes reject placement before charging coins. Lost lives end the game and require restart. The UI reports a graphics startup failure.

## FAQ

- Is the route prerecorded? No. A* recomputes routes from actual obstacles and moving unit destinations.
- Can I add a field? Yes. Add a valid layout with an open entrance-to-exit route.
- Are flying units affected by the maze? No. They fly directly to the gate and remain vulnerable to towers.
- Is music bundled? Only optional synthesized tones are included.
