@vibemancer/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +28 -0
  2. package/dist/chunk-L7Z7OFXD.js +9140 -0
  3. package/dist/chunk-L7Z7OFXD.js.map +1 -0
  4. package/dist/index-browser.d.ts +2602 -0
  5. package/dist/index-browser.js +407 -0
  6. package/dist/index-browser.js.map +1 -0
  7. package/dist/index.d.ts +150 -0
  8. package/dist/index.js +750 -0
  9. package/dist/index.js.map +1 -0
  10. package/package.json +79 -0
  11. package/src/bots/berserker/01_Stormchaser.ts +457 -0
  12. package/src/bots/berserker/02_Stormcaller.ts +417 -0
  13. package/src/bots/berserker/03_Stormforger.ts +481 -0
  14. package/src/bots/caster/01_Flamecaller.ts +286 -0
  15. package/src/bots/caster/02_Pyromancer.ts +350 -0
  16. package/src/bots/caster/03_Infernalist.ts +492 -0
  17. package/src/bots/defensive/01_Turtle.ts +151 -0
  18. package/src/bots/defensive/02_Sentinel.ts +134 -0
  19. package/src/bots/defensive/03_Golem.ts +357 -0
  20. package/src/bots/duelist/01_Battlemage.ts +433 -0
  21. package/src/bots/duelist/02_Warmage.ts +438 -0
  22. package/src/bots/duelist/03_Archmage.ts +588 -0
  23. package/src/bots/homing/01_Bonemancer.ts +67 -0
  24. package/src/bots/homing/02_Lich.ts +356 -0
  25. package/src/bots/homing/03_Archlich.ts +220 -0
  26. package/src/bots/index.ts +30 -0
  27. package/src/bots/kiter/01_Spellspinner.ts +398 -0
  28. package/src/bots/kiter/02_Spellweaver.ts +378 -0
  29. package/src/bots/kiter/03_Spellbinder.ts +448 -0
  30. package/src/bots/melee/01_Shadowblade.ts +270 -0
  31. package/src/bots/melee/02_Nightblade.ts +437 -0
  32. package/src/bots/melee/03_Voidblade.ts +582 -0
  33. package/src/bots/registry.ts +207 -0
  34. package/src/bots/shared.ts +472 -0
  35. package/src/bots/sniper/01_Spellshot.ts +385 -0
  36. package/src/bots/sniper/02_Spelltracer.ts +441 -0
  37. package/src/bots/sniper/03_Spellseeker.ts +546 -0
  38. package/src/bots/standalone/Critter.ts +89 -0
  39. package/src/bots/standalone/Doombringer.ts +91 -0
  40. package/src/bots/standalone/Hogger.ts +228 -0
  41. package/src/bots/standalone/Rookie.ts +50 -0
  42. package/src/bots/standalone/TargetDummy.ts +21 -0
  43. package/src/bots/test/cheater.ts +405 -0
  44. package/src/bots/test/crasher.ts +81 -0
  45. package/src/engine/hooks-runtime.ts +394 -0
  46. package/src/engine/manual-match.ts +289 -0
  47. package/src/engine/missile-templates.ts +155 -0
  48. package/src/engine/optimizer.ts +220 -0
  49. package/src/engine/params-runtime.ts +189 -0
  50. package/src/engine/physics.ts +143 -0
  51. package/src/engine/sandbox-browser.ts +671 -0
  52. package/src/engine/sandbox-compile.ts +197 -0
  53. package/src/engine/sandbox-harness.ts +367 -0
  54. package/src/engine/sandbox.ts +332 -0
  55. package/src/engine/simulation.ts +828 -0
  56. package/src/engine/spells.ts +128 -0
  57. package/src/engine-version.ts +11 -0
  58. package/src/hooks/action-builders.ts +210 -0
  59. package/src/hooks/bot-wrapper.ts +84 -0
  60. package/src/hooks/index.ts +75 -0
  61. package/src/hooks/state-hooks.ts +354 -0
  62. package/src/hooks/threat-analysis.ts +365 -0
  63. package/src/hooks/types.ts +142 -0
  64. package/src/index-browser.ts +30 -0
  65. package/src/index.ts +24 -0
  66. package/src/rules.ts +254 -0
  67. package/src/stats.ts +262 -0
  68. package/src/testing.ts +207 -0
  69. package/src/trace.ts +430 -0
  70. package/src/types.ts +193 -0
  71. package/src/utils/angles.ts +47 -0
  72. package/src/utils/combat.ts +279 -0
  73. package/src/utils/distance.ts +21 -0
  74. package/src/utils/index.ts +7 -0
  75. package/src/utils/movement.ts +108 -0
  76. package/src/utils/random.ts +65 -0
  77. package/src/utils/spatial.ts +63 -0
  78. package/src/utils/targeting.ts +45 -0
