🗼

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

ParamTypeRequiredDefaultDescription
waveCountnumberYes10Number of waves. Range 3–50.
difficultynumberNo0.5Base difficulty (0.0–1.0). Affects budget scaling and enemy composition.
budgetPerWavenumberYes20Base budget per wave. Scales up with progression.
spawnPointsnumberNo2Number of enemy spawn points (1–6).
enemyTypesEnemyType[]Nobuilt-inCustom enemy type definitions. Uses 11 built-in types if not provided.

Generation Details

The wave generator follows this process:

  1. Calculate per-wave difficulty using progression curve (0→1 ramp + base difficulty offset)
  2. Scale budget per wave: earlier waves get less, later waves get more
  3. Assign wave types: rush (fast/cheap), tank (heavy), swarm (many cheap), mixed, boss, breather
  4. Boss waves at final wave and optionally mid-way for 8+ wave sets
  5. Breather waves every 4th wave for player recovery
  6. Compose enemies within budget — pick from filtered pool based on wave type
  7. Distribute across spawn points with staggered delays
  8. Validate: budgets respected, difficulty monotonically increases (breathers excepted)

Built-in Enemy Types

NameCostHPSpeedArmorSpecial
Scout1302.00
Grunt2601.01
Runner2402.50
Heavy41500.63
Shielded51200.85Shield
Tank62500.46
Flyer3451.50Flying
Ogre Boss158000.38Boss
Dragon2012000.55Boss, 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 delay field 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 enemyTypes array to match your game's unit roster.