🗼
Tower Defense Waves
gameType: "tower-defense"
Budget-based wave composition with difficulty curves. Generates rush, tank, mixed, boss, swarm, and breather waves. Each wave respects its budget while building a natural difficulty progression. Validated for budget compliance and monotonic difficulty (with allowed breather dips).
Interactive Example
🗼 Tower Defense Waves
Budget-based wave composition with difficulty curves
difficulty: 0.48balanced ✓
Difficulty Curve
1
2
3
4
5
#1rush5×scout + 3×grunt11/12 budget330 HP
#2mixed4×grunt + 3×runner17/18 budget360 HP
#3tank3×heavy + 2×shielded22/24 budget690 HP
#4breather6×scout12/28 budget180 HP
#5boss1×boss_ogre + 4×grunt33/35 budget1040 HP
Waves
5
Enemies
31
Total HP
2600
Budget Used
81%
Try it
await pf.generate({
gameType: "tower-defense",
params: { waveCount: 10, budgetPerWave: 20, spawnPoints: 2 },
count: 1,
difficulty: { target: 0.50 }
})API Parameters
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
waveCount | number | Yes | 10 | Number of waves. Range 3–50. |
difficulty | number | No | 0.5 | Base difficulty (0.0–1.0). Affects budget scaling and enemy composition. |
budgetPerWave | number | Yes | 20 | Base budget per wave. Scales up with progression. |
spawnPoints | number | No | 2 | Number of enemy spawn points (1–6). |
enemyTypes | EnemyType[] | No | built-in | Custom enemy type definitions. Uses 11 built-in types if not provided. |
Generation Details
The wave generator follows this process:
- Calculate per-wave difficulty using progression curve (0→1 ramp + base difficulty offset)
- Scale budget per wave: earlier waves get less, later waves get more
- Assign wave types: rush (fast/cheap), tank (heavy), swarm (many cheap), mixed, boss, breather
- Boss waves at final wave and optionally mid-way for 8+ wave sets
- Breather waves every 4th wave for player recovery
- Compose enemies within budget — pick from filtered pool based on wave type
- Distribute across spawn points with staggered delays
- Validate: budgets respected, difficulty monotonically increases (breathers excepted)
Built-in Enemy Types
| Name | Cost | HP | Speed | Armor | Special |
|---|---|---|---|---|---|
| Scout | 1 | 30 | 2.0 | 0 | — |
| Grunt | 2 | 60 | 1.0 | 1 | — |
| Runner | 2 | 40 | 2.5 | 0 | — |
| Heavy | 4 | 150 | 0.6 | 3 | — |
| Shielded | 5 | 120 | 0.8 | 5 | Shield |
| Tank | 6 | 250 | 0.4 | 6 | — |
| Flyer | 3 | 45 | 1.5 | 0 | Flying |
| Ogre Boss | 15 | 800 | 0.3 | 8 | Boss |
| Dragon | 20 | 1200 | 0.5 | 5 | Boss, Flying, Fire |
Example Request
bash
curl -X POST https://api.gameplaygen.com/generate \
-H "Authorization: Bearer gg_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"gameType": "tower-defense",
"params": { "waveCount": 15, "budgetPerWave": 25, "spawnPoints": 3 },
"count": 1,
"difficulty": { "target": 0.7 }
}'Tips for Game Integration
- ▸Spawn timing: Use the
delayfield to stagger enemy spawns within each wave. - ▸Dynamic difficulty: Regenerate remaining waves mid-game if the player is struggling or breezing through.
- ▸Breather waves: Use breather intervals to trigger shop/upgrade UI between intense phases.
- ▸Custom enemies: Pass your own
enemyTypesarray to match your game's unit roster.