@@ -0,0 +1,2602 @@
1
+ /**
2
+ * VIBEMANCER - TYPES
3
+ *
4
+ * This file contains all the TypeScript interfaces used by the game engine.
5
+ */
6
+ /**
7
+ * Position in 2D space.
8
+ */
9
+ interface Position {
10
+ x: number;
11
+ y: number;
12
+ }
13
+ /**
14
+ * Velocity in 2D space (units per tick).
15
+ */
16
+ interface Velocity {
17
+ x: number;
18
+ y: number;
19
+ }
20
+ /**
21
+ * Wizard state.
22
+ */
23
+ interface WizardState {
24
+ id: string;
25
+ position: Position;
26
+ rotation: number;
27
+ health: number;
28
+ maxHealth: number;
29
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
30
+ castingSpell?: 'missile' | 'shield' | 'blink';
31
+ castProgress?: number;
32
+ castDuration?: number;
33
+ channelingSpell?: 'shield';
34
+ channelDuration?: number;
35
+ gcdRemaining?: number;
36
+ blinkCooldown: number;
37
+ velocity: Velocity;
38
+ lastMissileConfig?: MissileConfig;
39
+ warmupMultiplier?: number;
40
+ invincible?: boolean;
41
+ }
42
+ /**
43
+ * Projectile (missile) state.
44
+ */
45
+ interface ProjectileState {
46
+ id: string;
47
+ type: 'missile';
48
+ ownerId: string;
49
+ position: Position;
50
+ rotation: number;
51
+ speed: number;
52
+ turnRate: number;
53
+ damage: number;
54
+ remainingTicks: number;
55
+ }
56
+ /**
57
+ * Game configuration (read-only).
58
+ */
59
+ interface GameConfig {
60
+ arenaSize: {
61
+ width: number;
62
+ height: number;
63
+ };
64
+ tickRate: number;
65
+ maxTicks: number;
66
+ }
67
+ /**
68
+ * Full game state passed to wizard.
69
+ */
70
+ interface GameState {
71
+ tick: number;
72
+ position: Position;
73
+ rotation: number;
74
+ health: number;
75
+ maxHealth: number;
76
+ state: WizardState['state'];
77
+ castingSpell?: 'missile' | 'shield' | 'blink';
78
+ castProgress?: number;
79
+ castDuration?: number;
80
+ channelingSpell?: 'shield';
81
+ channelDuration?: number;
82
+ gcdRemaining?: number;
83
+ blinkCooldown: number;
84
+ velocity: Velocity;
85
+ lastMissileConfig?: MissileConfig;
86
+ warmupMultiplier?: number;
87
+ enemies: WizardState[];
88
+ projectiles: ProjectileState[];
89
+ myProjectiles: ProjectileState[];
90
+ damageDealt: number;
91
+ damageTaken: number;
92
+ lastHitTick: number;
93
+ }
94
+ /**
95
+ * Actions returned by wizard each tick.
96
+ *
97
+ * Movement uses world-space coordinates:
98
+ * - x: +100 = right, -100 = left
99
+ * - y: +100 = down, -100 = up
100
+ * - Diagonal movement is normalized (magnitude capped at 100)
101
+ * - No rotation tracking - just output (x, y) direction
102
+ */
103
+ interface WizardActions {
104
+ /**
105
+ * Movement direction in world-space.
106
+ * Values are clamped to [-100, 100] range.
107
+ * Magnitude is normalized to max 100 for diagonal movement.
108
+ */
109
+ move: {
110
+ x: number;
111
+ y: number;
112
+ };
113
+ /**
114
+ * Start a new cast (only works if state === 'idle').
115
+ */
116
+ startCast?: {
117
+ spell: 'missile';
118
+ config: MissileConfig;
119
+ missileAI: MissileAIFunction;
120
+ direction?: number;
121
+ } | {
122
+ spell: 'shield';
123
+ } | {
124
+ spell: 'blink';
125
+ target: Position;
126
+ };
127
+ /**
128
+ * Cancel current cast or channel (works if casting or channeling).
129
+ */
130
+ cancel?: boolean;
131
+ /**
132
+ * Update aim direction while casting a missile (degrees).
133
+ * The missile fires in this direction at launch, allowing tracking during cast.
134
+ * Only applies while state === 'casting' and castingSpell === 'missile'.
135
+ */
136
+ aimDirection?: number;
137
+ }
138
+ /**
139
+ * Missile configuration.
140
+ */
141
+ interface MissileConfig {
142
+ damage: number;
143
+ speed: number;
144
+ turnRate: number;
145
+ duration: number;
146
+ }
147
+ /**
148
+ * Missile AI function type.
149
+ */
150
+ type MissileAIFunction = (props: {
151
+ missileState: ProjectileState;
152
+ worldState: GameState;
153
+ random: () => number;
154
+ }) => MissileActions;
155
+ /**
156
+ * Actions returned by missile each tick.
157
+ */
158
+ interface MissileActions {
159
+ turnToward?: Position;
160
+ }
161
+ /**
162
+ * Main wizard function type.
163
+ */
164
+ type WizardFunction = (props: {
165
+ state: GameState;
166
+ config: GameConfig;
167
+ random: () => number;
168
+ }) => WizardActions;
169
+
170
+ /**
171
+ * VIBEMANCER - GAME RULES
172
+ *
173
+ * This is the single source of truth for all game constants.
174
+ * All game logic imports from here. Read this to understand the game.
175
+ */
176
+
177
+ declare const TICKS_PER_SECOND = 100;
178
+ declare const TICK_DURATION_MS = 10;
179
+ declare const WIZARD_HEALTH = 60;
180
+ declare const WIZARD_RADIUS = 5;
181
+ declare const MOVEMENT_SPEED = 1;
182
+ declare const CASTING_MOVEMENT_MULT = 0.5;
183
+ declare const GCD_DURATION = 100;
184
+ declare const SHIELD_CAST_TIME = 20;
185
+ declare const SHIELD_MAX_BLOCK = 0.9;
186
+ declare const SHIELD_DECAY_PER_SECOND = 0.2;
187
+ declare const SHIELD_MIN_BLOCK = 0.3;
188
+ declare const BLINK_CAST_TIME = 10;
189
+ declare const BLINK_RANGE = 300;
190
+ declare const BLINK_MAX_COOLDOWN = 2000;
191
+ declare const BLINK_MIN_COOLDOWN = 100;
192
+ /** @deprecated Use BLINK_MAX_COOLDOWN */
193
+ declare const BLINK_COOLDOWN = 2000;
194
+ declare const ARENA_WIDTH = 800;
195
+ declare const ARENA_HEIGHT = 800;
196
+ declare const ARENA_SIZE = 800;
197
+ declare const SPAWN_DISTANCE = 600;
198
+ declare const MISSILE_MIN_DAMAGE = 1;
199
+ declare const MISSILE_MIN_SPEED = 1.5;
200
+ declare const MISSILE_MIN_DURATION = 10;
201
+ declare const MISSILE_MIN_CAST_TIME = 0.1;
202
+ declare const MISSILE_BASE_RADIUS = 2;
203
+ declare const MISSILE_DAMAGE_RADIUS_SCALE = 0.1;
204
+ /**
205
+ * Calculate missile hitbox radius based on damage.
206
+ */
207
+ declare function calculateMissileRadius(damage: number): number;
208
+ declare const MISSILE_BASE_CAST = 0.1;
209
+ declare const MISSILE_DAMAGE_SCALE = 0.226;
210
+ declare const MISSILE_DAMAGE_POWER: number;
211
+ declare const MISSILE_HOMING_COEFF = 0.12;
212
+ declare const MISSILE_TURN_DURATION_COEFF = 0.1;
213
+ declare const MISSILE_SPEED_DURATION_BASELINE = 1.5;
214
+ declare const MISSILE_SPEED_DURATION_COEFF = 0.025;
215
+ /**
216
+ * Maps turnRate to effective cost for the cast time formula.
217
+ * - Positive: linear (unchanged behavior)
218
+ * - Negative: diminishing returns via -|t|/(1+|t|), saturating at -1.
219
+ * turnRate -0.5 → -0.33, -1 → -0.5, -5 → -0.83, -10 → -0.91
220
+ * Big cast speed gains from 0 to -1, worthwhile to -5, negligible after.
221
+ * No hard floor — the curve naturally caps the benefit.
222
+ */
223
+ declare function effectiveTurnRateCost(turnRate: number): number;
224
+ /**
225
+ * Validate and sanitize missile config.
226
+ * Ensures all values meet minimum requirements (Lesson #9).
227
+ */
228
+ declare function validateMissileConfig(config: MissileConfig): MissileConfig;
229
+ /**
230
+ * Calculate missile cast time from config.
231
+ *
232
+ * Base formula:
233
+ * cast_time = 0.1
234
+ * + 0.226 × damage^(2/3)
235
+ * + 0.12 × effectiveTurnRateCost(turnRate)
236
+ * + 0.10 × (effectiveTurnRateCost(turnRate) × durationSeconds)
237
+ * + 0.025 × (speed × durationSeconds - 1.5)
238
+ *
239
+ * effectiveTurnRateCost: linear for positive, -ln(1+|t|) for negative (diminishing returns).
240
+ *
241
+ * If lastMissileConfig is a MissileConfig, applies warmup multiplier:
242
+ * - Similar to previous: up to 20% faster
243
+ * - Very different: up to 20% slower (switching penalty)
244
+ */
245
+ declare function calculateMissileCastTime(config: MissileConfig, lastMissileConfig?: MissileConfig | undefined | null): number;
246
+ declare const WARMUP_MAX_BONUS = 0.2;
247
+ declare const WARMUP_MAX_PENALTY = 0.2;
248
+ declare const WARMUP_SPEED_TOLERANCE = 3;
249
+ declare const WARMUP_TURN_TOLERANCE = 1;
250
+ declare const WARMUP_DURATION_TOLERANCE = 50;
251
+ /**
252
+ * Calculate how similar two missile configs are (0 to 1).
253
+ * Returns 1 for identical configs, 0 for very different ones.
254
+ * Used by the warmup system to determine cast time multiplier.
255
+ *
256
+ * Only compares speed, turnRate, and duration — these define the missile
257
+ * "style" (melee stab vs ranged homing vs fast snipe). Damage is excluded
258
+ * because varying power doesn't change playstyle.
259
+ */
260
+ declare function calculateMissileSimilarity(prev: MissileConfig | undefined, current: MissileConfig): number;
261
+ /**
262
+ * Calculate the cast time multiplier from the warmup system.
263
+ * Returns < 1 for bonus (faster), > 1 for penalty (slower), 1 for neutral.
264
+ *
265
+ * Similar to previous cast → multiplier approaches (1 - MAX_BONUS) = 0.80
266
+ * Very different from previous → multiplier approaches (1 + MAX_PENALTY) = 1.20
267
+ * No previous cast → full bonus (1 - MAX_BONUS) = 0.80
268
+ */
269
+ declare function calculateWarmupMultiplier(prev: MissileConfig | undefined, current: MissileConfig): number;
270
+ declare const MATCH_DURATION = 30000;
271
+ declare const MAX_HEALTH = 60;
272
+ declare const COLLISION_RADIUS = 5;
273
+ declare const MOVE_SPEED = 1;
274
+ declare const MISSILE_RADIUS_PER_DAMAGE = 0.1;
275
+ declare const SHIELD_MAX_STRENGTH = 0.9;
276
+ declare const SHIELD_MIN_STRENGTH = 0.3;
277
+ declare const SHIELD_DECAY_RATE = 0.2;
278
+ declare const BLINK_MAX_RANGE = 300;
279
+ /**
280
+ * Calculate blink cooldown based on distance traveled.
281
+ * Short blinks get short cooldowns, full-range blinks get the maximum.
282
+ */
283
+ declare function calculateBlinkCooldown(distance: number): number;
284
+ declare const ARENA_WATER_BUFFER = 200;
285
+
286
+ /**
287
+ * Engine version — milliseconds since the Unix epoch.
288
+ *
289
+ * Bumped automatically by `scripts/update-engine-version.mjs` on every build.
290
+ * The same value is propagated to `packages/functions/src/engine-version.generated.ts`
291
+ * so cloud functions and the core engine always agree on a single version per deploy.
292
+ *
293
+ * Used to gate spectator replays: a recorded match can only be re-simulated when
294
+ * the runtime engine version matches the version that produced the match.
295
+ */
296
+ declare const ENGINE_VERSION = 1777556890699;
297
+
298
+ interface InternalWizardState extends WizardState {
299
+ missileConfig?: MissileConfig;
300
+ missileAI?: MissileAIFunction;
301
+ blinkTarget?: {
302
+ x: number;
303
+ y: number;
304
+ };
305
+ damageDealt: number;
306
+ damageTaken: number;
307
+ lastHitTick: number;
308
+ }
309
+ /**
310
+ * Initialize a new match state.
311
+ */
312
+ declare function createInitialState(_seed: number, spawnDist?: number): GameState;
313
+ /**
314
+ * Process one game tick.
315
+ */
316
+ declare function tick(currentTick: number, wizard1AI: WizardFunction, wizard2AI: WizardFunction, config: GameConfig, wizards: InternalWizardState[], projectiles: ProjectileState[], missileAIs: Map<string, MissileAIFunction>, matchSeed: number): {
317
+ nextTick: number;
318
+ wizards: InternalWizardState[];
319
+ projectiles: ProjectileState[];
320
+ errors: BotError[];
321
+ };
322
+ /**
323
+ * Get the game state from a specific player's perspective.
324
+ * Returns a deep clone to prevent mutation of history entries.
325
+ * Used for history recording where independent snapshots are needed.
326
+ */
327
+ declare function getPlayerState(playerIndex: number, wizards: InternalWizardState[], projectiles: ProjectileState[], tick: number): GameState;
328
+ /** Winner of a single match: a wizard ID, 'draw' (simultaneous kill), or null (timeout). */
329
+ type MatchWinner = 'wizard-1' | 'wizard-2' | 'draw' | null;
330
+ /** Winner of a fight (aggregate): a wizard ID or 'draw'. Never null. */
331
+ type FightWinner = 'wizard-1' | 'wizard-2' | 'draw';
332
+ /**
333
+ * Result of a simulation.
334
+ */
335
+ /** A runtime error captured from a bot or missile AI function. */
336
+ interface BotError {
337
+ tick: number;
338
+ entityId: string;
339
+ message: string;
340
+ }
341
+ interface SimulateResult {
342
+ /** 'wizard-1'/'wizard-2' = killed opponent, 'draw' = simultaneous kill, null = timeout */
343
+ winner: MatchWinner;
344
+ ticks: number;
345
+ finalState: GameState;
346
+ history: GameState[];
347
+ /** Runtime errors thrown by bot or missile AI functions (empty if no errors). */
348
+ errors: BotError[];
349
+ }
350
+ /**
351
+ * Result of a fight (best-of-5 at different spawn distances).
352
+ */
353
+ interface FightResult {
354
+ wizard1Wins: number;
355
+ wizard2Wins: number;
356
+ draws: number;
357
+ /** Winner of the fight: 'wizard-1', 'wizard-2', or 'draw' (never null) */
358
+ winner: FightWinner;
359
+ /**
360
+ * Individual match results (one per spawn distance, non-swapped only).
361
+ * Used for visual playback in the web viewer. Scoring includes both sides.
362
+ */
363
+ matches: SimulateResult[];
364
+ }
365
+ /** Spawn distances for the 5 matches in a fight (creates butterfly effect variation) */
366
+ declare const FIGHT_SPAWN_DISTANCES: number[];
367
+ /**
368
+ * Run a fight: 10 matches (5 spawn distances × 2 sides) between two bots.
369
+ * Each spawn distance is played twice — once with each bot on each side —
370
+ * to ensure results are independent of starting position.
371
+ *
372
+ * The `matches` array contains only the 5 non-swapped matches (for visual playback).
373
+ * The scoring aggregates (wizard1Wins, wizard2Wins, draws) include all 10 matches.
374
+ *
375
+ * This is the standard way to determine who wins a matchup.
376
+ * Used by both the tournament system and the visual UI.
377
+ */
378
+ declare function fight(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: {
379
+ seed?: number;
380
+ maxTicks?: number;
381
+ }): FightResult;
382
+ /**
383
+ * Run a full match simulation.
384
+ *
385
+ * @param options.skipHistory - When true, skips recording per-tick history snapshots.
386
+ * This dramatically improves performance (no deep cloning per tick) and is used
387
+ * by the optimizer and fight() scoring. The returned history array will be empty
388
+ * and finalState will still be populated.
389
+ */
390
+ declare function simulate(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: {
391
+ maxTicks?: number;
392
+ seed?: number;
393
+ spawnDistance?: number;
394
+ skipHistory?: boolean;
395
+ }): SimulateResult;
396
+
397
+ /**
398
+ * VIBEMANCER - HOOKS API TYPES
399
+ *
400
+ * Types for the hooks-based bot API.
401
+ *
402
+ * UNITS REFERENCE (100 ticks = 1 second):
403
+ * Position: absolute world coordinates, 0-800 on each axis (800×800 arena)
404
+ * Velocity: units per tick on each axis (player max speed = 1 u/t)
405
+ * Health: hit points (max 60)
406
+ * Ticks: game ticks (10ms each, 100/sec). Divide by 100 for seconds.
407
+ * Angles: degrees (0°=right, 90°=down, 180°=left, 270°=up)
408
+ */
409
+
410
+ /**
411
+ * Enemy wizard state as seen by your bot.
412
+ *
413
+ * Note: you cannot see the enemy's missile configs, cooldown timers, or
414
+ * damage history — only what's visible on the battlefield.
415
+ */
416
+ interface EnemyState {
417
+ /** Enemy position in world coordinates (0-800). */
418
+ position: Position;
419
+ /** Enemy velocity in units/tick. */
420
+ velocity: Velocity;
421
+ /** Enemy current HP (0-60). */
422
+ health: number;
423
+ /** Enemy status: 'idle', 'casting', 'channeling' (shield), or 'gcd_locked'. */
424
+ status: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
425
+ /** Which spell enemy is casting, or null. */
426
+ castingSpell: 'missile' | 'shield' | 'blink' | null;
427
+ /** Enemy shield block multiplier (0 if not shielding, 0.3-0.9 if shielding). */
428
+ shieldStrength: number;
429
+ }
430
+ /**
431
+ * Pre-computed analysis of an incoming enemy projectile.
432
+ *
433
+ * All timing values are in ticks (100 ticks = 1 second).
434
+ * Dodge directions are relative to missile heading, not world axes.
435
+ */
436
+ interface AnalyzedThreat {
437
+ /** Unique projectile ID. */
438
+ id: string;
439
+ /** Raw projectile state (position, rotation in degrees, speed in u/t, turnRate, remainingTicks). */
440
+ projectile: ProjectileState;
441
+ /** Ticks until missile hits your current position. Infinity if predicted to miss. */
442
+ ticksToImpact: number;
443
+ /** Whether the missile will hit if you stand still. */
444
+ willHit: boolean;
445
+ /** Whether strafing left (perpendicular to missile heading) avoids it. */
446
+ canDodgeLeft: boolean;
447
+ /** Whether strafing right (perpendicular to missile heading) avoids it. */
448
+ canDodgeRight: boolean;
449
+ /** Whether moving directly away from the missile avoids it. */
450
+ canOutrun: boolean;
451
+ /** Optimal dodge direction as a unit vector {x, y}, or null if undodgeable. */
452
+ bestDodgeDirection: Position | null;
453
+ /** Whether you can channel shield before the missile arrives. */
454
+ canBlockInTime: boolean;
455
+ /** Ticks from now when you should START channeling shield to block in time. */
456
+ ticksToStartShield: number;
457
+ }
458
+ /**
459
+ * Final action that can be returned from a bot.
460
+ * Cannot be further chained.
461
+ */
462
+ interface FinalAction {
463
+ /** Internal: extract the WizardActions */
464
+ readonly _toAction: () => WizardActions;
465
+ }
466
+ /**
467
+ * Action builder that allows chaining .move() for simultaneous movement.
468
+ * Returned by shield(), missile(), and cancel().
469
+ */
470
+ interface ActionBuilder extends FinalAction {
471
+ /**
472
+ * Add movement to this action (e.g., move while casting).
473
+ * Direction vector, not absolute position. Auto-normalized.
474
+ * Positive X = right, positive Y = down.
475
+ */
476
+ move(x: number, y: number): FinalAction;
477
+ }
478
+ /**
479
+ * Bot function type for the hooks API.
480
+ * Called every tick. Read state with hooks, return an action.
481
+ */
482
+ type BotFunction = () => FinalAction;
483
+ /**
484
+ * Internal context for game state hooks.
485
+ */
486
+ interface BotContext {
487
+ entityId: string;
488
+ tick: number;
489
+ position: Position;
490
+ velocity: Velocity;
491
+ health: number;
492
+ maxHealth: number;
493
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
494
+ castingSpell?: 'missile' | 'shield' | 'blink';
495
+ castProgress?: number;
496
+ castDuration?: number;
497
+ channelingSpell?: 'shield';
498
+ channelDuration?: number;
499
+ gcdRemaining?: number;
500
+ blinkCooldown: number;
501
+ enemies: Array<{
502
+ id: string;
503
+ position: Position;
504
+ velocity: Velocity;
505
+ health: number;
506
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
507
+ castingSpell?: 'missile' | 'shield' | 'blink';
508
+ channelingSpell?: 'shield';
509
+ channelDuration?: number;
510
+ }>;
511
+ projectiles: ProjectileState[];
512
+ myProjectiles: ProjectileState[];
513
+ arenaWidth: number;
514
+ arenaHeight: number;
515
+ damageDealt: number;
516
+ damageTaken: number;
517
+ lastHitTick: number;
518
+ }
519
+
520
+ /**
521
+ * VIBEMANCER - HOOKS RUNTIME
522
+ *
523
+ * This file implements a minimal React-like hooks runtime for AI programming.
524
+ * It supports useState, useEffect, useMemo, useRef, and useParam with entity isolation.
525
+ *
526
+ * RULES OF HOOKS (same as React):
527
+ * - Hooks must be called at the top level of the bot function
528
+ * - Hooks must be called in the same order every tick
529
+ * - Hooks must NOT be called conditionally
530
+ *
531
+ * Violating these rules throws an error (detected via hook index validation).
532
+ */
533
+
534
+ interface HookState {
535
+ values: unknown[];
536
+ effects: {
537
+ callback: () => void | (() => void);
538
+ deps?: unknown[];
539
+ cleanup?: () => void;
540
+ }[];
541
+ memos: {
542
+ value: unknown;
543
+ deps?: unknown[];
544
+ }[];
545
+ /** Type of each hook call in order (for validation). */
546
+ hookTypes: string[];
547
+ /** Total hooks called on first successful tick. */
548
+ hookCount: number;
549
+ /** Whether the first tick has completed successfully (hook pattern established). */
550
+ initialized: boolean;
551
+ }
552
+ /**
553
+ * Validate a hook call and return its sequential index.
554
+ * Ensures hooks are called in the same order every tick.
555
+ *
556
+ * On the first tick: records the hook type at this index.
557
+ * On subsequent ticks: validates the hook type matches.
558
+ *
559
+ * @param type - The hook type name (e.g., 'useState', 'useEffect', 'useParam')
560
+ * @returns The sequential hook index
561
+ * @throws If called outside runWithHooks or if hook order changed
562
+ */
563
+ declare function validateHookCall(type: string): number;
564
+ /**
565
+ * Run a function with a specific entity's hook context.
566
+ */
567
+ declare function runWithHooks<T>(entityId: string, fn: () => T): T;
568
+ /**
569
+ * Run a bot function with full context (game state + persistence hooks).
570
+ * Use this when you need to set BOTH the entity ID and the game context.
571
+ */
572
+ declare function runBotWithContext<T>(entityId: string, context: BotContext, fn: () => T): T;
573
+ /**
574
+ * Run a function with game state context only, preserving the current entity ID.
575
+ * Use this inside wrapNewBot where the entity ID is already set by the outer runWithHooks.
576
+ */
577
+ declare function withBotContext<T>(context: BotContext, fn: () => T): T;
578
+ /**
579
+ * Get the current bot context. Throws if called outside bot execution.
580
+ */
581
+ declare function getBotContext(): BotContext;
582
+ /**
583
+ * Persist state between ticks.
584
+ */
585
+ declare function useState<T>(initialValue: T | (() => T)): [T, (newValue: T | ((prev: T) => T)) => void];
586
+ /**
587
+ * React to state changes.
588
+ */
589
+ declare function useEffect(callback: () => void | (() => void), deps?: unknown[]): void;
590
+ /**
591
+ * Memoize expensive calculations.
592
+ */
593
+ declare function useMemo<T>(factory: () => T, deps?: unknown[]): T;
594
+ /**
595
+ * Mutable reference that persists across ticks.
596
+ * Unlike useState, mutations don't need a setter - just modify .current directly.
597
+ */
598
+ interface RefObject<T> {
599
+ current: T;
600
+ }
601
+ declare function useRef<T>(initialValue: T): RefObject<T>;
602
+ /**
603
+ * Clear hook state for an entity (e.g., when it dies).
604
+ */
605
+ declare function clearHooks(entityId: string): void;
606
+ /**
607
+ * Reset all hook states (e.g., when a match restarts).
608
+ */
609
+ declare function resetAllHooks(): void;
610
+
611
+ /**
612
+ * Move a wizard based on world-space input direction.
613
+ *
614
+ * Movement model (from design doc):
615
+ * - x: +100 = right, -100 = left
616
+ * - y: +100 = down, -100 = up
617
+ * - Values are clamped to [-100, 100]
618
+ * - Diagonal movement is normalized (magnitude capped at 100)
619
+ * - No rotation tracking - just output (x, y) direction
620
+ */
621
+ declare function moveWizard(wizard: WizardState, move: {
622
+ x: number;
623
+ y: number;
624
+ }, deltaTicks: number): Position;
625
+ /**
626
+ * Move a projectile in its current rotation direction.
627
+ */
628
+ declare function moveProjectile(projectile: ProjectileState, deltaTicks: number): Position;
629
+ /**
630
+ * Clamp a position to the arena boundaries.
631
+ */
632
+ declare function clampToArena(position: Position, radius: number): Position;
633
+ /**
634
+ * Resolve body collision between two wizards.
635
+ * Pushes both apart equally so they don't overlap. Neither is blocked — they just can't stack.
636
+ * Iterates until stable: wizard push → wall clamp → re-check overlap → repeat.
637
+ */
638
+ declare function resolveWizardCollision(wizard1: WizardState, wizard2: WizardState): void;
639
+ /**
640
+ * Perform swept circle collision detection between a moving point (projectile) and a stationary circle (wizard).
641
+ * Returns true if a collision occurred during the movement from oldPos to newPos.
642
+ */
643
+ declare function sweptCircleCollision(oldPos: Position, newPos: Position, radius: number, targetPos: Position, targetRadius: number): boolean;
644
+
645
+ /**
646
+ * Start casting a spell.
647
+ * For missiles, applies warmup system (bonus for similar, penalty for switching).
648
+ */
649
+ declare function startCast(wizard: WizardState, spell: 'missile' | 'shield' | 'blink', config?: MissileConfig): void;
650
+ /**
651
+ * Cancel the current cast.
652
+ */
653
+ declare function cancelCast(wizard: WizardState): void;
654
+ /**
655
+ * Complete the current cast and trigger the spell effect.
656
+ */
657
+ declare function completeCast(wizard: WizardState): void;
658
+ /**
659
+ * Update the shield channel state.
660
+ */
661
+ declare function updateShield(wizard: WizardState, deltaTicks: number): void;
662
+ /**
663
+ * Calculate the current block percentage of a shield based on channel duration.
664
+ */
665
+ declare function calculateShieldBlock(channelDurationTicks: number): number;
666
+ /**
667
+ * Apply damage to a wizard, considering shield mitigation.
668
+ *
669
+ * Shield blocks a percentage of damage based on channel duration:
670
+ * - Fresh shield (0s): 90% block → 10% damage through
671
+ * - Decayed shield: block % decreases over time (20%/sec)
672
+ * - Minimum: 30% block → 70% damage through
673
+ *
674
+ * (Design doc lines 196-212)
675
+ */
676
+ declare function applyDamage(wizard: WizardState, damage: number, _projectile?: ProjectileState): number;
677
+
678
+ /**
679
+ * VIBEMANCER - MANUAL MATCH
680
+ *
681
+ * Tick-by-tick match runner used by manual play mode. Wraps the same
682
+ * `tick()` primitive that `simulate()` uses, so stepping forward
683
+ * produces the same trajectory as a batched `simulate()` with the
684
+ * same seed.
685
+ *
686
+ * Extra capabilities over `simulate()`:
687
+ * - step(N) advances N ticks at a time (default 1) — caller controls pacing
688
+ * - replaceMissileAI(id, ai) hot-swaps a missile's AI mid-flight (used by
689
+ * the missile-hijack feature in manual play)
690
+ * - setInvincible(wizardIndex, on) toggles damage immunity per wizard
691
+ */
692
+
693
+ interface ManualMatchOptions {
694
+ seed?: number;
695
+ spawnDistance?: number;
696
+ maxTicks?: number;
697
+ }
698
+ interface StepResult {
699
+ gameState: GameState;
700
+ errors: BotError[];
701
+ done: boolean;
702
+ }
703
+ declare class ManualMatch {
704
+ private readonly wizard1AI;
705
+ private readonly wizard2AI;
706
+ private readonly seed;
707
+ private readonly maxTicks;
708
+ private readonly config;
709
+ private wizards;
710
+ private projectiles;
711
+ private missileAIs;
712
+ /** First-replacement originals for hijacked missiles. Used by restoreMissileAI. */
713
+ private originalMissileAIs;
714
+ private currentTick;
715
+ private done;
716
+ private allErrors;
717
+ private history;
718
+ constructor(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: ManualMatchOptions);
719
+ /**
720
+ * Advance the match by `count` ticks (default 1). Stops early if the
721
+ * match completes mid-batch.
722
+ */
723
+ step(count?: number): StepResult;
724
+ /**
725
+ * Hot-swap a missile's AI function. Used by the missile-hijack feature
726
+ * in manual play. The first replacement remembers the original AI so
727
+ * `restoreMissileAI` can put it back. Subsequent replacements update
728
+ * the active AI but leave the remembered original alone.
729
+ *
730
+ * No-op if the projectile id doesn't exist.
731
+ */
732
+ replaceMissileAI(projectileId: string, ai: MissileAIFunction): void;
733
+ /**
734
+ * Restore a previously hijacked missile's original AI function.
735
+ * No-op if the projectile id doesn't exist or was never hijacked.
736
+ */
737
+ restoreMissileAI(projectileId: string): void;
738
+ /**
739
+ * Set the invincibility flag for a wizard. Invincible wizards take 0
740
+ * damage from all sources.
741
+ */
742
+ setInvincible(wizardIndex: 0 | 1, on: boolean): void;
743
+ /**
744
+ * Get the current game state from wizard-1's perspective.
745
+ * Returned object is a deep clone — safe to mutate.
746
+ */
747
+ getGameState(): GameState;
748
+ getCurrentTick(): number;
749
+ isComplete(): {
750
+ done: boolean;
751
+ winner: MatchWinner;
752
+ };
753
+ getResult(): SimulateResult;
754
+ dispose(): void;
755
+ private computeWinner;
756
+ }
757
+
758
+ /**
759
+ * VIBEMANCER - MISSILE TEMPLATES
760
+ *
761
+ * Reusable missile config + AI factories for manual play and bot examples.
762
+ * Each factory clamps its inputs to rules.ts minimums and returns a pure
763
+ * AI function that's safe to register with the engine.
764
+ */
765
+
766
+ interface BaseParams {
767
+ damage: number;
768
+ speed: number;
769
+ duration: number;
770
+ }
771
+ interface TurningParams extends BaseParams {
772
+ turnRate: number;
773
+ }
774
+ type StraightParams = BaseParams;
775
+ type HomingParams = TurningParams;
776
+ type AntiHomingParams = TurningParams;
777
+ interface SpiralParams extends BaseParams {
778
+ spiralRadius: number;
779
+ spiralFreq: number;
780
+ }
781
+ interface SeekerParams extends TurningParams {
782
+ minLockDistance: number;
783
+ }
784
+ interface MissileTemplate {
785
+ config: MissileConfig;
786
+ ai: MissileAIFunction;
787
+ }
788
+ /**
789
+ * Fire-and-forget missile. No steering — flies in a straight line.
790
+ */
791
+ declare function straightMissile(p: StraightParams): MissileTemplate;
792
+ /**
793
+ * Homing missile. Steers toward the enemy each tick.
794
+ */
795
+ declare function homingMissile(p: HomingParams): MissileTemplate;
796
+ /**
797
+ * Anti-homing missile. Steers AWAY from the enemy — useful as a feint or
798
+ * area-denial pattern.
799
+ */
800
+ declare function antiHomingMissile(p: AntiHomingParams): MissileTemplate;
801
+ /**
802
+ * Spiral missile. Continuously orbits its current heading while advancing.
803
+ * Uses missileState.remainingTicks as a deterministic phase counter so the
804
+ * AI is fully pure (no closure state).
805
+ */
806
+ declare function spiralMissile(p: SpiralParams): MissileTemplate;
807
+ /**
808
+ * Seeker missile. Homes toward the enemy, but only when farther away than
809
+ * minLockDistance — closer than that, the missile coasts straight (so it
810
+ * doesn't whirl around a target it's about to hit).
811
+ */
812
+ declare function seekerMissile(p: SeekerParams): MissileTemplate;
813
+
814
+ /**
815
+ * Calculate the distance between two points.
816
+ */
817
+ declare function distanceTo(a: Position, b: Position): number;
818
+ /**
819
+ * Check if two points are within a certain range of each other.
820
+ */
821
+ declare function inRange(a: Position, b: Position, range: number): boolean;
822
+
823
+ /**
824
+ * Calculate the angle from one point to another in degrees.
825
+ * 0° = right, 90° = down, 180° = left, 270° = up.
826
+ */
827
+ declare function angleTo(from: Position, to: Position): number;
828
+ /**
829
+ * Normalize an angle to the 0-360 range.
830
+ */
831
+ declare function normalizeAngle(angle: number): number;
832
+ /**
833
+ * Calculate the shortest difference between two angles (-180 to +180).
834
+ */
835
+ declare function angleDiff(angleA: number, angleB: number): number;
836
+ /**
837
+ * Check if an angle is within a certain range of a target angle.
838
+ */
839
+ declare function angleInRange(angle: number, target: number, range: number): boolean;
840
+
841
+ /**
842
+ * Get the position after moving a certain distance in a direction.
843
+ */
844
+ declare function moveInDirection(position: Position, angle: number, distance: number): Position;
845
+ /**
846
+ * Predict the position after N ticks given current velocity.
847
+ */
848
+ declare function predictPosition(position: Position, velocity: Velocity, ticks: number): Position;
849
+ /**
850
+ * Calculate the intercept angle for a target moving at a certain velocity.
851
+ * Returns null if no intercept solution exists.
852
+ */
853
+ declare function interceptAngle(shooterPosition: Position, targetPosition: Position, targetVelocity: Velocity, projectileSpeed: number): number | null;
854
+
855
+ /**
856
+ * Find the nearest entity from a list.
857
+ */
858
+ declare function findNearest<T extends {
859
+ position: Position;
860
+ }>(from: Position, entities: T[]): T | null;
861
+ /**
862
+ * Find all entities within a certain range.
863
+ */
864
+ declare function findInRange<T extends {
865
+ position: Position;
866
+ }>(from: Position, entities: T[], range: number): T[];
867
+ /**
868
+ * Sort entities by distance (closest first).
869
+ */
870
+ declare function sortByDistance<T extends {
871
+ position: Position;
872
+ }>(from: Position, entities: T[]): T[];
873
+
874
+ /**
875
+ * Seeded PRNG utilities for deterministic randomness.
876
+ *
877
+ * Each entity (wizard, missile) gets its own random sequence that:
878
+ * - Is deterministic: same seed = same sequence
879
+ * - Is isolated: one entity's calls don't affect another's
880
+ * - Advances state: each call produces a different value
881
+ */
882
+ /**
883
+ * Combine two seeds into one using a simple hash.
884
+ */
885
+ declare function hashCombine(a: number, b: number): number;
886
+ /**
887
+ * Advance the random state using a Linear Congruential Generator.
888
+ * Parameters from glibc (widely tested).
889
+ */
890
+ declare function nextRandom(state: number): number;
891
+ /**
892
+ * Create a seeded random number generator.
893
+ * Returns a function that produces values in [0, 1) and advances internal state.
894
+ */
895
+ declare function createRandom(seed: number): () => number;
896
+ /**
897
+ * Create a deterministic seed for an entity based on match seed, entity ID, and tick.
898
+ * This ensures reproducibility: same match + same entity + same tick = same random sequence.
899
+ */
900
+ declare function createEntitySeed(matchSeed: number, entityId: string, tick: number): number;
901
+
902
+ /**
903
+ * VIBEMANCER - SPATIAL UTILITIES
904
+ *
905
+ * Direction vectors and arena bounds utilities.
906
+ */
907
+
908
+ /**
909
+ * Normalize a vector to unit length.
910
+ * Returns {x: 0, y: 0} for zero-length vectors.
911
+ */
912
+ declare function normalize(vector: Position): Position;
913
+ /**
914
+ * Get normalized direction vector from one position toward another.
915
+ * Returns {x: 0, y: 0} if positions are identical.
916
+ */
917
+ declare function directionTo(from: Position, to: Position): Position;
918
+ /**
919
+ * Get normalized direction vector from one position away from another.
920
+ * Returns {x: 0, y: 0} if positions are identical.
921
+ */
922
+ declare function directionAway(from: Position, to: Position): Position;
923
+ /**
924
+ * Clamp a position to valid arena bounds.
925
+ * Note: For wizard-specific clamping with radius, use clampToArena from physics.ts
926
+ */
927
+ declare function clampPositionToArena(position: Position): Position;
928
+ /**
929
+ * Get the length/magnitude of a vector.
930
+ */
931
+ declare function magnitude(vector: Position): number;
932
+
933
+ /**
934
+ * VIBEMANCER - COMBAT UTILITIES
935
+ *
936
+ * Utilities for combat calculations.
937
+ */
938
+
939
+ /**
940
+ * Get cast time in ticks for a missile configuration.
941
+ * Applies the same clamps/validation as the engine before calculating,
942
+ * so the result matches the actual cast time that will be used in-game.
943
+ *
944
+ * If lastMissileConfig is provided, includes warmup multiplier.
945
+ * Pass undefined for first cast (full warmup) or null for base time only.
946
+ */
947
+ declare function getMissileCastTime(config: MissileConfig, lastMissileConfig?: MissileConfig | null): number;
948
+ /**
949
+ * Calculate the position to aim at to hit a moving target.
950
+ * Returns the intercept point where a missile would hit the target.
951
+ *
952
+ * @param targetPos - Current target position
953
+ * @param targetVel - Target velocity (units per tick)
954
+ * @param missileSpeed - Missile speed (units per tick)
955
+ * @param myPos - Shooter position
956
+ * @returns The position to aim at
957
+ */
958
+ declare function getLeadPosition(targetPos: Position, targetVel: Velocity, missileSpeed: number, myPos: Position): Position;
959
+ /**
960
+ * Calculate optimal missile configuration based on target behavior.
961
+ */
962
+ declare function getAdaptiveMissileConfig(targetVelocity: Position, distance: number): {
963
+ speed: number;
964
+ turnRate: number;
965
+ damage: number;
966
+ duration: number;
967
+ };
968
+ /**
969
+ * Given a cast-time budget (in ticks) and a target distance, find the best
970
+ * missile config that fits. Maximizes damage while ensuring the missile
971
+ * can reach the target and finishes casting in time.
972
+ *
973
+ * Returns null if no useful missile fits in the budget.
974
+ *
975
+ * How it works: tries several speed/turnRate templates. For each, calculates
976
+ * the minimum duration to reach `distance`, then solves the cast-time formula
977
+ * for the maximum damage that fits within `budgetTicks`.
978
+ *
979
+ * If `lastMissileConfig` is provided, accounts for warmup bonus: similar
980
+ * missiles cast faster, so more damage can fit in the same budget.
981
+ */
982
+ declare function fitMissileToBudget(budgetTicks: number, distance: number, options?: {
983
+ minTurnRate?: number;
984
+ maxDamage?: number;
985
+ lastMissileConfig?: MissileConfig;
986
+ }): MissileConfig | null;
987
+
988
+ /**
989
+ * Bot: TargetDummy
990
+ *
991
+ * BEHAVIOR: Does absolutely nothing. No movement, no spells, no AI.
992
+ *
993
+ * NAMING RATIONALE: "Target Dummy" is universal MMO player vocabulary for the
994
+ * practice objects found in capital cities. Every WoW/FFXIV player has beaten
995
+ * on a target dummy to test DPS rotations. That's exactly what this bot is —
996
+ * a punching bag for testing missile mechanics and baseline damage output.
997
+ * Nobody calls them "training dummies"; the player term is always "target dummy."
998
+ *
999
+ * STANDALONE — no tier progression. It's a test fixture, not a combatant.
1000
+ */
1001
+ declare const TargetDummy: WizardFunction;
1002
+
1003
+ /**
1004
+ * Bot: Rookie
1005
+ *
1006
+ * BEHAVIOR: Stands perfectly still and fires straight (non-homing) missiles at
1007
+ * the enemy. No movement, no dodging, no shielding. Knows one spell and uses
1008
+ * it on cooldown. The wizard equivalent of an FPS player who stands in the open
1009
+ * and holds left-click.
1010
+ *
1011
+ * NAMING RATIONALE: "Rookie" is the universal term for a first-timer who barely
1012
+ * knows what they're doing. This bot is a day-one player who learned how to cast
1013
+ * missile and nothing else. No movement, no defense, just raw "I press the button."
1014
+ * We considered "Noob" (more accurate) but Rookie is less abrasive while conveying
1015
+ * the same thing — a beginner who doesn't know any better.
1016
+ *
1017
+ * STANDALONE — no tier progression. Rookies either learn to play a real class
1018
+ * or quit. This bot represents the rock-bottom of "at least it shoots."
1019
+ */
1020
+ declare const Rookie: WizardFunction;
1021
+
1022
+ /**
1023
+ * Bot: Critter
1024
+ *
1025
+ * BEHAVIOR: Picks random valid actions each tick — random movement, random spells,
1026
+ * random missile configs, random directions. Occasionally cancels its own casts.
1027
+ * Uses engine-provided seeded random for deterministic behavior. Useful for
1028
+ * finding edge cases in the engine, but completely useless in combat.
1029
+ *
1030
+ * NAMING RATIONALE: In WoW, critters are the 1-HP ambient mobs (rabbits, squirrels,
1031
+ * prairie dogs) that wander around doing nothing useful and die to literally anything.
1032
+ * This bot is the wizard equivalent — it flails around randomly and gets destroyed by
1033
+ * anyone with a plan. The word "Critter" immediately tells any gamer "this thing is
1034
+ * helpless and exists only to fill space."
1035
+ *
1036
+ * STANDALONE — no tier progression. Critters don't level up. However, a future
1037
+ * "Hogger" bot could be an elite critter: same chaotic spirit but actually dangerous
1038
+ * (like the famous WoW elite that wipes unprepared lowbies).
1039
+ */
1040
+ declare const Critter: WizardFunction;
1041
+
1042
+ /**
1043
+ * Bot: Hogger
1044
+ *
1045
+ * BEHAVIOR: The elite critter. Chaotic and unpredictable but genuinely dangerous.
1046
+ * Randomly varies missile configs each cast (damage 7-15, speed 3-8, random homing),
1047
+ * moves erratically but still somewhat toward/away from the enemy, shields when
1048
+ * in real danger, and blinks unpredictably. The randomness makes Hogger hard to
1049
+ * predict — you never know if the next missile will be a slow tracker or a fast
1050
+ * snipe. Unlike Critter's pure randomness, Hogger has enough combat awareness
1051
+ * to actually win fights.
1052
+ *
1053
+ * NAMING RATIONALE: In WoW, Hogger is the iconic level 11 elite gnoll in Elwynn
1054
+ * Forest who infamously kills unprepared lowbies. He's technically a basic mob
1055
+ * but hits way harder than expected. This bot is the Critter that learned to
1056
+ * fight — still chaotic, still a bit dumb, but capable of ending you if you
1057
+ * underestimate it. "Hogger" is one of WoW's most recognizable references and
1058
+ * perfectly captures "deceptively dangerous chaos."
1059
+ *
1060
+ * STANDALONE — no tier progression. There's only one Hogger.
1061
+ */
1062
+ declare const Hogger: WizardFunction;
1063
+
1064
+ /**
1065
+ * Bot: Doombringer
1066
+ *
1067
+ * BEHAVIOR: Fires a single maximum-damage homing missile with infinite budget.
1068
+ * No damage cap — goes for the biggest possible hit. Exists as a benchmark to
1069
+ * demonstrate why lower-damage + shield play is superior. Has basic shield
1070
+ * defense but no sophisticated tactics. One fat cast, one fat hit.
1071
+ *
1072
+ * STANDALONE — no tier progression. Benchmark/test bot.
1073
+ */
1074
+ declare const Doombringer: WizardFunction;
1075
+
1076
+ declare const Turtle: WizardFunction;
1077
+
1078
+ /**
1079
+ * Bot: Sentinel
1080
+ *
1081
+ * BEHAVIOR: Stationary tank with last-moment shielding AND two-tier offense.
1082
+ * Like Turtle, never moves and shields at the last moment. Unlike Turtle,
1083
+ * fires bigger missiles (damage 20) when the safe window is large enough,
1084
+ * falling back to Turtle's fast missile (damage 12) when pressed.
1085
+ *
1086
+ * PROGRESSION LINE: Turtle → Sentinel → Golem
1087
+ * - Turtle (tier 1): Stationary, fixed missiles, reactive shield timing
1088
+ * - Sentinel (tier 2): Stationary, two-tier offense (big + fast missiles)
1089
+ * - Golem (tier 3): Immovable fortress, perfect shield timing
1090
+ *
1091
+ * TIER: 2 (enhanced Turtle)
1092
+ */
1093
+ declare const Sentinel: WizardFunction;
1094
+
1095
+ /**
1096
+ * Bot: Golem
1097
+ *
1098
+ * BEHAVIOR: Stationary fortress with perfect shield timing and devastating
1099
+ * counterattacks during enemy vulnerability windows. Reads enemy cast/GCD
1100
+ * state to time punish missiles that land when the enemy can't shield.
1101
+ * Handles multi-missile volleys by holding shield through consecutive impacts.
1102
+ * Uses progressive cast-cancel thresholds for optimal damage trading.
1103
+ *
1104
+ * KEY IMPROVEMENTS OVER SENTINEL:
1105
+ * - Counterattack punish: fires during enemy cast/GCD recovery
1106
+ * - Multi-threat volley awareness: holds shield through consecutive hits
1107
+ * - Progressive cast-cancel: graduated damage thresholds
1108
+ * - Perfect shield timing: uses ticksToStartShield precisely
1109
+ *
1110
+ * PROGRESSION LINE: Turtle → Sentinel → Golem
1111
+ * TIER: 3 (elite Defensive line)
1112
+ */
1113
+ declare const Golem: WizardFunction;
1114
+
1115
+ /**
1116
+ * Bot: Shadowblade
1117
+ *
1118
+ * BEHAVIOR: Melee assassin. Blinks to the enemy, then lands devastating point-blank
1119
+ * stab attacks (15 damage, 30u range, ~60 tick cast = 2-hit kill). Runs directly
1120
+ * at the enemy with minimal strafe, shields undodgeable threats. The entire
1121
+ * strategy is: get close, stab, kill. Simple and brutal.
1122
+ *
1123
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
1124
+ * - Shadowblade (tier 1): Offensive blink, melee stabs, basic shield
1125
+ * - Nightblade (tier 2): + missile-aware blinks, adaptive stabs, timed defense
1126
+ * - Voidblade (tier 3): Future — perfect assassination timing, inescapable engages
1127
+ *
1128
+ * TIER: 1 (base)
1129
+ */
1130
+ declare const Shadowblade: WizardFunction;
1131
+
1132
+ /**
1133
+ * Bot: Nightblade
1134
+ *
1135
+ * BEHAVIOR: Enhanced melee assassin. Same aggressive engagement as Shadowblade —
1136
+ * blinks directly to the enemy and stabs for 15 damage (2-hit kill). The tier 2
1137
+ * upgrade is PREEMPTIVE DEFENSE: Nightblade watches the enemy's cast bar and
1138
+ * shields before a point-blank missile is even launched. At melee range, missiles
1139
+ * arrive almost instantly after launch — too fast to react. Nightblade anticipates
1140
+ * the threat. Also has emergency blink and proper channeling management.
1141
+ *
1142
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
1143
+ * - Shadowblade (tier 1): Offensive blink, melee stabs, basic shield (reactive only)
1144
+ * - Nightblade (tier 2): + preemptive shield vs enemy casts, emergency blink
1145
+ * - Voidblade (tier 3): Future — perfect assassination timing, inescapable engages
1146
+ *
1147
+ * TIER: 2 (enhanced Shadowblade)
1148
+ */
1149
+ declare const Nightblade: WizardFunction;
1150
+
1151
+ /**
1152
+ * Bot: Voidblade
1153
+ *
1154
+ * BEHAVIOR: Reactive counter-puncher. Shields everything, then fires quick stabs
1155
+ * during enemy vulnerability windows (GCD/casting) when they can't shield back.
1156
+ * At melee range, the shield blocks ~90% of incoming damage while Voidblade's
1157
+ * counter-stabs land at full damage — winning through attrition.
1158
+ *
1159
+ * CORE LOOP (melee range):
1160
+ * 1. Enemy casts missile → Voidblade blink-dodges (100% avoid) or shields (90% block)
1161
+ * 2. Enemy enters GCD → Voidblade fires quick stab (lands unblocked)
1162
+ * 3. Voidblade enters GCD → enemy recovers → repeat
1163
+ *
1164
+ * KEY IMPROVEMENTS OVER NIGHTBLADE:
1165
+ * - Blink-dodge priority: avoids 100% of damage when blink available, shields as fallback
1166
+ * - Reads enemy vulnerability to time counter-stabs perfectly
1167
+ * - Cancel-into-defense: aborts own cast if enemy missile incoming
1168
+ * - Punish budget: sizes stabs to fit exactly in the vulnerability window
1169
+ *
1170
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
1171
+ * TIER: 3 (elite Melee line)
1172
+ */
1173
+ declare const Voidblade: WizardFunction;
1174
+
1175
+ /**
1176
+ * Bot: Bonemancer
1177
+ *
1178
+ * BEHAVIOR: Stands still and fires slow, homing missiles constantly. Every missile
1179
+ * tracks the enemy with turnRate 2 — they curve relentlessly toward the target.
1180
+ * No movement, no shields, just an unending stream of seeking projectiles. The
1181
+ * missiles are slow (speed 3) but long-lived (300 ticks) and will chase you across
1182
+ * the entire arena.
1183
+ *
1184
+ * NAMING RATIONALE: Named after Diablo 2's Bone Necromancer ("Bonemancer"), whose
1185
+ * signature spell Bone Spirit is a slow-moving, auto-tracking projectile that hunts
1186
+ * enemies relentlessly. That's exactly what this bot does — it stands in place and
1187
+ * spams seeking missiles. The homing behavior is the key identity: these aren't
1188
+ * aimed shots, they're heat-seeking spirits that chase you down. Every D2 player
1189
+ * knows the Bonemancer — it's one of the most iconic builds.
1190
+ *
1191
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
1192
+ * - Bonemancer (tier 1): Stationary, spams slow homing missiles
1193
+ * - Lich (tier 2): Future — enhanced homing with adaptive missiles and defense
1194
+ * - Archlich (tier 3): Future — master of tracking magic, undodgeable death swarm
1195
+ * The progression follows the D2 necromancer power fantasy: from bone apprentice
1196
+ * to undead overlord, each tier's missiles become harder to escape.
1197
+ *
1198
+ * TIER: 1 (base)
1199
+ */
1200
+ declare const Bonemancer: WizardFunction;
1201
+
1202
+ /**
1203
+ * Bot: Lich
1204
+ *
1205
+ * BEHAVIOR: Homing missile specialist with strong-tracking adaptive missiles.
1206
+ * Uses fitMissileToBudget with minTurnRate 1.0 — higher than other bots (0.5) —
1207
+ * producing missiles with superior tracking at the cost of some damage/speed.
1208
+ * Strafing launches missiles from different angles, creating multi-angle pressure.
1209
+ *
1210
+ * Shields undodgeable/critical threats, emergency blinks. Cancels missile cast
1211
+ * only for lethal incoming damage.
1212
+ *
1213
+ * KEY DIFFERENCES FROM BONEMANCER:
1214
+ * - Bonemancer: stationary, no defense, fixed d=7/s=3/t=2/dur=300
1215
+ * - Lich: mobile, full defense, adaptive strong-tracking homing missiles
1216
+ *
1217
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
1218
+ * - Bonemancer (tier 1): Stationary, spams fixed slow homing missiles, no defense
1219
+ * - Lich (tier 2): Mobile + defense, adaptive strong-tracking missiles (minTurnRate 1.0)
1220
+ * - Archlich (tier 3): Future — converging web patterns, impossible to escape
1221
+ *
1222
+ * TIER: 2 (enhanced Bonemancer)
1223
+ */
1224
+ declare const Lich: WizardFunction;
1225
+
1226
+ /**
1227
+ * Bot: Archlich
1228
+ *
1229
+ * BEHAVIOR: Lich's proven core (mobile homing specialist) plus vulnerability
1230
+ * exploitation. Defense, movement, and standard offense are identical to Lich.
1231
+ * The T3 advantage: when the enemy is locked in GCD/cast, fires fast straight
1232
+ * punish missiles that land during the vulnerability window.
1233
+ *
1234
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
1235
+ * TIER: 3 (elite Homing line)
1236
+ */
1237
+ declare const Archlich: WizardFunction;
1238
+
1239
+ /**
1240
+ * Bot: Flamecaller
1241
+ *
1242
+ * BEHAVIOR: Long-range homing missile caster with fixed missile config.
1243
+ * Maintains 350u distance, strafes to dodge, and fires standard homing
1244
+ * missiles (d=10, s=5, t=1, dur=180). Shields undodgeable threats,
1245
+ * emergency blinks. A straightforward ranged caster that trades
1246
+ * consistency for adaptability.
1247
+ *
1248
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
1249
+ * - Flamecaller (tier 1): Fixed homing missiles, basic strafe and defense
1250
+ * - Pyromancer (tier 2): + adaptive fitting, cast canceling, smart fallbacks
1251
+ * - Infernalist (tier 3): Future — overwhelming adaptive fire
1252
+ *
1253
+ * TIER: 1 (base)
1254
+ */
1255
+ declare const Flamecaller: WizardFunction;
1256
+
1257
+ /**
1258
+ * Bot: Pyromancer
1259
+ *
1260
+ * BEHAVIOR: Adaptive homing missile specialist at long range. Maintains 400u
1261
+ * distance, strafes to dodge, and uses fitMissileToBudget with minTurnRate 0.5
1262
+ * to fire the highest-damage homing missile that fits in the safe window.
1263
+ * Shields undodgeable threats, emergency blinks. A versatile ranged caster
1264
+ * that adapts its missiles to the situation.
1265
+ *
1266
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
1267
+ * - Flamecaller (tier 1): Fixed homing missiles, basic strafe and defense
1268
+ * - Pyromancer (tier 2): + adaptive fitting, cast canceling, smart fallbacks
1269
+ * - Infernalist (tier 3): Future — overwhelming adaptive fire
1270
+ *
1271
+ * TIER: 2 (enhanced Flamecaller)
1272
+ */
1273
+ declare const Pyromancer: WizardFunction;
1274
+
1275
+ /**
1276
+ * Bot: Infernalist
1277
+ *
1278
+ * BEHAVIOR: Rapid-fire caster that exploits warmup bonus for accelerating DPS.
1279
+ * Fires consistent homing missiles to build warmup, punishes vulnerability windows
1280
+ * with warmup-boosted fast casts. Proactive blink kiting when enemy closes.
1281
+ *
1282
+ * KEY IMPROVEMENTS OVER PYROMANCER:
1283
+ * - Warmup exploitation: always passes lastMissileConfig for bonus
1284
+ * - Punish mode: straight missiles during enemy vulnerability
1285
+ * - Proactive blink kiting: monitors closing rate
1286
+ * - Progressive cast-cancel: graduated thresholds
1287
+ *
1288
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
1289
+ * TIER: 3 (elite Caster line)
1290
+ */
1291
+ declare const Infernalist: WizardFunction;
1292
+
1293
+ /**
1294
+ * Bot: Spellshot
1295
+ *
1296
+ * BEHAVIOR: Uses interceptAngle to calculate where the enemy will be and fires
1297
+ * fast, non-homing missiles (speed 8, turnRate 0) along the predicted path.
1298
+ * Strafes at medium range (300-400), shields undodgeable threats, emergency
1299
+ * blinks when shield isn't available. The key mechanic is PREDICTION — these
1300
+ * missiles don't track, they go exactly where you calculated the enemy would be.
1301
+ *
1302
+ * NAMING RATIONALE: "Spellshot" — a spell that is a single, precisely aimed shot.
1303
+ * Like a sniper's "called shot" but magical. The defining feature is the intercept
1304
+ * calculation: this bot doesn't fire tracking missiles, it calculates the exact
1305
+ * angle needed to hit a moving target. "Shot" implies precision, singular impact,
1306
+ * and skill-based aiming — everything this bot is about.
1307
+ *
1308
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
1309
+ * - Spellshot (tier 1): Basic intercept prediction, non-homing missiles
1310
+ * - Spelltracer (tier 2): Future — predictive homing (missiles that lead AND track)
1311
+ * - Spellseeker (tier 3): Future — perfect prediction, multi-angle attacks
1312
+ * The naming progression: shot (single bullet) → tracer (bullet that tracks a path)
1313
+ * → seeker (actively hunts). Each tier adds more intelligence to the projectile,
1314
+ * evolving from "I calculate where you'll be" to "my missile calculates where you'll be."
1315
+ *
1316
+ * NOTE: A separate future archetype "Spellslinger" (volume-of-fire) is reserved
1317
+ * for a rapid-fire bot that prioritizes quantity over prediction.
1318
+ *
1319
+ * TIER: 1 (base)
1320
+ */
1321
+ declare const Spellshot: WizardFunction;
1322
+
1323
+ /**
1324
+ * Bot: Spelltracer
1325
+ *
1326
+ * BEHAVIOR: Enhanced ranged sniper with adaptive missile fitting and intercept
1327
+ * prediction. Uses fitMissileToBudget to find the highest-damage fast missile
1328
+ * that fits the safe window, then fires it along the predicted intercept angle.
1329
+ * Maintains medium-long range (300-450), shields undodgeable threats with proper
1330
+ * timing, emergency blinks, and distance blinks when cornered. The key mechanic
1331
+ * is still PREDICTION — but now with adaptive damage optimization.
1332
+ *
1333
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
1334
+ * - Spellshot (tier 1): Fixed config intercept prediction, non-homing missiles
1335
+ * - Spelltracer (tier 2): + adaptive fitting, timed defense, distance management
1336
+ * - Spellseeker (tier 3): Future — perfect prediction, multi-angle attacks
1337
+ *
1338
+ * TIER: 2 (enhanced Spellshot)
1339
+ */
1340
+ declare const Spelltracer: WizardFunction;
1341
+
1342
+ /**
1343
+ * Bot: Spellseeker
1344
+ *
1345
+ * BEHAVIOR: Elite sniper that uses intercept-aimed straight missiles during vulnerability
1346
+ * windows. Combines Spelltracer's adaptive fitting with precise lead-position aiming
1347
+ * and vulnerability exploitation. Straight punish missiles at sniper range are nearly
1348
+ * unavoidable. Proactive distance control via closing rate detection.
1349
+ *
1350
+ * KEY IMPROVEMENTS OVER SPELLTRACER:
1351
+ * - Intercept-aimed punish: getLeadPosition + straight missiles during vulnerability
1352
+ * - Proactive distance blink: monitors closing rate, blinks before danger zone
1353
+ * - Progressive cast-cancel: graduated damage thresholds
1354
+ * - Warmup exploitation: always passes lastMissileConfig
1355
+ *
1356
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
1357
+ * TIER: 3 (elite Sniper line)
1358
+ */
1359
+ declare const Spellseeker: WizardFunction;
1360
+
1361
+ /**
1362
+ * Bot: Battlemage
1363
+ *
1364
+ * BEHAVIOR: Balanced mid-range duelist. Shields undodgeable threats, interrupts
1365
+ * enemy casts with quick missiles, saves blink for emergencies OR gap-closing.
1366
+ * Switches between quick (10 dmg, fast) and heavy (15 dmg, slow) missile configs
1367
+ * based on safety window and range. Will aggressively trade hits when health allows.
1368
+ * The unique trait is cast-interruption: fires quick missiles specifically when the
1369
+ * enemy is casting, punishing long cast times.
1370
+ *
1371
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
1372
+ * - Battlemage (tier 1): Quick/heavy fixed configs, cast interruption, basic defense
1373
+ * - Warmage (tier 2): Adaptive missile fitting (fitMissileToBudget), smarter attacks
1374
+ * - Archmage (tier 3): Future — supreme duelist, perfect tactical mastery
1375
+ *
1376
+ * TIER: 1 (base)
1377
+ */
1378
+ declare const Battlemage: WizardFunction;
1379
+
1380
+ /**
1381
+ * Bot: Warmage
1382
+ *
1383
+ * BEHAVIOR: Enhanced Battlemage with adaptive missile fitting. Uses fitMissileToBudget
1384
+ * to maximize damage within safe attack windows instead of fixed quick/heavy configs.
1385
+ * Same close-range playstyle: shields undodgeable threats, blinks to close distance
1386
+ * or escape, aggressive hit-trading when health allows. The adaptive fitting means
1387
+ * every attack is optimized for the current situation — no wasted cast time.
1388
+ *
1389
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
1390
+ * - Battlemage (tier 1): Quick/heavy fixed configs, cast interruption, basic defense
1391
+ * - Warmage (tier 2): Adaptive missile fitting, optimized damage windows
1392
+ * - Archmage (tier 3): Future — supreme duelist, perfect tactical mastery
1393
+ *
1394
+ * TIER: 2 (enhanced Battlemage)
1395
+ */
1396
+ declare const Warmage: WizardFunction;
1397
+
1398
+ /**
1399
+ * Bot: Archmage
1400
+ *
1401
+ * BEHAVIOR: Versatile duelist that adapts missile choice based on distance and HP.
1402
+ * Close range → straight missiles (no turn cost = more damage). Mid/far range → homing.
1403
+ * Uses dual-blink aggressively (gap-close during vulnerability, escape when trade is bad).
1404
+ * HP-aware: ahead → aggressive close range; behind → defensive ranged kiting.
1405
+ *
1406
+ * KEY IMPROVEMENTS OVER WARMAGE:
1407
+ * - Range-adaptive missiles: straight close, homing far
1408
+ * - Vulnerability-timed blinks: gap-close during enemy cast/GCD
1409
+ * - HP-aware aggression: adjusts distance + risk tolerance based on HP differential
1410
+ * - Progressive cast-cancel: graduated thresholds
1411
+ *
1412
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
1413
+ * TIER: 3 (elite Duelist line)
1414
+ */
1415
+ declare const Archmage: WizardFunction;
1416
+
1417
+ /**
1418
+ * Bot: Stormchaser
1419
+ *
1420
+ * BEHAVIOR: Fights aggressively while managing defense intelligently. Uses
1421
+ * two fixed missile configs (standard homing + quick attack) with predictive
1422
+ * homing missile AI (interceptAngle on the missile itself). Blink-dodges
1423
+ * incoming threats, shields when blink is on cooldown. Tight distance
1424
+ * management (350 units, ±30 band).
1425
+ *
1426
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
1427
+ * - Stormchaser (tier 1): Fixed missiles, predictive homing AI, blink-dodge
1428
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
1429
+ * - Stormforger (tier 3): Future — supreme berserker, perfect aggression
1430
+ *
1431
+ * TIER: 1 (base)
1432
+ */
1433
+ declare const Stormchaser: WizardFunction;
1434
+
1435
+ /**
1436
+ * Bot: Stormcaller
1437
+ *
1438
+ * BEHAVIOR: Enhanced Stormchaser with adaptive missile fitting (fitMissileToBudget)
1439
+ * AND predictive homing missiles. Combines aggressive fighting philosophy with
1440
+ * optimized damage output. Uses budget-based missile fitting to maximize damage
1441
+ * within safe windows. Falls back to quick missiles under pressure. Same smart
1442
+ * trade/shield decisions as Stormchaser but with better resource usage.
1443
+ *
1444
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
1445
+ * - Stormchaser (tier 1): Adaptive missiles, smart trading, aggressive defense
1446
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
1447
+ * - Stormforger (tier 3): Future — supreme berserker, perfect aggression
1448
+ *
1449
+ * TIER: 2 (enhanced Stormchaser)
1450
+ */
1451
+ declare const Stormcaller: WizardFunction;
1452
+
1453
+ /**
1454
+ * Bot: Stormforger
1455
+ *
1456
+ * BEHAVIOR: Enhanced Stormcaller with vulnerability exploitation. Takes the exact
1457
+ * Stormcaller foundation (adaptive missile fitting + predictive homing) and adds
1458
+ * a punish mode that fires fast straight missiles when the enemy is locked in
1459
+ * GCD or cast animation. During vulnerability windows, uses getLeadPosition for
1460
+ * accurate straight shots that arrive before the enemy can react.
1461
+ *
1462
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
1463
+ * - Stormchaser (tier 1): Adaptive missiles, smart trading, aggressive defense
1464
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
1465
+ * - Stormforger (tier 3): + vulnerability exploitation, punish missiles during enemy GCD
1466
+ *
1467
+ * TIER: 3 (elite Berserker line)
1468
+ */
1469
+ declare const Stormforger: WizardFunction;
1470
+
1471
+ /**
1472
+ * Bot: Spellspinner
1473
+ *
1474
+ * BEHAVIOR: Maintains medium range (350 units), strafes constantly to dodge
1475
+ * missiles, and fires homing missiles (damage 10, speed 4, turnRate 2). Heavy
1476
+ * emphasis on movement — 80% strafe intensity when not dodging, 100% when dodging.
1477
+ * Shields only undodgeable threats, emergency blinks when shield isn't available.
1478
+ * The constant circular strafing motion traces patterns like thread being spun.
1479
+ *
1480
+ * NAMING RATIONALE: Like a spider spinning a web of projectiles while circling its
1481
+ * prey. The constant strafing movement pattern traces circles — spinning thread
1482
+ * around the arena. "Spell" + "spinner" = a wizard who spins spells around the
1483
+ * battlefield. The kiting behavior (maintaining distance while attacking) creates
1484
+ * a web-like pattern of missiles and movement that traps opponents.
1485
+ *
1486
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
1487
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
1488
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
1489
+ * - Spellbinder (tier 3): Future — inescapable web of magic, perfect distance control
1490
+ * The progression: spinner (raw thread) → weaver (creates patterns) → binder
1491
+ * (constrains and traps). Each tier's projectile web becomes harder to escape.
1492
+ *
1493
+ * TIER: 1 (base)
1494
+ */
1495
+ declare const Spellspinner: WizardFunction;
1496
+
1497
+ /**
1498
+ * Bot: Spellweaver
1499
+ *
1500
+ * BEHAVIOR: Enhanced Spellspinner with adaptive missile fitting. Same medium-range
1501
+ * kiting playstyle — maintains distance, strafes heavily — but uses fitMissileToBudget
1502
+ * to maximize damage within safe attack windows. Always uses homing missiles since
1503
+ * kiting means enemies are always moving. More sophisticated than Spellspinner's
1504
+ * fixed damage/speed/turnRate configuration.
1505
+ *
1506
+ * NAMING RATIONALE: A weaver creates intricate patterns from raw thread. Where the
1507
+ * Spellspinner produces raw threads of magic (fixed missiles), the Spellweaver
1508
+ * combines them into optimized patterns (adaptive fitting). The name suggests
1509
+ * craftsmanship and sophistication — the same kiting web, but deliberately woven
1510
+ * rather than chaotically spun.
1511
+ *
1512
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
1513
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
1514
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
1515
+ * - Spellbinder (tier 3): Future — inescapable web, perfect distance control
1516
+ *
1517
+ * TIER: 2 (enhanced Spellspinner)
1518
+ */
1519
+ declare const Spellweaver: WizardFunction;
1520
+
1521
+ /**
1522
+ * Bot: Spellbinder
1523
+ *
1524
+ * BEHAVIOR: Enhanced Spellweaver with vulnerability exploitation. Same medium-range
1525
+ * kiting playstyle — maintains distance, strafes heavily, uses fitMissileToBudget
1526
+ * for adaptive homing missiles. The T3 upgrade adds a punish mode that fires fast
1527
+ * straight missiles timed to land while the enemy is locked in a cast or GCD,
1528
+ * when they cannot shield. Defense, movement, and standard offense are identical
1529
+ * to Spellweaver.
1530
+ *
1531
+ * NAMING RATIONALE: A binder constrains and locks down opponents. Where the
1532
+ * Spellweaver optimizes missile patterns (adaptive fitting), the Spellbinder
1533
+ * reads the enemy's state and punishes vulnerability windows — binding them
1534
+ * to their commitments with unavoidable damage.
1535
+ *
1536
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
1537
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
1538
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
1539
+ * - Spellbinder (tier 3): + vulnerability punish mode with fast straight missiles
1540
+ *
1541
+ * TIER: 3 (elite Spellspinner line)
1542
+ */
1543
+ declare const Spellbinder: WizardFunction;
1544
+
1545
+ /**
1546
+ * VIBEMANCER - BOT REGISTRY
1547
+ *
1548
+ * Single source of truth for all bots, ordered from weakest to strongest.
1549
+ * Run the tournament test to determine the correct ordering.
1550
+ *
1551
+ * To reorder: run `npx vitest run tests/bots/tournament.test.ts`
1552
+ * and update the list below based on the results.
1553
+ *
1554
+ * BOT NAMING SCHEME (3-tier progression):
1555
+ *
1556
+ * | Group | Tier 1 (base) | Tier 2 (enhanced) | Tier 3 (elite) |
1557
+ * |------------|----------------|-------------------|-----------------|
1558
+ * | Defensive | Turtle | Sentinel | Golem |
1559
+ * | Duelist | Battlemage | Warmage | Archmage |
1560
+ * | Homing | Bonemancer | Lich | Archlich |
1561
+ * | Caster | Flamecaller | Pyromancer | Infernalist |
1562
+ * | Melee | Shadowblade | Nightblade | Voidblade |
1563
+ * | Sniper | Spellshot | Spelltracer | Spellseeker |
1564
+ * | Berserker | Stormchaser | Stormcaller | Stormforger |
1565
+ * | Kiter | Spellspinner | Spellweaver | Spellbinder |
1566
+ *
1567
+ * Standalone: TargetDummy, Critter, Hogger, Rookie, Doombringer
1568
+ * Reserved: Spellslinger (future volume-of-fire archetype)
1569
+ *
1570
+ */
1571
+
1572
+ interface BotEntry {
1573
+ name: string;
1574
+ ai: WizardFunction;
1575
+ description: string;
1576
+ tier?: number;
1577
+ group: string;
1578
+ }
1579
+ interface BotGroup {
1580
+ label: string;
1581
+ bots: BotEntry[];
1582
+ }
1583
+ /**
1584
+ * All bots organized by progression line.
1585
+ * Each group contains bots from the same archetype, ordered by tier.
1586
+ */
1587
+ declare const BOT_GROUPS: BotGroup[];
1588
+ declare const ALL_BOTS: BotEntry[];
1589
+
1590
+ /**
1591
+ * VIBEMANCER - STATE HOOKS
1592
+ *
1593
+ * React-style hooks for reading game state.
1594
+ * These handle the "subconscious" perception that humans do instinctively.
1595
+ *
1596
+ * UNITS REFERENCE (100 ticks = 1 second):
1597
+ * Position: absolute world coordinates, 0-800 on each axis (800×800 arena)
1598
+ * Velocity: units per tick on each axis (player max speed = 1 u/t)
1599
+ * Health: hit points (max 60)
1600
+ * Ticks: game ticks (10ms each, 100/sec). Divide by 100 for seconds.
1601
+ * Shield: block multiplier 0.0-0.9 (0.9 = blocks 90% damage)
1602
+ */
1603
+
1604
+ /**
1605
+ * Get your current health (0-60). Wizard dies at 0.
1606
+ */
1607
+ declare function useHealth(): number;
1608
+ /**
1609
+ * Get your current position as {x, y} in world coordinates (0-800).
1610
+ * Position is clamped to [5, 795] (arena bounds minus wizard radius).
1611
+ */
1612
+ declare function usePosition(): Position;
1613
+ /**
1614
+ * Get your current velocity as {x, y} in units/tick.
1615
+ * Max magnitude is 1 u/t when idle, 0.5 u/t when casting, 0 when channeling shield.
1616
+ */
1617
+ declare function useVelocity(): Velocity;
1618
+ /**
1619
+ * Get your current status:
1620
+ * - 'idle': free to act
1621
+ * - 'casting': casting a spell (missile or blink). Can move at 50% speed.
1622
+ * - 'channeling': channeling shield. Cannot move. Cancel anytime with cancel().
1623
+ * - 'gcd_locked': global cooldown after spell. Can move at full speed, but cannot cast.
1624
+ */
1625
+ declare function useStatus(): 'idle' | 'casting' | 'channeling' | 'gcd_locked';
1626
+ /**
1627
+ * Get ticks until you can start a new spell.
1628
+ *
1629
+ * Returns 0 when idle or channeling (shield can be canceled immediately).
1630
+ * During casting: remaining cast ticks. During GCD: remaining GCD ticks.
1631
+ *
1632
+ * Note: 100 ticks = 1 second.
1633
+ */
1634
+ declare function useTicksUntilReady(): number;
1635
+ /**
1636
+ * Get current shield block multiplier.
1637
+ *
1638
+ * Returns 0 if not channeling shield.
1639
+ * Returns 0.3-0.9 if channeling: starts at 0.9 (blocks 90%), decays by 0.2/sec,
1640
+ * minimum 0.3 (blocks 30%). The remaining damage gets through:
1641
+ * actualDamage = incomingDamage × (1 - shieldStrength).
1642
+ */
1643
+ declare function useShieldStrength(): number;
1644
+ /**
1645
+ * Get blink cooldown remaining in ticks. Returns 0 if ready to blink.
1646
+ *
1647
+ * Cooldown scales with distance used:
1648
+ * - 100 units → ~100 ticks (1s)
1649
+ * - 300 units (max range) → 2000 ticks (20s)
1650
+ *
1651
+ * Note: 100 ticks = 1 second.
1652
+ */
1653
+ declare function useBlinkCooldown(): number;
1654
+ /**
1655
+ * Get currently casting spell, or null if not casting.
1656
+ * Returns 'missile', 'shield', or 'blink'.
1657
+ */
1658
+ declare function useCastingSpell(): 'missile' | 'shield' | 'blink' | null;
1659
+ /**
1660
+ * Get cast progress as {current, total} in ticks, or null if not casting.
1661
+ *
1662
+ * current = ticks elapsed, total = ticks needed. When current >= total, spell fires.
1663
+ * Note: 100 ticks = 1 second.
1664
+ */
1665
+ declare function useCastProgress(): {
1666
+ current: number;
1667
+ total: number;
1668
+ } | null;
1669
+ /**
1670
+ * Get enemy wizard state.
1671
+ *
1672
+ * Returns position, velocity, health, status, casting spell, and shield strength.
1673
+ * Note: you cannot see the enemy's missile configs or exact cooldown timers —
1674
+ * only their status and what's visible on the field.
1675
+ */
1676
+ declare function useEnemy(): EnemyState;
1677
+ /**
1678
+ * Get all your active (in-flight) projectiles.
1679
+ * Each has position, rotation (degrees), speed (u/t), turnRate, remainingTicks.
1680
+ */
1681
+ declare function useMyProjectiles(): ProjectileState[];
1682
+ /**
1683
+ * Get total damage you've dealt this match.
1684
+ */
1685
+ declare function useDamageDealt(): number;
1686
+ /**
1687
+ * Get total damage you've taken this match.
1688
+ */
1689
+ declare function useDamageTaken(): number;
1690
+ /**
1691
+ * Get the tick number when you last took damage. Returns 0 if never hit.
1692
+ * Compare with useTick() to get ticks since last hit.
1693
+ */
1694
+ declare function useLastHitTick(): number;
1695
+ /**
1696
+ * Get arena dimensions. Default: {width: 800, height: 800}.
1697
+ * Wizards are clamped to [5, 795] on each axis (radius = 5).
1698
+ */
1699
+ declare function useArenaSize(): {
1700
+ width: number;
1701
+ height: number;
1702
+ };
1703
+ /**
1704
+ * Get current game tick (starts at 0, increments each tick).
1705
+ * 100 ticks = 1 second. Match ends at 30,000 ticks (5 minutes).
1706
+ */
1707
+ declare function useTick(): number;
1708
+ /**
1709
+ * Get analyzed threats from all incoming enemy projectiles.
1710
+ * Sorted by ticksToImpact (soonest first). Only includes missiles within 500 units
1711
+ * or that are predicted to hit.
1712
+ *
1713
+ * Each threat includes:
1714
+ * - ticksToImpact: ticks until hit (Infinity if will miss)
1715
+ * - willHit: true if missile hits your current position
1716
+ * - canDodgeLeft/Right: whether strafing perpendicular to missile heading works
1717
+ * - canOutrun: whether moving away from missile escapes it
1718
+ * - bestDodgeDirection: {x, y} unit vector to dodge optimally, or null if undodgeable
1719
+ * - canBlockInTime: whether you can raise shield before impact
1720
+ * - ticksToStartShield: when to START channeling shield to block in time
1721
+ */
1722
+ declare function useThreats(): AnalyzedThreat[];
1723
+ /**
1724
+ * Get the most imminent threat, or null if no threats.
1725
+ * Shorthand for useThreats()[0].
1726
+ */
1727
+ declare function useClosestThreat(): AnalyzedThreat | null;
1728
+ /**
1729
+ * Get your missiles analyzed from the enemy's perspective.
1730
+ * Useful to predict when enemy will shield/dodge your attacks.
1731
+ */
1732
+ declare function useMyThreatsToEnemy(): AnalyzedThreat[];
1733
+
1734
+ /**
1735
+ * VIBEMANCER - THREAT ANALYSIS
1736
+ *
1737
+ * Pre-computes threat information for incoming projectiles.
1738
+ * This handles the "subconscious" perception of missile trajectories.
1739
+ */
1740
+
1741
+ /**
1742
+ * Analyze all threats from enemy projectiles.
1743
+ *
1744
+ * @param myPos - Current position of the wizard
1745
+ * @param projectiles - All projectiles in the game
1746
+ * @param myProjectiles - Only the bot's own projectiles (used for filtering)
1747
+ * @param ticksUntilReady - Ticks until wizard can start a new action
1748
+ * @returns Array of analyzed threats sorted by ticksToImpact (soonest first)
1749
+ */
1750
+ declare function analyzeThreats(myPos: Position, projectiles: ProjectileState[], myProjectiles: ProjectileState[], ticksUntilReady: number): AnalyzedThreat[];
1751
+
1752
+ /**
1753
+ * VIBEMANCER - ACTION BUILDERS
1754
+ *
1755
+ * Fluent API for constructing bot actions with type-safe chaining.
1756
+ *
1757
+ * UNITS REFERENCE (100 ticks = 1 second):
1758
+ * Position: absolute world coordinates, 0-800 on each axis (800×800 arena)
1759
+ * Movement: direction vector, magnitude auto-normalized to max 100
1760
+ * Speed: units per tick (player moves at 1 unit/tick = 100 units/sec)
1761
+ * Duration: ticks (divide by 100 for seconds)
1762
+ * Angles: degrees (0°=right, 90°=down, 180°=left, 270°=up)
1763
+ * Damage: raw HP removed on hit (wizard has 60 HP)
1764
+ * Turn rate: degrees per tick the missile can rotate
1765
+ */
1766
+
1767
+ /**
1768
+ * Channel a shield that blocks incoming damage.
1769
+ *
1770
+ * Starts at 90% block, decays by 20% per second, minimum 30%.
1771
+ * Takes 20 ticks (0.2s) to activate. Movement is disabled while channeling.
1772
+ * Cancel anytime with cancel(). Triggers 100-tick (1s) GCD after cancel.
1773
+ *
1774
+ * Can chain .move() — movement applies during the 20-tick cast, NOT during channel.
1775
+ *
1776
+ * @example
1777
+ * return shield(); // shield and stay still
1778
+ * return shield().move(100, 0); // move right while cast starts
1779
+ */
1780
+ declare function shield(): ActionBuilder;
1781
+ /**
1782
+ * Cast a missile spell.
1783
+ *
1784
+ * Cast time scales with damage, speed, duration, and turn rate — bigger missiles
1785
+ * take longer to cast. While casting you move at 50% speed. After firing, 100-tick
1786
+ * (1s) GCD before next spell.
1787
+ *
1788
+ * Repeated similar missiles cast 20% faster (warmup bonus). Switching styles
1789
+ * incurs a 20% penalty.
1790
+ *
1791
+ * Can chain .move() for simultaneous movement while casting.
1792
+ *
1793
+ * @param config - Missile stats:
1794
+ * - damage: HP removed on hit (1-60 typical). Also sets hitbox: radius = 2 + 0.1×damage.
1795
+ * - speed: units/tick (min 1.5). Player moves at 1 u/t, so 5 = 5× player speed.
1796
+ * - duration: ticks the missile lives (min 10). Range ≈ speed × duration.
1797
+ * - turnRate: degrees/tick of homing (0 = straight line, 3 = moderate homing, 5+ = strong).
1798
+ * Negative = no homing + minor speed cost reduction.
1799
+ * @param ai - Called every tick to control missile steering. Receives:
1800
+ * - missileState: the missile's position, rotation (degrees), speed, remainingTicks
1801
+ * - worldState: full game state (all wizards, projectiles)
1802
+ * - random(): seeded PRNG [0, 1)
1803
+ * Return { turnToward: {x, y} } to home toward a position, or {} to fly straight.
1804
+ * @param direction - Launch angle in degrees (0°=right, 90°=down, 180°=left, 270°=up).
1805
+ * Tip: use Math.atan2(dy, dx) * (180 / Math.PI) to aim at a target.
1806
+ *
1807
+ * @example
1808
+ * // Straight missile aimed at enemy
1809
+ * const angle = Math.atan2(dy, dx) * (180 / Math.PI);
1810
+ * return missile({damage: 15, speed: 6, duration: 200, turnRate: 0}, () => ({}), angle);
1811
+ *
1812
+ * // Homing missile that tracks enemy
1813
+ * return missile(
1814
+ * {damage: 10, speed: 5, duration: 300, turnRate: 3},
1815
+ * ({worldState}) => ({turnToward: worldState.enemies[0]?.position}),
1816
+ * angle,
1817
+ * );
1818
+ */
1819
+ declare function missile(config: MissileConfig, ai: MissileAIFunction, direction: number): ActionBuilder;
1820
+ /**
1821
+ * Teleport to an absolute position on the arena.
1822
+ *
1823
+ * Max range: 300 units from current position (clamped by engine if further).
1824
+ * Cast time: 10 ticks (0.1s). Cooldown scales with distance:
1825
+ * - 100 units → 100 ticks (1s)
1826
+ * - 300 units → 2000 ticks (20s)
1827
+ *
1828
+ * Cannot chain .move() — blink IS the movement.
1829
+ *
1830
+ * @param x - Target X position (0-800, absolute world coordinate)
1831
+ * @param y - Target Y position (0-800, absolute world coordinate)
1832
+ *
1833
+ * @example
1834
+ * return blink(400, 400); // blink to center
1835
+ * return blink(enemy.position.x, enemy.position.y); // blink to enemy
1836
+ */
1837
+ declare function blink(x: number, y: number): FinalAction;
1838
+ /**
1839
+ * Cancel current cast or channel (e.g. stop shielding to attack).
1840
+ *
1841
+ * Canceling a cast/channel triggers 100-tick (1s) GCD.
1842
+ * Can chain .move() for simultaneous movement.
1843
+ *
1844
+ * @example
1845
+ * return cancel().move(-100, 0); // cancel and dodge left
1846
+ */
1847
+ declare function cancel(): ActionBuilder;
1848
+ /**
1849
+ * Move in a direction without casting any spell.
1850
+ *
1851
+ * This is a **direction vector**, not a target position. The engine normalizes
1852
+ * the magnitude to max 100, then moves at 1 unit/tick (100 units/sec).
1853
+ * Positive X = right, positive Y = down.
1854
+ *
1855
+ * To move toward a target position, subtract your position:
1856
+ * move(target.x - myPos.x, target.y - myPos.y)
1857
+ *
1858
+ * @param x - Horizontal direction (positive = right, negative = left)
1859
+ * @param y - Vertical direction (positive = down, negative = up)
1860
+ *
1861
+ * @example
1862
+ * return move(100, 0); // move right
1863
+ * return move(enemy.position.x - myPos.x, enemy.position.y - myPos.y); // move toward enemy
1864
+ */
1865
+ declare function move(x: number, y: number): FinalAction;
1866
+ /**
1867
+ * Do nothing — no action, no movement.
1868
+ */
1869
+ declare function idle(): FinalAction;
1870
+ /**
1871
+ * Extract WizardActions from a FinalAction.
1872
+ * Used by the engine to get the actual action.
1873
+ */
1874
+ declare function extractAction(finalAction: FinalAction): WizardActions;
1875
+
1876
+ /**
1877
+ * VIBEMANCER - BOT WRAPPER
1878
+ *
1879
+ * Utilities to convert between old-style (WizardFunction) and new-style (BotFunction) bots.
1880
+ */
1881
+
1882
+ /**
1883
+ * Convert a new-style bot (using hooks) to an old-style bot (WizardFunction).
1884
+ *
1885
+ * This allows new bots to work with the existing simulation.
1886
+ *
1887
+ * @example
1888
+ * const NewBot: BotFunction = () => {
1889
+ * const health = useHealth();
1890
+ * return health < 10 ? shield() : idle();
1891
+ * };
1892
+ *
1893
+ * // Convert to work with simulate()
1894
+ * const oldStyleBot = wrapNewBot(NewBot);
1895
+ * simulate(oldStyleBot, opponent);
1896
+ */
1897
+ declare function wrapNewBot(newBot: BotFunction): WizardFunction;
1898
+ /**
1899
+ * Type guard to check if a bot is a new-style BotFunction.
1900
+ * New-style bots have 0 parameters, old-style bots have at least 1.
1901
+ */
1902
+ declare function isNewStyleBot(bot: WizardFunction | BotFunction): bot is BotFunction;
1903
+
1904
+ /**
1905
+ * VIBEMANCER - PARAMETER RUNTIME
1906
+ *
1907
+ * Provides the useParam() hook for bots to declare tunable parameters,
1908
+ * and the infrastructure for the optimizer to inject/discover parameter values.
1909
+ *
1910
+ * Design: Module-level state (JS is single-threaded, no race conditions).
1911
+ * The optimizer sets param values before running a bot, and clears them after.
1912
+ * During discovery, all useParam calls are recorded.
1913
+ *
1914
+ * ## useParam API
1915
+ *
1916
+ * ```typescript
1917
+ * // Basic: just a value, no optimizer config
1918
+ * const damage = useParam('damage', 15);
1919
+ *
1920
+ * // With range: optimizer searches value ± range (sliding window)
1921
+ * const distance = useParam('distance', 350, {range: 150, min: 0});
1922
+ *
1923
+ * // With fixed min/max: optimizer searches [min, max] (fixed bounds)
1924
+ * const damage = useParam('damage', 15, {min: 5, max: 25});
1925
+ *
1926
+ * // With all: range defines search radius, min/max clamp it
1927
+ * const fraction = useParam('fraction', 0.25, {range: 0.2, min: 0, max: 1});
1928
+ *
1929
+ * // With custom step count: optimizer tests 20 values instead of default 10
1930
+ * const distance = useParam('distance', 500, {range: 200, min: 0, steps: 20});
1931
+ * ```
1932
+ *
1933
+ * - **Arg 1** `name` — unique parameter name (must be consistent across ticks)
1934
+ * - **Arg 2** `value` — the actual value used in gameplay. This is what your bot
1935
+ * uses during matches. The optimizer script automatically updates this value.
1936
+ * - **Arg 3** `config` (optional) — optimizer search configuration:
1937
+ * - `range` — search radius: optimizer checks `value ± range`. The auto-optimizer
1938
+ * rewrites `value` after each run, so the search window slides automatically.
1939
+ * - `min` / `max` — hard constraints (e.g., distance ≥ 0, fraction ≤ 1).
1940
+ * When `range` is omitted, these define fixed search bounds (old-style).
1941
+ * - `steps` — how many evenly-spaced values the optimizer tests per pass (default: 10).
1942
+ * - `substeps` — steps to use in refinement passes (passes 2+). Set to 0 to freeze
1943
+ * after pass 1 (ideal for boolean params). Defaults to `steps` if not specified.
1944
+ * - At least `range` or both `min` + `max` must be provided.
1945
+ *
1946
+ * Without optimizer config, useParam simply returns `value` every tick.
1947
+ * With optimizer config, the offline optimizer script can override the value during search.
1948
+ *
1949
+ * ## Rules of Hooks
1950
+ * useParam follows the same rules as useState/useEffect/etc:
1951
+ * - Must be called at the top level of your bot function (not inside conditionals)
1952
+ * - Must be called in the same order every tick
1953
+ * - Violations are detected and throw errors
1954
+ */
1955
+
1956
+ /**
1957
+ * Declaration of a tunable parameter, as discovered by the optimizer.
1958
+ */
1959
+ interface ParamDeclaration {
1960
+ name: string;
1961
+ value: number;
1962
+ range?: number;
1963
+ min?: number;
1964
+ max?: number;
1965
+ steps: number;
1966
+ /** Steps to use in refinement passes (passes 2+). 0 = freeze after pass 1. Defaults to `steps`. */
1967
+ substeps?: number;
1968
+ }
1969
+ /**
1970
+ * Declare a tunable parameter. Returns the current value (optimizer-injected or the provided value).
1971
+ *
1972
+ * @param name - Unique parameter name (consistent across ticks)
1973
+ * @param value - The gameplay value. The auto-optimizer rewrites this in source code.
1974
+ * @param config - Optional optimizer search configuration
1975
+ * @returns The optimizer-injected value during optimization, or `value` during normal play
1976
+ *
1977
+ * @example
1978
+ * // Simple: no optimizer config
1979
+ * const damage = useParam('damage', 15);
1980
+ *
1981
+ * // With range: optimizer searches value ± range (sliding window)
1982
+ * const distance = useParam('distance', 350, {range: 150, min: 0});
1983
+ *
1984
+ * // With fixed min/max: optimizer searches [min, max]
1985
+ * const damage = useParam('damage', 15, {min: 5, max: 25});
1986
+ */
1987
+ declare function useParam(name: string, value: number, config?: {
1988
+ range?: number;
1989
+ min?: number;
1990
+ max?: number;
1991
+ steps?: number;
1992
+ substeps?: number;
1993
+ }): number;
1994
+ /**
1995
+ * Inject parameter values for the next bot execution.
1996
+ * The wrapped bot will read these values via useParam().
1997
+ */
1998
+ declare function setParamValues(values: Record<string, number>): void;
1999
+ /**
2000
+ * Clear injected parameter values. useParam() will return its provided value.
2001
+ */
2002
+ declare function clearParamValues(): void;
2003
+ /**
2004
+ * Start discovery mode. All subsequent useParam() calls with optimizer config
2005
+ * will register their declarations.
2006
+ */
2007
+ declare function startDiscovery(): void;
2008
+ /**
2009
+ * Stop discovery mode and return all discovered parameter declarations.
2010
+ */
2011
+ declare function stopDiscovery(): ParamDeclaration[];
2012
+ /**
2013
+ * Wrap a bot function to inject specific parameter values.
2014
+ * The returned function sets params before calling the bot and clears them after.
2015
+ */
2016
+ declare function wrapWithParams(bot: WizardFunction, params: Record<string, number>): WizardFunction;
2017
+
2018
+ /**
2019
+ * VIBEMANCER - OPTIMIZER UTILITIES
2020
+ *
2021
+ * Core functions used by the offline parameter optimizer script.
2022
+ * These handle combo generation, range narrowing, and fight scoring.
2023
+ *
2024
+ * The optimizer uses multi-pass coordinate descent:
2025
+ * - Pass 1: Coarse search across the effective range for each param
2026
+ * - Pass 2+: Fine search zoomed into the neighborhood of the best result
2027
+ *
2028
+ * Parameters can define their search window two ways:
2029
+ * - `range`: sliding window centered on current value (value ± range)
2030
+ * - `min`/`max`: fixed bounds (old-style)
2031
+ *
2032
+ * Both can be combined: range defines the search radius, min/max clamp it.
2033
+ */
2034
+
2035
+ /**
2036
+ * Compute the effective min/max search window for a parameter.
2037
+ *
2038
+ * - If `range` is set: window is `[value - range, value + range]`, clamped by optional min/max
2039
+ * - If only `min`/`max` are set: window is `[min, max]` directly
2040
+ * - If neither: returns `[value, value]` (no search)
2041
+ */
2042
+ declare function getEffectiveRange(p: ParamDeclaration): {
2043
+ min: number;
2044
+ max: number;
2045
+ };
2046
+ /**
2047
+ * Generate evenly-spaced candidate values for a single parameter.
2048
+ *
2049
+ * Divides [min, max] into `steps` evenly-spaced values. For example,
2050
+ * min=0, max=100, steps=5 produces [0, 25, 50, 75, 100].
2051
+ *
2052
+ * @param min - Lower bound of search range
2053
+ * @param max - Upper bound of search range
2054
+ * @param steps - Number of evenly-spaced values to generate (minimum 2)
2055
+ * @returns Array of candidate values, sorted ascending
2056
+ */
2057
+ declare function generateCandidates(min: number, max: number, steps: number): number[];
2058
+ /**
2059
+ * Generate all combinations (cartesian product) of candidate values for multiple params.
2060
+ *
2061
+ * For N params with S1, S2, ... SN steps each, produces S1 × S2 × ... × SN combinations.
2062
+ * Each combination is a Record<string, number> mapping param name to value.
2063
+ *
2064
+ * @param params - Parameter declarations with search ranges and step counts
2065
+ * @returns Array of all parameter combinations to evaluate
2066
+ */
2067
+ declare function generateCombos(params: ParamDeclaration[]): Record<string, number>[];
2068
+ /**
2069
+ * Narrow parameter ranges around the best combo found in the previous pass.
2070
+ *
2071
+ * Centers each param on its best value and shrinks the search range to one gap width.
2072
+ * This provides finer resolution in subsequent passes. Hard min/max constraints are preserved.
2073
+ *
2074
+ * @param params - Original parameter declarations
2075
+ * @param best - Best parameter combination from the previous pass
2076
+ * @returns New parameter declarations with narrowed ranges for the next pass
2077
+ */
2078
+ declare function narrowRange(params: ParamDeclaration[], best: Record<string, number>): ParamDeclaration[];
2079
+ /**
2080
+ * Score a FightResult from one bot's perspective.
2081
+ *
2082
+ * Returns a continuous score that provides gradient information beyond binary win/loss:
2083
+ * - Win: 3.0 base + up to 0.5 HP bonus (higher remaining HP = better)
2084
+ * - Draw: 1.0
2085
+ * - Loss: 0.0 base + up to 0.5 bonus for low enemy HP (closer fights = better)
2086
+ *
2087
+ * For a mirrored fight set (bot as wizard-1 AND wizard-2), call this twice
2088
+ * and sum the scores for a balanced evaluation.
2089
+ *
2090
+ * @param result - The fight result to score
2091
+ * @returns Continuous score in range [0, 3.5] per match
2092
+ */
2093
+ declare function scoreFight(result: FightResult): number;
2094
+ /**
2095
+ * Score a FightResult from wizard-2's perspective.
2096
+ * Same scoring logic as scoreFight but with roles reversed.
2097
+ *
2098
+ * Use this for tournaments where both sides of a pairing need scoring.
2099
+ */
2100
+ declare function scoreFightAsWizard2(result: FightResult): number;
2101
+
2102
+ /**
2103
+ * VIBEMANCER — BROWSER SANDBOX
2104
+ *
2105
+ * Provides Web Worker-based sandboxing for bot code execution in the browser.
2106
+ * Same compiled bundles as the isolated-vm sandbox (MatchSandbox), but runs
2107
+ * in a Web Worker instead of a V8 isolate.
2108
+ *
2109
+ * Architecture:
2110
+ * - Host: creates Worker from Blob URL, communicates via postMessage
2111
+ * - Worker: loads compiled bundle (sets globalThis.__fight/__simulate),
2112
+ * dispatches fight/simulate calls, posts results back
2113
+ *
2114
+ * Safety:
2115
+ * - Timeout via setTimeout + worker.terminate() catches infinite loops
2116
+ * - No memory limit (browser manages worker memory; worst case = tab crash)
2117
+ * - Prototype freeze prevents cross-bot sabotage (same banner as isolated-vm)
2118
+ * - No Node.js APIs available in Web Workers
2119
+ *
2120
+ * NOTE: This file has ZERO Node.js dependencies. It works in any JS environment.
2121
+ */
2122
+
2123
+ /**
2124
+ * Minimal Worker interface for dependency injection.
2125
+ * Matches the browser Worker API subset we need.
2126
+ * For tests, a Node.js worker_threads adapter can implement this.
2127
+ */
2128
+ interface WorkerLike {
2129
+ postMessage(data: unknown): void;
2130
+ terminate(): void;
2131
+ addEventListener(type: string, listener: (ev: unknown) => void): void;
2132
+ removeEventListener(type: string, listener: (ev: unknown) => void): void;
2133
+ }
2134
+ /**
2135
+ * Factory function that creates a WorkerLike from a JavaScript code string.
2136
+ * Default: creates a browser Web Worker via Blob URL.
2137
+ * Override in options.createWorker for testing with Node.js worker_threads.
2138
+ */
2139
+ type WorkerFactory = (code: string) => {
2140
+ worker: WorkerLike;
2141
+ cleanup?: () => void;
2142
+ };
2143
+ /**
2144
+ * Options for browser sandbox creation.
2145
+ */
2146
+ interface BrowserSandboxOptions {
2147
+ /** Timeout in ms for fight/simulate calls (default: 30000). */
2148
+ timeoutMs?: number;
2149
+ /** Custom worker factory for dependency injection (testing). */
2150
+ createWorker?: WorkerFactory;
2151
+ }
2152
+ /**
2153
+ * Create the full worker script from a compiled match bundle.
2154
+ * Appends the message-handling bootstrap to the bundle IIFE.
2155
+ */
2156
+ declare function createWorkerScript(bundle: string): string;
2157
+ /**
2158
+ * Browser-compatible sandboxed match runner using Web Workers.
2159
+ *
2160
+ * Same compiled bundles as MatchSandbox (isolated-vm), but runs in a
2161
+ * Web Worker instead. All fight/simulate calls are async (postMessage-based).
2162
+ *
2163
+ * Usage:
2164
+ * ```ts
2165
+ * // Bundle is compiled server-side or at build time (Node.js only)
2166
+ * const bundle = await MatchSandbox.compile(bot1, bot2);
2167
+ *
2168
+ * // Run in browser via Web Worker
2169
+ * const sandbox = await BrowserMatchSandbox.fromBundle(bundle);
2170
+ * const result = await sandbox.fight({ seed: 42 });
2171
+ * sandbox.dispose();
2172
+ * ```
2173
+ */
2174
+ declare class BrowserMatchSandbox {
2175
+ private worker;
2176
+ private workerCleanup;
2177
+ private timeout;
2178
+ private disposed;
2179
+ private nextId;
2180
+ private pending;
2181
+ private messageHandler;
2182
+ private errorHandler;
2183
+ private constructor();
2184
+ /**
2185
+ * Create a browser sandbox from a pre-compiled bundle string.
2186
+ * The bundle should be the output of MatchSandbox.compile() (or equivalent IIFE
2187
+ * that sets globalThis.__fight and globalThis.__simulate).
2188
+ */
2189
+ static fromBundle(bundle: string, options?: BrowserSandboxOptions): Promise<BrowserMatchSandbox>;
2190
+ /**
2191
+ * Wait for the worker to post {type: 'ready'}, then attach permanent handlers.
2192
+ */
2193
+ private waitForReady;
2194
+ /**
2195
+ * Extract message data from a browser MessageEvent or raw Node.js data.
2196
+ */
2197
+ private unwrapEvent;
2198
+ /**
2199
+ * Attach permanent message and error handlers for fight/simulate responses.
2200
+ */
2201
+ private attachHandlers;
2202
+ /**
2203
+ * Run a full fight (10 matches: 5 spawn distances x 2 sides).
2204
+ * Returns a Promise because Worker communication is async.
2205
+ */
2206
+ fight(options?: {
2207
+ seed?: number;
2208
+ maxTicks?: number;
2209
+ }): Promise<FightResult>;
2210
+ /**
2211
+ * Run a single simulation. Returns a Promise.
2212
+ *
2213
+ * @param options.params1 - useParam overrides for bot 1 (wizard-1)
2214
+ * @param options.params2 - useParam overrides for bot 2 (wizard-2)
2215
+ */
2216
+ simulate(options?: {
2217
+ seed?: number;
2218
+ maxTicks?: number;
2219
+ spawnDistance?: number;
2220
+ skipHistory?: boolean;
2221
+ params1?: Record<string, number>;
2222
+ params2?: Record<string, number>;
2223
+ }): Promise<SimulateResult>;
2224
+ /**
2225
+ * Dispose the worker and free all resources.
2226
+ * The sandbox cannot be used after disposal.
2227
+ */
2228
+ dispose(): void;
2229
+ /**
2230
+ * Whether this sandbox has been disposed.
2231
+ */
2232
+ get isDisposed(): boolean;
2233
+ /**
2234
+ * Send a generic method call to the worker. Used by sibling sandboxes
2235
+ * (e.g. BrowserManualMatchSandbox) that need to dispatch to method
2236
+ * names other than fight/simulate. The worker bootstrap looks up
2237
+ * `globalThis['__' + method]` and calls it with `options`.
2238
+ */
2239
+ callRaw(method: string, options: unknown): Promise<unknown>;
2240
+ /**
2241
+ * Send a method call to the worker and wait for the response.
2242
+ * Times out and terminates the worker if no response within timeout.
2243
+ */
2244
+ private call;
2245
+ private ensureNotDisposed;
2246
+ }
2247
+ /**
2248
+ * One-shot browser-sandboxed fight. Creates worker, runs fight, disposes.
2249
+ */
2250
+ declare function browserSandboxFight(bundle: string, options?: {
2251
+ seed?: number;
2252
+ maxTicks?: number;
2253
+ } & BrowserSandboxOptions): Promise<FightResult>;
2254
+ /**
2255
+ * One-shot browser-sandboxed simulate. Creates worker, runs simulate, disposes.
2256
+ */
2257
+ declare function browserSandboxSimulate(bundle: string, options?: {
2258
+ seed?: number;
2259
+ maxTicks?: number;
2260
+ spawnDistance?: number;
2261
+ skipHistory?: boolean;
2262
+ params1?: Record<string, number>;
2263
+ params2?: Record<string, number>;
2264
+ } & BrowserSandboxOptions): Promise<SimulateResult>;
2265
+ /**
2266
+ * Options accepted by `__manualMatchInit` (worker-side). Mirrors
2267
+ * `ManualMatchOptions` from manual-match.ts, but without the constructor's
2268
+ * AI parameters since the player AI is a worker-local stub.
2269
+ */
2270
+ interface ManualMatchInitOptions {
2271
+ seed?: number;
2272
+ spawnDistance?: number;
2273
+ maxTicks?: number;
2274
+ initialHumanActions?: WizardActions;
2275
+ }
2276
+ interface ManualMatchStepRequest {
2277
+ humanActions?: WizardActions;
2278
+ humanMissileTargets?: Record<string, {
2279
+ x: number;
2280
+ y: number;
2281
+ }>;
2282
+ count?: number;
2283
+ }
2284
+ /**
2285
+ * Long-lived Web Worker sandbox holding a single ManualMatch instance.
2286
+ *
2287
+ * Unlike BrowserMatchSandbox (which runs one batched fight/simulate per
2288
+ * worker), BrowserManualMatchSandbox keeps the worker alive across many
2289
+ * step calls so the engine state and hook state persist between ticks.
2290
+ * This is what manual play mode uses: one worker per session, disposed
2291
+ * when the user leaves the page or starts a new match.
2292
+ *
2293
+ * Usage:
2294
+ * ```ts
2295
+ * const sandbox = await BrowserManualMatchSandbox.fromBundle(opponentBundle);
2296
+ * await sandbox.init({seed: 42});
2297
+ * for (let i = 0; i < 100; i++) {
2298
+ * await sandbox.step({humanActions: {move: {x: 100, y: 0}}, count: 1});
2299
+ * }
2300
+ * await sandbox.dispose();
2301
+ * ```
2302
+ */
2303
+ declare class BrowserManualMatchSandbox {
2304
+ private readonly inner;
2305
+ private constructor();
2306
+ /**
2307
+ * Create a manual-match sandbox from a pre-compiled bundle. The bundle
2308
+ * must be the output of `compileManualMatchBundle()` — the regular
2309
+ * `compileMatchBundle()` output won't work since it doesn't expose the
2310
+ * `__manualMatch*` globals.
2311
+ */
2312
+ static fromBundle(bundle: string, options?: BrowserSandboxOptions): Promise<BrowserManualMatchSandbox>;
2313
+ /**
2314
+ * Initialize the worker-side ManualMatch instance.
2315
+ * Returns the initial GameState (tick 0).
2316
+ */
2317
+ init(options?: ManualMatchInitOptions): Promise<GameState>;
2318
+ /**
2319
+ * Advance the match by `request.count` ticks (default 1), updating
2320
+ * the player's human actions and any hijacked missile targets first.
2321
+ */
2322
+ step(request?: ManualMatchStepRequest): Promise<StepResult>;
2323
+ /**
2324
+ * Replace a missile's AI with a worker-local hijack stub that reads
2325
+ * from `latestHumanMissileTargets[projectileId]`. Subsequent step()
2326
+ * calls with `humanMissileTargets` populated for this id steer the
2327
+ * missile.
2328
+ */
2329
+ hijackMissile(projectileId: string): Promise<void>;
2330
+ /**
2331
+ * Restore a hijacked missile's original AI.
2332
+ */
2333
+ releaseMissile(projectileId: string): Promise<void>;
2334
+ /**
2335
+ * Toggle invincibility for a wizard.
2336
+ */
2337
+ setInvincible(wizardIndex: 0 | 1, on: boolean): Promise<void>;
2338
+ /**
2339
+ * Get the current game state without advancing.
2340
+ */
2341
+ getState(): Promise<GameState>;
2342
+ /**
2343
+ * Get the full SimulateResult-compatible result object (history + winner).
2344
+ */
2345
+ getResult(): Promise<SimulateResult>;
2346
+ /**
2347
+ * Dispose the worker-side ManualMatch instance. Does NOT terminate the
2348
+ * worker — call dispose() for that.
2349
+ */
2350
+ resetMatch(): Promise<void>;
2351
+ /**
2352
+ * Terminate the worker and free all resources.
2353
+ */
2354
+ dispose(): void;
2355
+ get isDisposed(): boolean;
2356
+ }
2357
+
2358
+ /**
2359
+ * VIBEMANCER - FIGHT STATISTICS
2360
+ *
2361
+ * Extracts detailed per-bot statistics from a SimulateResult history.
2362
+ * Used by testBot().simulate() and vibemancer trace for debugging.
2363
+ */
2364
+
2365
+ /** Detailed statistics for one bot in a single match. */
2366
+ interface FightStats {
2367
+ /** Total damage dealt to the opponent. */
2368
+ damageDealt: number;
2369
+ /** Total damage taken from the opponent. */
2370
+ damageTaken: number;
2371
+ /** Number of missiles launched. */
2372
+ missilesLaunched: number;
2373
+ /** Number of missiles that dealt damage (hit the opponent). */
2374
+ missileHits: number;
2375
+ /** Hit rate (0-1). NaN if no missiles fired. */
2376
+ hitRate: number;
2377
+ /** Number of our missiles that hit while enemy was shielding. */
2378
+ hitsEnemyShielded: number;
2379
+ /** Number of our missiles that hit while enemy had no shield. */
2380
+ hitsEnemyUnshielded: number;
2381
+ /** Total raw damage our missiles would have dealt without shields. */
2382
+ rawDamageDealt: number;
2383
+ /** Damage blocked by enemy shields. */
2384
+ damageBlockedByEnemy: number;
2385
+ /** Percentage of our raw damage blocked by enemy shields (0-1). */
2386
+ enemyBlockRate: number;
2387
+ /** Number of times we were hit by enemy missiles. */
2388
+ hitsReceived: number;
2389
+ /** Number of hits received while shield was channeling. */
2390
+ hitsShielded: number;
2391
+ /** Number of hits received without shield. */
2392
+ hitsUnshielded: number;
2393
+ /** Total raw damage that hit us (before shield reduction). */
2394
+ rawDamageReceived: number;
2395
+ /** Total damage blocked by shields. */
2396
+ damageBlocked: number;
2397
+ /** Percentage of incoming raw damage that was blocked (0-1). */
2398
+ blockRate: number;
2399
+ /** Ticks spent in 'casting' state. */
2400
+ castingTicks: number;
2401
+ /** Ticks spent channeling shield. */
2402
+ shieldTicks: number;
2403
+ /** Ticks spent in GCD lockout. */
2404
+ gcdTicks: number;
2405
+ /** Ticks spent idle (not casting, channeling, or in GCD). */
2406
+ idleTicks: number;
2407
+ /** Number of times shield was activated. */
2408
+ shieldCount: number;
2409
+ /** Number of times blink was used. */
2410
+ blinkCount: number;
2411
+ /** Total match duration in ticks. */
2412
+ totalTicks: number;
2413
+ }
2414
+ /**
2415
+ * Extract fight statistics from a SimulateResult.
2416
+ * Returns stats for wizard-1 (the bot under test).
2417
+ */
2418
+ declare function extractStats(result: SimulateResult): FightStats;
2419
+ /** Format stats as a human-readable summary string. */
2420
+ declare function formatStats(stats: FightStats, botName: string): string;
2421
+
2422
+ /**
2423
+ * VIBEMANCER - TESTING UTILITIES
2424
+ *
2425
+ * Helpers for writing automated tests for your bot.
2426
+ * Import from '@vibemancer/core' in your test files.
2427
+ *
2428
+ * @example
2429
+ * import {testBot} from '@vibemancer/core';
2430
+ * import {MyWizard} from '../src/bot';
2431
+ *
2432
+ * test('beats TargetDummy', async () => {
2433
+ * const result = await testBot(MyWizard).fight('TargetDummy');
2434
+ * expect(result.won).toBe(true);
2435
+ * });
2436
+ */
2437
+
2438
+ /** Result of a testBot().fight() call with convenience accessors. */
2439
+ interface TestFightResult {
2440
+ /** The raw FightResult from the simulation engine. */
2441
+ raw: FightResult;
2442
+ /** Overall winner: 'wizard-1' | 'wizard-2' | 'draw'. */
2443
+ winner: FightWinner;
2444
+ /** True if your bot won the fight. */
2445
+ won: boolean;
2446
+ /** True if your bot lost the fight. */
2447
+ lost: boolean;
2448
+ /** True if the fight was a draw. */
2449
+ drawn: boolean;
2450
+ /** Number of individual matches your bot won (out of 10). */
2451
+ wins: number;
2452
+ /** Number of individual matches your bot lost (out of 10). */
2453
+ losses: number;
2454
+ /** Number of individual matches that were draws. */
2455
+ draws: number;
2456
+ }
2457
+ /** Result of a testBot().simulate() call with convenience accessors. */
2458
+ interface TestSimulateResult {
2459
+ /** The raw SimulateResult from the simulation engine. */
2460
+ raw: SimulateResult;
2461
+ /** Match winner. */
2462
+ winner: MatchWinner;
2463
+ /** True if your bot won. */
2464
+ won: boolean;
2465
+ /** True if your bot lost. */
2466
+ lost: boolean;
2467
+ /** True if the match was a draw or timeout. */
2468
+ drawn: boolean;
2469
+ /** Number of ticks the match lasted. */
2470
+ ticks: number;
2471
+ /** Your bot's remaining HP. */
2472
+ myHealth: number;
2473
+ /** Enemy's remaining HP. */
2474
+ enemyHealth: number;
2475
+ /** Detailed fight statistics (missiles, damage, shield usage, time breakdown). */
2476
+ stats: FightStats;
2477
+ /** Runtime errors thrown by bot or missile AI (empty if none). */
2478
+ errors: Array<{
2479
+ tick: number;
2480
+ entityId: string;
2481
+ message: string;
2482
+ }>;
2483
+ }
2484
+ /** Builder returned by testBot(). */
2485
+ interface TestBotBuilder {
2486
+ /**
2487
+ * Run a full fight (10 matches) against a named built-in bot.
2488
+ * @param opponent - Built-in bot name (e.g., 'Battlemage', 'TargetDummy').
2489
+ */
2490
+ fight(opponent: string, options?: {
2491
+ seed?: number;
2492
+ }): TestFightResult;
2493
+ /**
2494
+ * Run a single match against a named built-in bot.
2495
+ * @param opponent - Built-in bot name.
2496
+ */
2497
+ simulate(opponent: string, options?: {
2498
+ seed?: number;
2499
+ spawnDistance?: number;
2500
+ maxTicks?: number;
2501
+ }): TestSimulateResult;
2502
+ }
2503
+ /**
2504
+ * Create a test builder for your bot.
2505
+ *
2506
+ * @param bot - Your bot function (the same function you export from src/bot.ts).
2507
+ * @returns A builder with .fight() and .simulate() methods.
2508
+ *
2509
+ * @example
2510
+ * ```ts
2511
+ * import {testBot} from '@vibemancer/core';
2512
+ * import {MyWizard} from '../src/bot';
2513
+ *
2514
+ * test('beats TargetDummy', () => {
2515
+ * const result = testBot(MyWizard).fight('TargetDummy');
2516
+ * expect(result.won).toBe(true);
2517
+ * });
2518
+ *
2519
+ * test('survives 10 seconds against Battlemage', () => {
2520
+ * const result = testBot(MyWizard).simulate('Battlemage', {maxTicks: 1000});
2521
+ * expect(result.myHealth).toBeGreaterThan(0);
2522
+ * });
2523
+ *
2524
+ * test('kills at close range', () => {
2525
+ * const result = testBot(MyWizard).simulate('TargetDummy', {spawnDistance: 200});
2526
+ * expect(result.won).toBe(true);
2527
+ * expect(result.ticks).toBeLessThan(1000);
2528
+ * });
2529
+ * ```
2530
+ */
2531
+ declare function testBot(bot: WizardFunction | BotFunction): TestBotBuilder;
2532
+
2533
+ /**
2534
+ * VIBEMANCER - FIGHT TRACE
2535
+ *
2536
+ * Extracts a structured event log from a SimulateResult history.
2537
+ * Both bots' actions are tracked: state changes, missile launches with
2538
+ * full config, hits, damage, dodge proximity, movement patterns.
2539
+ *
2540
+ * Used by:
2541
+ * - vibemancer trace (CLI debug command)
2542
+ * - scripts/fight-trace.ts (internal diagnostic)
2543
+ * - User tests that want event-level analysis
2544
+ */
2545
+
2546
+ interface TraceEvent {
2547
+ tick: number;
2548
+ /** 'W1' = wizard-1, 'W2' = wizard-2 */
2549
+ actor: 'W1' | 'W2';
2550
+ type: TraceEventType;
2551
+ detail: string;
2552
+ }
2553
+ type TraceEventType = 'STATE' | 'FIRE' | 'HIT' | 'HURT' | 'DODGE_START' | 'DODGE_CLOSE' | 'MOVE' | 'ERROR' | 'WARNING';
2554
+ interface TraceSummary {
2555
+ winner: string;
2556
+ ticks: number;
2557
+ w1Name: string;
2558
+ w2Name: string;
2559
+ w1FinalHp: number;
2560
+ w2FinalHp: number;
2561
+ w1: TraceBotSummary;
2562
+ w2: TraceBotSummary;
2563
+ }
2564
+ interface TraceBotSummary {
2565
+ missilesLaunched: number;
2566
+ hits: number;
2567
+ damageDealt: number;
2568
+ damageReceived: number;
2569
+ shields: number;
2570
+ blinks: number;
2571
+ dodgeEncounters: number;
2572
+ movement: {
2573
+ strafe: number;
2574
+ approach: number;
2575
+ retreat: number;
2576
+ still: number;
2577
+ };
2578
+ }
2579
+ /**
2580
+ * Extract a structured event log from simulation history.
2581
+ * Tracks both bots' state changes, missile launches (with full config + range),
2582
+ * hits, damage, dodge proximity, movement patterns, and runtime errors.
2583
+ */
2584
+ declare function extractTraceEvents(history: GameState[], errors?: BotError[]): TraceEvent[];
2585
+ /**
2586
+ * Generate a summary from trace events and the simulation result.
2587
+ */
2588
+ declare function summarizeTrace(events: TraceEvent[], result: SimulateResult, w1Name: string, w2Name: string): TraceSummary;
2589
+ /** Format trace events as a human-readable string. */
2590
+ declare function formatTraceEvents(events: TraceEvent[]): string;
2591
+ /** Format a full trace summary as a human-readable string. */
2592
+ declare function formatTraceSummary(summary: TraceSummary): string;
2593
+ /**
2594
+ * Generate diagnostic tips based on trace analysis.
2595
+ * Identifies common problems and suggests fixes.
2596
+ * Returns an array of human-readable tips (empty if no issues found).
2597
+ */
2598
+ declare function diagnoseTrace(events: TraceEvent[], summary: TraceSummary): string[];
2599
+ /** Format diagnostic tips as a human-readable string. */
2600
+ declare function formatDiagnosis(tips: string[]): string;
2601
+
2602
+ export { ALL_BOTS, ARENA_HEIGHT, ARENA_SIZE, ARENA_WATER_BUFFER, ARENA_WIDTH, type ActionBuilder, type AnalyzedThreat, type AntiHomingParams, Archlich, Archmage, BLINK_CAST_TIME, BLINK_COOLDOWN, BLINK_MAX_COOLDOWN, BLINK_MAX_RANGE, BLINK_MIN_COOLDOWN, BLINK_RANGE, BOT_GROUPS, Battlemage, Bonemancer, type BotContext, type BotEntry, type BotError, type BotFunction, type BotGroup, BrowserManualMatchSandbox, BrowserMatchSandbox, type BrowserSandboxOptions, CASTING_MOVEMENT_MULT, COLLISION_RADIUS, Critter, Doombringer, ENGINE_VERSION, type EnemyState, FIGHT_SPAWN_DISTANCES, type FightResult, type FightStats, type FightWinner, type FinalAction, Flamecaller, GCD_DURATION, type GameConfig, type GameState, Golem, Hogger, type HomingParams, type HookState, Infernalist, type InternalWizardState, Lich, MATCH_DURATION, MAX_HEALTH, MISSILE_BASE_CAST, MISSILE_BASE_RADIUS, MISSILE_DAMAGE_POWER, MISSILE_DAMAGE_RADIUS_SCALE, MISSILE_DAMAGE_SCALE, MISSILE_HOMING_COEFF, MISSILE_MIN_CAST_TIME, MISSILE_MIN_DAMAGE, MISSILE_MIN_DURATION, MISSILE_MIN_SPEED, MISSILE_RADIUS_PER_DAMAGE, MISSILE_SPEED_DURATION_BASELINE, MISSILE_SPEED_DURATION_COEFF, MISSILE_TURN_DURATION_COEFF, MOVEMENT_SPEED, MOVE_SPEED, ManualMatch, type ManualMatchInitOptions, type ManualMatchOptions, type ManualMatchStepRequest, type MatchWinner, type MissileAIFunction, type MissileActions, type MissileConfig, type MissileTemplate, Nightblade, type ParamDeclaration, type Position, type ProjectileState, Pyromancer, type RefObject, Rookie, SHIELD_CAST_TIME, SHIELD_DECAY_PER_SECOND, SHIELD_DECAY_RATE, SHIELD_MAX_BLOCK, SHIELD_MAX_STRENGTH, SHIELD_MIN_BLOCK, SHIELD_MIN_STRENGTH, SPAWN_DISTANCE, type SeekerParams, Sentinel, Shadowblade, type SimulateResult, Spellbinder, Spellseeker, Spellshot, Spellspinner, Spelltracer, Spellweaver, type SpiralParams, type StepResult, Stormcaller, Stormchaser, Stormforger, type StraightParams, TICKS_PER_SECOND, TICK_DURATION_MS, TargetDummy, type TestBotBuilder, type TestFightResult, type TestSimulateResult, type TraceBotSummary, type TraceEvent, type TraceEventType, type TraceSummary, Turtle, type Velocity, Voidblade, WARMUP_DURATION_TOLERANCE, WARMUP_MAX_BONUS, WARMUP_MAX_PENALTY, WARMUP_SPEED_TOLERANCE, WARMUP_TURN_TOLERANCE, WIZARD_HEALTH, WIZARD_RADIUS, Warmage, type WizardActions, type WizardFunction, type WizardState, type WorkerFactory, type WorkerLike, analyzeThreats, angleDiff, angleInRange, angleTo, antiHomingMissile, applyDamage, blink, browserSandboxFight, browserSandboxSimulate, calculateBlinkCooldown, calculateMissileCastTime, calculateMissileRadius, calculateMissileSimilarity, calculateShieldBlock, calculateWarmupMultiplier, cancel, cancelCast, clampPositionToArena, clampToArena, clearHooks, clearParamValues, completeCast, createEntitySeed, createInitialState, createRandom, createWorkerScript, diagnoseTrace, directionAway, directionTo, distanceTo, effectiveTurnRateCost, extractAction, extractStats, extractTraceEvents, fight, findInRange, findNearest, fitMissileToBudget, formatDiagnosis, formatStats, formatTraceEvents, formatTraceSummary, generateCandidates, generateCombos, getAdaptiveMissileConfig, getBotContext, getEffectiveRange, getLeadPosition, getMissileCastTime, getPlayerState, hashCombine, homingMissile, idle, inRange, interceptAngle, isNewStyleBot, magnitude, missile, move, moveInDirection, moveProjectile, moveWizard, narrowRange, nextRandom, normalize, normalizeAngle, predictPosition, resetAllHooks, resolveWizardCollision, runBotWithContext, runWithHooks, scoreFight, scoreFightAsWizard2, seekerMissile, setParamValues, shield, simulate, sortByDistance, spiralMissile, startCast, startDiscovery, stopDiscovery, straightMissile, summarizeTrace, sweptCircleCollision, testBot, tick, updateShield, useArenaSize, useBlinkCooldown, useCastProgress, useCastingSpell, useClosestThreat, useDamageDealt, useDamageTaken, useEffect, useEnemy, useHealth, useLastHitTick, useMemo, useMyProjectiles, useMyThreatsToEnemy, useParam, usePosition, useRef, useShieldStrength, useState, useStatus, useThreats, useTick, useTicksUntilReady, useVelocity, validateHookCall, validateMissileConfig, withBotContext, wrapNewBot, wrapWithParams };