@vibemancer/core 1.0.3 → 1.0.5

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.
@@ -0,0 +1,3077 @@
1
+ /**
2
+ * VIBEMANCER - HOOKS API TYPES
3
+ *
4
+ * Types for the hooks-based bot API.
5
+ *
6
+ * UNITS REFERENCE (100 ticks = 1 second):
7
+ * Position: absolute world coordinates, 0-860 on each axis. The arena is 860x860,
8
+ * but only [30, 830] is safe — the outer 30 units are lethal lava.
9
+ * Velocity: units per tick on each axis (player max speed = 1 u/t)
10
+ * Health: hit points (max 60)
11
+ * Ticks: game ticks (10ms each, 100/sec). Divide by 100 for seconds.
12
+ * Angles: degrees (0°=right, 90°=down, 180°=left, 270°=up)
13
+ */
14
+
15
+ /**
16
+ * Enemy wizard state as seen by your bot.
17
+ *
18
+ * Note: you cannot see the enemy's missile configs, cooldown timers, or
19
+ * damage history — only what's visible on the battlefield.
20
+ */
21
+ interface EnemyState {
22
+ /** Enemy position in world coordinates (0-800). */
23
+ position: Position;
24
+ /** Enemy velocity in units/tick. */
25
+ velocity: Velocity;
26
+ /** Enemy current HP (0-60). */
27
+ health: number;
28
+ /** Enemy status: 'idle', 'casting', 'channeling' (shield), or 'gcd_locked'. */
29
+ status: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
30
+ /** Which spell enemy is casting, or null. */
31
+ castingSpell: 'missile' | 'shield' | 'blink' | null;
32
+ /** Cast progress in ticks (0 if not casting). */
33
+ castProgress: number;
34
+ /** Total cast duration in ticks (0 if not casting). */
35
+ castDuration: number;
36
+ /** Remaining GCD ticks (0 if not in GCD). */
37
+ gcdRemaining: number;
38
+ /** Duration the enemy has been channeling in ticks (0 if not channeling). */
39
+ channelDuration: number;
40
+ /** Enemy shield block multiplier (0 if not shielding, 0.3-0.9 if shielding). */
41
+ shieldStrength: number;
42
+ }
43
+ /**
44
+ * Pre-computed analysis of an incoming enemy projectile.
45
+ *
46
+ * All timing values are in ticks (100 ticks = 1 second).
47
+ * Dodge directions are relative to missile heading, not world axes.
48
+ */
49
+ interface AnalyzedThreat {
50
+ /** Unique projectile ID. */
51
+ id: string;
52
+ /** Raw projectile state (position, rotation in degrees, speed in u/t, turnRate, remainingTicks). */
53
+ projectile: ProjectileState;
54
+ /** Ticks until missile hits your current position. Infinity if predicted to miss. */
55
+ ticksToImpact: number;
56
+ /** Whether the missile will hit if you stand still. */
57
+ willHit: boolean;
58
+ /** Whether strafing left (perpendicular to missile heading) avoids it. */
59
+ canDodgeLeft: boolean;
60
+ /** Whether strafing right (perpendicular to missile heading) avoids it. */
61
+ canDodgeRight: boolean;
62
+ /** Whether moving directly away from the missile avoids it. */
63
+ canOutrun: boolean;
64
+ /** Optimal dodge direction as a unit vector {x, y}, or null if undodgeable. */
65
+ bestDodgeDirection: Position | null;
66
+ /** Whether you can channel shield before the missile arrives. */
67
+ canBlockInTime: boolean;
68
+ /** Ticks from now when you should START channeling shield to block in time. */
69
+ ticksToStartShield: number;
70
+ }
71
+ /**
72
+ * Final action that can be returned from a bot.
73
+ * Cannot be further chained.
74
+ */
75
+ interface FinalAction {
76
+ /** Internal: extract the WizardActions */
77
+ readonly _toAction: () => WizardActions;
78
+ }
79
+ /**
80
+ * Action builder that allows chaining .move() for simultaneous movement.
81
+ * Returned by shield(), missile(), and cancel().
82
+ */
83
+ interface ActionBuilder extends FinalAction {
84
+ /**
85
+ * Add movement to this action (e.g., move while casting).
86
+ * Direction vector, not absolute position. Auto-normalized.
87
+ * Positive X = right, positive Y = down.
88
+ */
89
+ move(x: number, y: number): FinalAction;
90
+ }
91
+ /**
92
+ * Wizard function type for the hooks API.
93
+ * Called every tick. Read state with hooks, return an action.
94
+ */
95
+ type WizardFunction = () => FinalAction;
96
+ /**
97
+ * Internal context for game state hooks.
98
+ */
99
+ interface WizardContext {
100
+ entityId: string;
101
+ tick: number;
102
+ position: Position;
103
+ velocity: Velocity;
104
+ health: number;
105
+ maxHealth: number;
106
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
107
+ castingSpell?: 'missile' | 'shield' | 'blink';
108
+ castProgress?: number;
109
+ castDuration?: number;
110
+ channelingSpell?: 'shield';
111
+ channelDuration?: number;
112
+ gcdRemaining?: number;
113
+ blinkCooldown: number;
114
+ lastMissileConfig?: MissileConfig;
115
+ enemies: Array<{
116
+ id: string;
117
+ position: Position;
118
+ velocity: Velocity;
119
+ health: number;
120
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
121
+ castingSpell?: 'missile' | 'shield' | 'blink';
122
+ castProgress?: number;
123
+ castDuration?: number;
124
+ gcdRemaining?: number;
125
+ channelingSpell?: 'shield';
126
+ channelDuration?: number;
127
+ }>;
128
+ projectiles: ProjectileState[];
129
+ myProjectiles: ProjectileState[];
130
+ arenaWidth: number;
131
+ arenaHeight: number;
132
+ damageDealt: number;
133
+ damageTaken: number;
134
+ lastHitTick: number;
135
+ random: () => number;
136
+ }
137
+ /**
138
+ * Context available to missile AI functions via getMissileContext().
139
+ * Provides missile state, the full game state from the owner's perspective,
140
+ * and a seeded PRNG.
141
+ */
142
+ interface MissileContext {
143
+ /** Missile position in world coordinates. */
144
+ position: Position;
145
+ /** Missile heading in degrees (0=right, 90=down). */
146
+ rotation: number;
147
+ /** Missile speed in units/tick. */
148
+ speed: number;
149
+ /** Missile turn rate in degrees/tick. */
150
+ turnRate: number;
151
+ /** Missile damage on hit. */
152
+ damage: number;
153
+ /** Ticks remaining before the missile expires. */
154
+ remainingTicks: number;
155
+ /** ID of the wizard who owns this missile. */
156
+ ownerId: string;
157
+ /** Full game state from the missile owner's perspective. */
158
+ worldState: GameState;
159
+ /** Seeded PRNG [0, 1). Deterministic per missile per tick. */
160
+ random: () => number;
161
+ }
162
+ /**
163
+ * Action returned by a missile AI function.
164
+ * Call turnToward(x, y) to steer, or flyStraight() to coast.
165
+ */
166
+ interface MissileAction {
167
+ /** Internal: extract the MissileActions */
168
+ readonly _toMissileAction: () => MissileActions;
169
+ }
170
+ /**
171
+ * Missile AI function type for the hooks API.
172
+ * Called every tick for each in-flight missile.
173
+ * Read state with getMissileContext(), return a MissileAction.
174
+ */
175
+ type MissileFunction$1 = () => MissileAction;
176
+
177
+ /**
178
+ * VIBEMANCER - TYPES
179
+ *
180
+ * This file contains all the TypeScript interfaces used by the game engine.
181
+ */
182
+ /**
183
+ * Position in 2D space.
184
+ */
185
+ interface Position {
186
+ x: number;
187
+ y: number;
188
+ }
189
+ /**
190
+ * Velocity in 2D space (units per tick).
191
+ */
192
+ interface Velocity {
193
+ x: number;
194
+ y: number;
195
+ }
196
+ /**
197
+ * Wizard state.
198
+ */
199
+ interface WizardState {
200
+ id: string;
201
+ position: Position;
202
+ rotation: number;
203
+ health: number;
204
+ maxHealth: number;
205
+ state: 'idle' | 'casting' | 'channeling' | 'gcd_locked';
206
+ castingSpell?: 'missile' | 'shield' | 'blink';
207
+ castProgress?: number;
208
+ castDuration?: number;
209
+ channelingSpell?: 'shield';
210
+ channelDuration?: number;
211
+ gcdRemaining?: number;
212
+ blinkCooldown: number;
213
+ velocity: Velocity;
214
+ lastMissileConfig?: MissileConfig;
215
+ warmupMultiplier?: number;
216
+ invincible?: boolean;
217
+ }
218
+ /**
219
+ * Projectile (missile) state.
220
+ */
221
+ interface ProjectileState {
222
+ id: string;
223
+ type: 'missile';
224
+ ownerId: string;
225
+ position: Position;
226
+ rotation: number;
227
+ speed: number;
228
+ turnRate: number;
229
+ damage: number;
230
+ remainingTicks: number;
231
+ }
232
+ /**
233
+ * Game configuration (read-only).
234
+ */
235
+ interface GameConfig {
236
+ arenaSize: {
237
+ width: number;
238
+ height: number;
239
+ };
240
+ tickRate: number;
241
+ maxTicks: number;
242
+ }
243
+ /**
244
+ * Full game state passed to wizard.
245
+ */
246
+ interface GameState {
247
+ tick: number;
248
+ position: Position;
249
+ rotation: number;
250
+ health: number;
251
+ maxHealth: number;
252
+ state: WizardState['state'];
253
+ castingSpell?: 'missile' | 'shield' | 'blink';
254
+ castProgress?: number;
255
+ castDuration?: number;
256
+ channelingSpell?: 'shield';
257
+ channelDuration?: number;
258
+ gcdRemaining?: number;
259
+ blinkCooldown: number;
260
+ velocity: Velocity;
261
+ lastMissileConfig?: MissileConfig;
262
+ warmupMultiplier?: number;
263
+ enemies: WizardState[];
264
+ projectiles: ProjectileState[];
265
+ myProjectiles: ProjectileState[];
266
+ damageDealt: number;
267
+ damageTaken: number;
268
+ lastHitTick: number;
269
+ /** Events emitted during the most recent tick (empty for the initial state). */
270
+ events: SimEvent[];
271
+ }
272
+ /**
273
+ * Actions returned by wizard each tick.
274
+ *
275
+ * Movement uses world-space coordinates:
276
+ * - x: +100 = right, -100 = left
277
+ * - y: +100 = down, -100 = up
278
+ * - Diagonal movement is normalized (magnitude capped at 100)
279
+ * - No rotation tracking - just output (x, y) direction
280
+ */
281
+ interface WizardActions {
282
+ /**
283
+ * Movement direction in world-space.
284
+ * Values are clamped to [-100, 100] range.
285
+ * Magnitude is normalized to max 100 for diagonal movement.
286
+ */
287
+ move: {
288
+ x: number;
289
+ y: number;
290
+ };
291
+ /**
292
+ * Start a new cast (only works if state === 'idle').
293
+ */
294
+ startCast?: {
295
+ spell: 'missile';
296
+ config: MissileConfig;
297
+ missileAI: MissileFunction;
298
+ direction?: number;
299
+ } | {
300
+ spell: 'shield';
301
+ } | {
302
+ spell: 'blink';
303
+ target: Position;
304
+ };
305
+ /**
306
+ * Cancel current cast or channel (works if casting or channeling).
307
+ */
308
+ cancel?: boolean;
309
+ /**
310
+ * Update aim direction while casting a missile (degrees).
311
+ * The missile fires in this direction at launch, allowing tracking during cast.
312
+ * Only applies while state === 'casting' and castingSpell === 'missile'.
313
+ */
314
+ aimDirection?: number;
315
+ /**
316
+ * Missile guide — manual play mode only. Takes direct control of a
317
+ * specific missile using WASD/joystick input. While active, the wizard
318
+ * is invulnerable and frozen (move ignored), and the missile steers
319
+ * using its turnRate toward the given direction.
320
+ *
321
+ * direction: {x, y} → converted to target angle via atan2(y, x)
322
+ * direction: null → missile flies straight (no steering input)
323
+ */
324
+ missileGuide?: {
325
+ missileId: string;
326
+ direction: {
327
+ x: number;
328
+ y: number;
329
+ } | null;
330
+ } | null;
331
+ }
332
+ /**
333
+ * Missile configuration.
334
+ */
335
+ interface MissileConfig {
336
+ damage: number;
337
+ speed: number;
338
+ turnRate: number;
339
+ duration: number;
340
+ }
341
+ /**
342
+ * Missile AI function type — re-exported from hooks/types.ts.
343
+ */
344
+ type MissileFunction = MissileFunction$1;
345
+ /**
346
+ * Actions returned by missile each tick.
347
+ */
348
+ interface MissileActions {
349
+ turnToward?: Position;
350
+ turnToAngle?: number;
351
+ }
352
+ interface MissileHitEvent {
353
+ type: 'missile-hit';
354
+ position: Position;
355
+ damage: number;
356
+ actualDamage: number;
357
+ speed: number;
358
+ ownerId: string;
359
+ targetId: string;
360
+ }
361
+ interface MissileExpiredEvent {
362
+ type: 'missile-expired';
363
+ position: Position;
364
+ }
365
+ interface MissileOobEvent {
366
+ type: 'missile-oob';
367
+ position: Position;
368
+ }
369
+ interface BlinkEvent {
370
+ type: 'blink';
371
+ wizardId: string;
372
+ from: Position;
373
+ to: Position;
374
+ }
375
+ interface ShieldStartEvent {
376
+ type: 'shield-start';
377
+ wizardId: string;
378
+ position: Position;
379
+ }
380
+ interface CastStartEvent {
381
+ type: 'cast-start';
382
+ wizardId: string;
383
+ position: Position;
384
+ spell: 'missile' | 'shield' | 'blink';
385
+ }
386
+ interface WizardDeathEvent {
387
+ type: 'wizard-death';
388
+ wizardId: string;
389
+ position: Position;
390
+ }
391
+ interface WizardLavaDeathEvent {
392
+ type: 'wizard-lava-death';
393
+ wizardId: string;
394
+ position: Position;
395
+ }
396
+ interface CastCancelEvent {
397
+ type: 'cast-cancel';
398
+ wizardId: string;
399
+ position: Position;
400
+ spell: 'missile' | 'shield' | 'blink';
401
+ }
402
+ interface MissileLaunchEvent {
403
+ type: 'missile-launch';
404
+ position: Position;
405
+ damage: number;
406
+ speed: number;
407
+ ownerId: string;
408
+ rotation: number;
409
+ }
410
+ interface ShieldBlockEvent {
411
+ type: 'shield-block';
412
+ wizardId: string;
413
+ position: Position;
414
+ damageBlocked: number;
415
+ damageThrough: number;
416
+ }
417
+ type SimEvent = MissileHitEvent | MissileExpiredEvent | MissileOobEvent | MissileLaunchEvent | BlinkEvent | ShieldStartEvent | ShieldBlockEvent | CastStartEvent | CastCancelEvent | WizardDeathEvent | WizardLavaDeathEvent;
418
+
419
+ /**
420
+ * VIBEMANCER - GAME RULES
421
+ *
422
+ * This is the single source of truth for all game constants.
423
+ * All game logic imports from here. Read this to understand the game.
424
+ *
425
+ * SWEEPABLE CONSTANTS — the balance-search ruleset:
426
+ * Every combat-balance constant lives on the mutable `RULES` object. The engine
427
+ * and bots read `RULES.X` so the balance-search optimizer can override any of
428
+ * them at runtime via applyRulesetOverrides() — object property reads are live
429
+ * across every module and survive bundling (unlike a reassigned `let`, which
430
+ * esbuild/Vite snapshot at the import site). Structural constants (arena size,
431
+ * tick rate, hitbox radius, missile floors) stay plain `const`.
432
+ *
433
+ * The UPPER_CASE named exports below (WIZARD_HEALTH, SHIELD_CAST_TIME, …) are
434
+ * default SNAPSHOTS for external/UI/MCP consumers that only need the factory
435
+ * value. They do NOT track overrides — anything that must respond to a sweep
436
+ * reads `RULES.X`.
437
+ */
438
+
439
+ declare const TICKS_PER_SECOND = 100;
440
+ declare const TICK_DURATION_MS = 10;
441
+ /**
442
+ * The mutable ruleset: the single source of truth for every sweepable combat
443
+ * constant. Engine + bots read these via `RULES.X`. Override with
444
+ * applyRulesetOverrides(); restore with resetRuleset().
445
+ */
446
+ declare const RULES: {
447
+ WIZARD_HEALTH: number;
448
+ MOVEMENT_SPEED: number;
449
+ CASTING_MOVEMENT_MULT: number;
450
+ GCD_DURATION: number;
451
+ SHIELD_CAST_TIME: number;
452
+ SHIELD_MAX_BLOCK: number;
453
+ SHIELD_DECAY_PER_SECOND: number;
454
+ SHIELD_MIN_BLOCK: number;
455
+ BLINK_CAST_TIME: number;
456
+ BLINK_RANGE: number;
457
+ BLINK_MAX_COOLDOWN: number;
458
+ BLINK_MIN_COOLDOWN: number;
459
+ KNOCKBACK_DAMAGE_THRESHOLD: number;
460
+ KNOCKBACK_SPEED_PER_DAMAGE: number;
461
+ KNOCKBACK_DELAY: number;
462
+ KNOCKBACK_DECAY: number;
463
+ MISSILE_MIN_CAST_TIME: number;
464
+ MISSILE_BASE_RADIUS: number;
465
+ MISSILE_DAMAGE_RADIUS_SCALE: number;
466
+ MISSILE_BASE_CAST: number;
467
+ MISSILE_DAMAGE_SCALE: number;
468
+ MISSILE_DAMAGE_POWER: number;
469
+ MISSILE_HOMING_COEFF: number;
470
+ MISSILE_TURN_DURATION_COEFF: number;
471
+ MISSILE_SPEED_DURATION_BASELINE: number;
472
+ MISSILE_SPEED_DURATION_COEFF: number;
473
+ WARMUP_MAX_BONUS: number;
474
+ WARMUP_MAX_PENALTY: number;
475
+ };
476
+ declare const WIZARD_HEALTH: number;
477
+ declare const WIZARD_RADIUS = 5;
478
+ declare const MOVEMENT_SPEED: number;
479
+ declare const CASTING_MOVEMENT_MULT: number;
480
+ declare const GCD_DURATION: number;
481
+ declare const SHIELD_CAST_TIME: number;
482
+ declare const SHIELD_MAX_BLOCK: number;
483
+ declare const SHIELD_DECAY_PER_SECOND: number;
484
+ declare const SHIELD_MIN_BLOCK: number;
485
+ declare const BLINK_CAST_TIME: number;
486
+ declare const BLINK_RANGE: number;
487
+ declare const BLINK_MAX_COOLDOWN: number;
488
+ declare const BLINK_MIN_COOLDOWN: number;
489
+ /** @deprecated Use BLINK_MAX_COOLDOWN */
490
+ declare const BLINK_COOLDOWN: number;
491
+ declare const KNOCKBACK_DAMAGE_THRESHOLD: number;
492
+ declare const KNOCKBACK_SPEED_PER_DAMAGE: number;
493
+ declare const KNOCKBACK_DELAY: number;
494
+ declare const KNOCKBACK_DECAY: number;
495
+ declare const ARENA_SIZE = 860;
496
+ declare const LAVA_BORDER_WIDTH = 30;
497
+ declare const ARENA_MIN = 30;
498
+ declare const ARENA_MAX: number;
499
+ declare const SPAWN_DISTANCE = 600;
500
+ declare const MISSILE_MIN_DAMAGE = 1;
501
+ declare const MISSILE_MIN_SPEED = 1.5;
502
+ declare const MISSILE_MIN_DURATION = 10;
503
+ declare const MISSILE_MIN_CAST_TIME: number;
504
+ declare const MISSILE_BASE_RADIUS: number;
505
+ declare const MISSILE_DAMAGE_RADIUS_SCALE: number;
506
+ /**
507
+ * Calculate missile hitbox radius based on damage.
508
+ */
509
+ declare function calculateMissileRadius(damage: number): number;
510
+ declare const MISSILE_BASE_CAST: number;
511
+ declare const MISSILE_DAMAGE_SCALE: number;
512
+ declare const MISSILE_DAMAGE_POWER: number;
513
+ declare const MISSILE_HOMING_COEFF: number;
514
+ declare const MISSILE_TURN_DURATION_COEFF: number;
515
+ declare const MISSILE_SPEED_DURATION_BASELINE: number;
516
+ declare const MISSILE_SPEED_DURATION_COEFF: number;
517
+ /**
518
+ * Maps turnRate to effective cost for the cast time formula.
519
+ * Higher turn rate = more expensive cast. Negative values clamped to 0.
520
+ */
521
+ declare function effectiveTurnRateCost(turnRate: number): number;
522
+ /**
523
+ * Validate and sanitize missile config.
524
+ * Ensures all values meet minimum requirements (Lesson #9).
525
+ */
526
+ declare function validateMissileConfig(config: MissileConfig): MissileConfig;
527
+ /**
528
+ * Calculate missile cast time from config.
529
+ *
530
+ * Base formula:
531
+ * cast_time = 0.1
532
+ * + 0.226 × damage^(2/3)
533
+ * + 0.12 × effectiveTurnRateCost(turnRate)
534
+ * + 0.10 × (effectiveTurnRateCost(turnRate) × durationSeconds)
535
+ * + 0.025 × (speed × durationSeconds - 1.5)
536
+ *
537
+ * turnRate is clamped to >= 0. Cost is linear.
538
+ *
539
+ * If lastMissileConfig is a MissileConfig, applies warmup multiplier:
540
+ * - Similar to previous: up to 20% faster
541
+ * - Very different: up to 20% slower (switching penalty)
542
+ */
543
+ declare function calculateMissileCastTime(config: MissileConfig, lastMissileConfig?: MissileConfig | undefined | null): number;
544
+ declare const WARMUP_MAX_BONUS: number;
545
+ declare const WARMUP_MAX_PENALTY: number;
546
+ declare const WARMUP_SPEED_TOLERANCE = 3;
547
+ declare const WARMUP_TURN_TOLERANCE = 1;
548
+ declare const WARMUP_DURATION_TOLERANCE = 50;
549
+ /**
550
+ * Calculate how similar two missile configs are (0 to 1).
551
+ * Returns 1 for identical configs, 0 for very different ones.
552
+ * Used by the warmup system to determine cast time multiplier.
553
+ *
554
+ * Only compares speed, turnRate, and duration — these define the missile
555
+ * "style" (melee stab vs ranged homing vs fast snipe). Damage is excluded
556
+ * because varying power doesn't change playstyle.
557
+ */
558
+ declare function calculateMissileSimilarity(prev: MissileConfig | undefined, current: MissileConfig): number;
559
+ /**
560
+ * Calculate the cast time multiplier from the warmup system.
561
+ * Returns < 1 for bonus (faster), > 1 for penalty (slower), 1 for neutral.
562
+ *
563
+ * Similar to previous cast → multiplier approaches (1 - MAX_BONUS) = 0.80
564
+ * Very different from previous → multiplier approaches (1 + MAX_PENALTY) = 1.20
565
+ * No previous cast → full bonus (1 - MAX_BONUS) = 0.80
566
+ */
567
+ declare function calculateWarmupMultiplier(prev: MissileConfig | undefined, current: MissileConfig): number;
568
+ declare const MATCH_DURATION = 30000;
569
+ declare const DEFAULT_SEED = 42;
570
+ declare const MAX_HEALTH: number;
571
+ declare const COLLISION_RADIUS = 5;
572
+ declare const MOVE_SPEED: number;
573
+ declare const MISSILE_RADIUS_PER_DAMAGE: number;
574
+ declare const SHIELD_MAX_STRENGTH: number;
575
+ declare const SHIELD_MIN_STRENGTH: number;
576
+ declare const SHIELD_DECAY_RATE: number;
577
+ declare const BLINK_MAX_RANGE: number;
578
+ /**
579
+ * Calculate blink cooldown based on distance traveled.
580
+ * Short blinks get short cooldowns, full-range blinks get the maximum.
581
+ */
582
+ declare function calculateBlinkCooldown(distance: number): number;
583
+ declare const ARENA_WATER_BUFFER = 200;
584
+ /**
585
+ * Search bounds for each sweepable constant. The current value is the start.
586
+ * Every key here is read by the engine/bots through `RULES.X`, so overrides
587
+ * take effect across the whole simulation.
588
+ */
589
+ declare const RULESET_RANGES: Record<string, {
590
+ min: number;
591
+ max: number;
592
+ }>;
593
+ /** Merge overrides onto the RULES object and apply them globally. */
594
+ declare function applyRulesetOverrides(overrides: Record<string, number>): void;
595
+ /** Restore all swept constants to their factory defaults. */
596
+ declare function resetRuleset(): void;
597
+ /** Current value of every sweepable constant (the optimizer's starting point). */
598
+ declare function currentRuleset(): Record<string, number>;
599
+
600
+ /**
601
+ * Engine version — a stable content hash of packages/core/src.
602
+ *
603
+ * Derived by `scripts/update-engine-version.mjs` from the engine sources, so it changes
604
+ * only when the engine changes — NOT on every build.
605
+ * The same value is propagated to `packages/functions/src/engine-version.generated.ts`
606
+ * so cloud functions and the core engine always agree on one version.
607
+ *
608
+ * Used to gate spectator replays: a recorded match can only be re-simulated when
609
+ * the runtime engine version matches the version that produced the match.
610
+ */
611
+ declare const ENGINE_VERSION = 4396905295552957;
612
+
613
+ /**
614
+ * VIBEMANCER — BOT COMPUTE BUDGET
615
+ *
616
+ * The real-time guard, moved off the whole fight and onto each bot.
617
+ *
618
+ * Decision 0002: fight LENGTH is simulation time (`maxTicks`) and always was; "stop a bot
619
+ * looping forever" genuinely needs real time. Conflating both into one wall-clock timeout
620
+ * around the entire match meant a slow SERVER was indistinguishable from a broken bot — and
621
+ * matchmaking blamed the player for it, up to auto-deactivating their bot.
622
+ *
623
+ * The constraint that shapes this module: the tick loop runs INSIDE the isolate, where the
624
+ * only clock is `Date.now()`. There is no way to measure a bot in machine-independent units
625
+ * from in there. So this guard is wall-clock, and wall clock on a shared server is exactly
626
+ * the thing that caused the original bug.
627
+ *
628
+ * The resolution is therefore in what going over budget COSTS:
629
+ *
630
+ * - A bot has ONE budget: total thinking time across a whole fight.
631
+ * - Spend it and the bot is not called again for the rest of the fight. It stands still.
632
+ * - That is never recorded as an error, so it cannot increment `consecutiveCrashes` and
633
+ * cannot auto-deactivate a bot.
634
+ *
635
+ * A bot too slow to answer loses the fight it was too slow for, which is the same thing that
636
+ * happens to a lagging player in any real-time game. A busy server can cost someone a match;
637
+ * it must never cost them their bot.
638
+ *
639
+ * ## Why there is no per-tick limit
640
+ *
641
+ * There was one, briefly: overrun 50ms in a single tick and that tick's action was
642
+ * discarded. It had to go, and the reason is the important part of this file.
643
+ *
644
+ * This engine is DETERMINISTIC by design. Spectate re-simulates a recorded match and gates
645
+ * on ENGINE_VERSION precisely so that the same version and seed reproduce the same fight. A
646
+ * per-tick threshold breaks that: under load a single call can cross 50ms through a GC pause
647
+ * or a scheduler hiccup, its action is discarded, and the fight diverges. Outcomes then
648
+ * depend on how busy the machine was — which is the original bug, reintroduced at finer
649
+ * granularity by the thing meant to fix it. It was caught by a test that passed alone and
650
+ * failed inside a loaded run.
651
+ *
652
+ * A single cumulative budget does not have that problem in practice. Measurement still
653
+ * varies with load, but it only changes BEHAVIOUR at one point — exhaustion — and an honest
654
+ * bot never approaches it: the worst real bot measured spends 5.6s of a 45s allowance. So
655
+ * every legitimate fight is bit-identical to an unbudgeted one, and determinism holds.
656
+ *
657
+ * A bot that stalls inside one tick is left to the outer wall-clock backstop, which is the
658
+ * only thing that could ever catch it anyway: a `while(true)` cannot be interrupted from
659
+ * inside a single-threaded isolate, no matter what the tick loop measures.
660
+ *
661
+ * Everything here is pure arithmetic so it can be tested exhaustively. The only impure part
662
+ * — reading the clock — stays in the tick loop.
663
+ *
664
+ * A note on precision, because it looks broken and is not. `Date.now()` resolves to 1ms here
665
+ * (measured), while a typical bot call is microseconds — so nearly every individual call
666
+ * measures 0ms and contributes nothing. That is fine, and deliberately not "fixed": a call
667
+ * lasting d milliseconds (d < 1) straddles a millisecond boundary with probability d, so it
668
+ * reads 1 exactly that often and 0 otherwise. The expected measurement equals the true
669
+ * duration, which over the thousands of calls in a fight is what a cumulative budget needs.
670
+ * Swapping in a higher-resolution clock is not an option anyway: inside the isolate there is
671
+ * no other clock, and a per-call `performance.now()` would cost more than it measures.
672
+ */
673
+ /** Limits applied to a single bot for one fight. */
674
+ interface BudgetLimits {
675
+ /** Milliseconds a bot may spend thinking, in total, before it stops being called. */
676
+ totalMs: number;
677
+ }
678
+ /** A single bot's running spend for one fight. */
679
+ interface BotBudgetState {
680
+ spentMs: number;
681
+ exhausted: boolean;
682
+ }
683
+ /**
684
+ * Default, sized from measurement (2026-08-30) — and resized once, after the first
685
+ * measurement turned out to be worthless.
686
+ *
687
+ * The first pass measured TargetDummy, a bot whose entire body is `return idle()`. Against
688
+ * that, a full-length 30,000-tick match costs ~196ms and any budget looks generous. Real
689
+ * built-in bots are nothing like it. One `fight()` — ten matches — between two of them:
690
+ *
691
+ * Bonemancer vs Turtle 18392ms
692
+ * Bonemancer vs Spellseeker 11251ms
693
+ * Turtle vs Hogger 10185ms
694
+ *
695
+ * and instrumenting the calls shows bot code is 70-78% of that, one honest bot spending
696
+ * 5611ms in a single fight. A 20s budget, which had looked like 200x headroom, was really
697
+ * about 2-4x — it would have fired on innocent play the first time the server was busy,
698
+ * which is the exact bug it exists to prevent.
699
+ *
700
+ * Hence 45s per bot per fight: roughly 8x the honest worst case measured here. That margin
701
+ * is also what keeps fights deterministic, since behaviour only changes if it is reached.
702
+ *
703
+ * This exists to catch runaway code, not to make anyone optimise.
704
+ */
705
+ declare const DEFAULT_BUDGET: BudgetLimits;
706
+ /**
707
+ * Last-resort wall-clock backstop for a whole fight (ms).
708
+ *
709
+ * Lives here, next to the budget, because the two numbers only make sense together: the
710
+ * budget is what bounds bot compute, and this is only for the case no in-isolate guard can
711
+ * reach — a bot in `while(true)`, which cannot be interrupted from inside a single-threaded
712
+ * isolate no matter what the tick loop measures.
713
+ *
714
+ * One runaway bot (45s of budget) plus an honest opponent has to fit inside it, or the
715
+ * backstop fires first and the budget never gets to attribute anything. It is capped at 110s
716
+ * rather than raised further because the mcp Cloud Function's own `timeoutSeconds` is 120 —
717
+ * above that the platform kills the request first and nothing useful is reported.
718
+ *
719
+ * It is a single exported constant precisely because it was previously four separate
720
+ * literals (bundle-fight, sandbox twice, functions/fight-runner) that drifted apart.
721
+ */
722
+ declare const DEFAULT_FIGHT_BACKSTOP_MS = 110000;
723
+ /**
724
+ * Both bots' budgets for ONE FIGHT.
725
+ *
726
+ * The scope matters more than it looks. `fight()` is not one simulation, it is ten (five
727
+ * spawn distances, each played from both sides). A budget scoped to a single `simulate`
728
+ * would hand a runaway bot its whole total ten times over — 450 seconds of bot compute
729
+ * inside a 110-second backstop — and would look like it was bounding something while
730
+ * bounding nothing. So the budget belongs to the fight, and is carried across its matches.
731
+ *
732
+ * This is the one mutable thing in this module: `simulate` updates `states` in place as it
733
+ * runs so the spend survives from one match to the next.
734
+ */
735
+ interface FightBudget {
736
+ states: [BotBudgetState, BotBudgetState];
737
+ limits: BudgetLimits;
738
+ }
739
+ /** A fresh budget for one bot at the start of a fight. */
740
+ declare function createBudgetState(): BotBudgetState;
741
+ /** A fresh budget covering both bots for one whole fight (all of its matches). */
742
+ declare function createFightBudget(limits?: BudgetLimits): FightBudget;
743
+ /** May this bot still be called at all? */
744
+ declare function mayAct(state: BotBudgetState): boolean;
745
+ /**
746
+ * Record what one call cost.
747
+ *
748
+ * A non-finite elapsed time is ignored rather than charged, and a negative one cannot refund
749
+ * budget — `Date.now()` can step backwards on an NTP correction or a VM migration, and that
750
+ * must not become a way to earn compute.
751
+ */
752
+ declare function recordSpend(state: BotBudgetState, limits: BudgetLimits, elapsedMs: number): BotBudgetState;
753
+
754
+ interface InternalWizardState extends WizardState {
755
+ missileConfig?: MissileConfig;
756
+ missileAI?: MissileFunction$1;
757
+ blinkTarget?: {
758
+ x: number;
759
+ y: number;
760
+ };
761
+ damageDealt: number;
762
+ damageTaken: number;
763
+ lastHitTick: number;
764
+ knockbackVx?: number;
765
+ knockbackVy?: number;
766
+ knockbackDelay?: number;
767
+ knockbackPendingVx?: number;
768
+ knockbackPendingVy?: number;
769
+ }
770
+ /**
771
+ * Initialize a new match state.
772
+ */
773
+ declare function createInitialState(_seed: number, spawnDist?: number): GameState;
774
+ /**
775
+ * Process one game tick.
776
+ */
777
+ declare function tick(currentTick: number, wizard1AI: WizardFunction, wizard2AI: WizardFunction, config: GameConfig, wizards: InternalWizardState[], projectiles: ProjectileState[], missileAIs: Map<string, MissileFunction$1>, matchSeed: number, budgets?: {
778
+ states: [BotBudgetState, BotBudgetState];
779
+ limits: BudgetLimits;
780
+ }): {
781
+ nextTick: number;
782
+ wizards: InternalWizardState[];
783
+ projectiles: ProjectileState[];
784
+ events: SimEvent[];
785
+ errors: BotError[];
786
+ budgets?: [BotBudgetState, BotBudgetState];
787
+ };
788
+ /**
789
+ * Get the game state from a specific player's perspective.
790
+ * Returns a deep clone to prevent mutation of history entries.
791
+ * Used for history recording where independent snapshots are needed.
792
+ */
793
+ declare function getPlayerState(playerIndex: number, wizards: InternalWizardState[], projectiles: ProjectileState[], tick: number, events?: SimEvent[]): GameState;
794
+ /** Winner of a single match: a wizard ID, 'draw' (simultaneous kill), or null (timeout). */
795
+ type MatchWinner = 'wizard-1' | 'wizard-2' | 'draw' | null;
796
+ /** Winner of a fight (aggregate): a wizard ID or 'draw'. Never null. */
797
+ type FightWinner = 'wizard-1' | 'wizard-2' | 'draw';
798
+ /**
799
+ * Result of a simulation.
800
+ */
801
+ /** A runtime error captured from a bot or missile AI function. */
802
+ interface BotError {
803
+ tick: number;
804
+ entityId: string;
805
+ message: string;
806
+ }
807
+ interface SimulateResult {
808
+ /** 'wizard-1'/'wizard-2' = killed opponent, 'draw' = simultaneous kill, null = timeout */
809
+ winner: MatchWinner;
810
+ ticks: number;
811
+ finalState: GameState;
812
+ history: GameState[];
813
+ /** Runtime errors thrown by bot or missile AI functions (empty if no errors). */
814
+ errors: BotError[];
815
+ }
816
+ /**
817
+ * Result of a fight (best-of-5 at different spawn distances).
818
+ */
819
+ interface FightResult {
820
+ wizard1Wins: number;
821
+ wizard2Wins: number;
822
+ draws: number;
823
+ /** Winner of the fight: 'wizard-1', 'wizard-2', or 'draw' (never null) */
824
+ winner: FightWinner;
825
+ /**
826
+ * Individual match results (one per spawn distance, non-swapped only).
827
+ * Used for visual playback in the web viewer. Scoring includes both sides.
828
+ */
829
+ matches: SimulateResult[];
830
+ }
831
+ /** Spawn distances for the 5 matches in a fight (creates butterfly effect variation) */
832
+ declare const FIGHT_SPAWN_DISTANCES: number[];
833
+ /**
834
+ * Run a fight: 10 matches (5 spawn distances × 2 sides) between two bots.
835
+ * Each spawn distance is played twice — once with each bot on each side —
836
+ * to ensure results are independent of starting position.
837
+ *
838
+ * The `matches` array contains only the 5 non-swapped matches (for visual playback).
839
+ * The scoring aggregates (wizard1Wins, wizard2Wins, draws) include all 10 matches.
840
+ *
841
+ * This is the standard way to determine who wins a matchup.
842
+ * Used by both the tournament system and the visual UI.
843
+ */
844
+ declare function fight(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: {
845
+ seed?: number;
846
+ maxTicks?: number;
847
+ /**
848
+ * Per-bot compute budget for the WHOLE fight — all ten matches share it. Omitted
849
+ * means unbudgeted. See bot-compute-budget.ts.
850
+ */
851
+ budgetLimits?: BudgetLimits;
852
+ }): FightResult;
853
+ /**
854
+ * Run a full match simulation.
855
+ *
856
+ * @param options.skipHistory - When true, skips recording per-tick history snapshots.
857
+ * This dramatically improves performance (no deep cloning per tick) and is used
858
+ * by the optimizer and fight() scoring. The returned history array will be empty
859
+ * and finalState will still be populated.
860
+ */
861
+ declare function simulate(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: {
862
+ maxTicks?: number;
863
+ seed?: number;
864
+ spawnDistance?: number;
865
+ skipHistory?: boolean;
866
+ /**
867
+ * Per-bot compute budget for this match alone. Omitted means unbudgeted, which is
868
+ * what manual play and most tests want — the clock is then never read at all. See
869
+ * bot-compute-budget.ts for why exceeding it costs a bot its action rather than
870
+ * producing an error.
871
+ */
872
+ budgetLimits?: BudgetLimits;
873
+ /**
874
+ * A budget SHARED across every match of a fight, updated in place as this match
875
+ * runs. This is what `fight()` passes, because a fight is ten matches and a
876
+ * per-match budget would bound nothing. Takes precedence over `budgetLimits`.
877
+ */
878
+ budget?: FightBudget;
879
+ }): SimulateResult;
880
+
881
+ /**
882
+ * VIBEMANCER - HOOKS RUNTIME
883
+ *
884
+ * This file implements a minimal React-like hooks runtime for AI programming.
885
+ * It supports useState, useEffect, useMemo, useRef, and useParam with entity isolation.
886
+ *
887
+ * RULES OF HOOKS (same as React):
888
+ * - Hooks must be called at the top level of the bot function
889
+ * - Hooks must be called in the same order every tick
890
+ * - Hooks must NOT be called conditionally
891
+ *
892
+ * Violating these rules throws an error (detected via hook index validation).
893
+ */
894
+
895
+ interface HookState {
896
+ values: unknown[];
897
+ effects: {
898
+ callback: () => void | (() => void);
899
+ deps?: unknown[];
900
+ cleanup?: () => void;
901
+ }[];
902
+ memos: {
903
+ value: unknown;
904
+ deps?: unknown[];
905
+ }[];
906
+ /** Type of each hook call in order (for validation). */
907
+ hookTypes: string[];
908
+ /** Total hooks called on first successful tick. */
909
+ hookCount: number;
910
+ /** Whether the first tick has completed successfully (hook pattern established). */
911
+ initialized: boolean;
912
+ }
913
+ /**
914
+ * Validate a hook call and return its sequential index.
915
+ * Ensures hooks are called in the same order every tick.
916
+ *
917
+ * On the first tick: records the hook type at this index.
918
+ * On subsequent ticks: validates the hook type matches.
919
+ *
920
+ * @param type - The hook type name (e.g., 'useState', 'useEffect', 'useParam')
921
+ * @returns The sequential hook index
922
+ * @throws If called outside runWithHooks or if hook order changed
923
+ */
924
+ declare function validateHookCall(type: string): number;
925
+ /**
926
+ * Run a function with a specific entity's hook context.
927
+ */
928
+ declare function runWithHooks<T>(entityId: string, fn: () => T): T;
929
+ /**
930
+ * Run a bot function with full context (game state + persistence hooks).
931
+ * Use this when you need to set BOTH the entity ID and the game context.
932
+ */
933
+ declare function runWizardWithContext<T>(entityId: string, context: WizardContext, fn: () => T): T;
934
+ /**
935
+ * Run a function with game state context only, preserving the current entity ID.
936
+ * Used by the simulation to set up WizardContext before calling hooks-style bots.
937
+ */
938
+ declare function withWizardContext<T>(context: WizardContext, fn: () => T): T;
939
+ /**
940
+ * Get the current bot context. Throws if called outside bot execution.
941
+ */
942
+ declare function getWizardContext(): WizardContext;
943
+ /**
944
+ * Run a function with missile context set, preserving the current entity ID.
945
+ * Used by the simulation to set up MissileContext before calling hooks-style missile AIs.
946
+ */
947
+ declare function withMissileContext<T>(context: MissileContext, fn: () => T): T;
948
+ /**
949
+ * Get the current missile context. Throws if called outside missile AI execution.
950
+ */
951
+ declare function getMissileContext(): MissileContext;
952
+ /**
953
+ * Persist state between ticks.
954
+ */
955
+ declare function useState<T>(initialValue: T | (() => T)): [T, (newValue: T | ((prev: T) => T)) => void];
956
+ /**
957
+ * React to state changes.
958
+ */
959
+ declare function useEffect(callback: () => void | (() => void), deps?: unknown[]): void;
960
+ /**
961
+ * Memoize expensive calculations.
962
+ */
963
+ declare function useMemo<T>(factory: () => T, deps?: unknown[]): T;
964
+ /**
965
+ * Mutable reference that persists across ticks.
966
+ * Unlike useState, mutations don't need a setter - just modify .current directly.
967
+ */
968
+ interface RefObject<T> {
969
+ current: T;
970
+ }
971
+ declare function useRef<T>(initialValue: T): RefObject<T>;
972
+ /**
973
+ * Clear hook state for an entity (e.g., when it dies).
974
+ */
975
+ declare function clearHooks(entityId: string): void;
976
+ /**
977
+ * Reset all hook states (e.g., when a match restarts).
978
+ */
979
+ declare function resetAllHooks(): void;
980
+
981
+ /**
982
+ * Move a wizard based on world-space input direction.
983
+ *
984
+ * Any vector works: direction is preserved, speed is clamped to [0, 1].
985
+ * (0.5, 0) = half speed right. (300, 200) = full speed at 33.7°.
986
+ */
987
+ declare function moveWizard(wizard: WizardState, move: {
988
+ x: number;
989
+ y: number;
990
+ }, deltaTicks: number): Position;
991
+ /**
992
+ * Move a projectile in its current rotation direction.
993
+ */
994
+ declare function moveProjectile(projectile: ProjectileState, deltaTicks: number): Position;
995
+ /**
996
+ * Clamp a position to the full arena bounds (0-860).
997
+ * No playfield clamping — wizards CAN walk/blink into lava.
998
+ */
999
+ declare function clampToArena(position: Position, radius: number): Position;
1000
+ /**
1001
+ * Check if a position is in the lava zone (outside the playfield).
1002
+ * Lava zones: [0, ARENA_MIN] and [ARENA_MAX, ARENA_SIZE] on each axis.
1003
+ */
1004
+ declare function isInLava(position: Position, radius: number): boolean;
1005
+ /**
1006
+ * Resolve body collision between two wizards.
1007
+ * Pushes both apart equally so they don't overlap. Neither is blocked — they just can't stack.
1008
+ * Iterates until stable: wizard push → wall clamp → re-check overlap → repeat.
1009
+ */
1010
+ declare function resolveWizardCollision(wizard1: WizardState, wizard2: WizardState): void;
1011
+ /**
1012
+ * Perform swept circle collision detection between a moving point (projectile) and a stationary circle (wizard).
1013
+ * Returns true if a collision occurred during the movement from oldPos to newPos.
1014
+ */
1015
+ declare function sweptCircleCollision(oldPos: Position, newPos: Position, radius: number, targetPos: Position, targetRadius: number): boolean;
1016
+
1017
+ /**
1018
+ * Start casting a spell.
1019
+ * For missiles, applies warmup system (bonus for similar, penalty for switching).
1020
+ */
1021
+ declare function startCast(wizard: WizardState, spell: 'missile' | 'shield' | 'blink', config?: MissileConfig): void;
1022
+ /**
1023
+ * Cancel the current cast.
1024
+ */
1025
+ declare function cancelCast(wizard: WizardState): void;
1026
+ /**
1027
+ * Complete the current cast and trigger the spell effect.
1028
+ */
1029
+ declare function completeCast(wizard: WizardState): void;
1030
+ /**
1031
+ * Update the shield channel state.
1032
+ */
1033
+ declare function updateShield(wizard: WizardState, deltaTicks: number): void;
1034
+ /**
1035
+ * Calculate the current block percentage of a shield based on channel duration.
1036
+ */
1037
+ declare function calculateShieldBlock(channelDurationTicks: number): number;
1038
+ /**
1039
+ * Apply damage to a wizard, considering shield mitigation.
1040
+ *
1041
+ * Shield blocks a percentage of damage based on channel duration:
1042
+ * - Fresh shield (0s): 90% block → 10% damage through
1043
+ * - Decayed shield: block % decreases over time (20%/sec)
1044
+ * - Minimum: 30% block → 70% damage through
1045
+ *
1046
+ * (Design doc lines 196-212)
1047
+ */
1048
+ declare function applyDamage(wizard: WizardState, damage: number, _projectile?: ProjectileState): number;
1049
+
1050
+ /**
1051
+ * VIBEMANCER - MANUAL MATCH
1052
+ *
1053
+ * Tick-by-tick match runner used by manual play mode. Wraps the same
1054
+ * `tick()` primitive that `simulate()` uses, so stepping forward
1055
+ * produces the same trajectory as a batched `simulate()` with the
1056
+ * same seed.
1057
+ *
1058
+ * Extra capabilities over `simulate()`:
1059
+ * - step(N) advances N ticks at a time (default 1) — caller controls pacing
1060
+ * - replaceMissileAI(id, ai) hot-swaps a missile's AI mid-flight (used by
1061
+ * the missile-guide feature in manual play)
1062
+ * - setInvincible(wizardIndex, on) toggles damage immunity per wizard
1063
+ */
1064
+
1065
+ interface ManualMatchOptions {
1066
+ seed?: number;
1067
+ spawnDistance?: number;
1068
+ maxTicks?: number;
1069
+ }
1070
+ interface StepResult {
1071
+ gameState: GameState;
1072
+ errors: BotError[];
1073
+ done: boolean;
1074
+ }
1075
+ declare class ManualMatch {
1076
+ private readonly wizard1AI;
1077
+ private readonly wizard2AI;
1078
+ private readonly seed;
1079
+ private readonly maxTicks;
1080
+ private readonly config;
1081
+ private wizards;
1082
+ private projectiles;
1083
+ private missileAIs;
1084
+ /** First-replacement originals for guided missiles. Used by restoreMissileAI. */
1085
+ private originalMissileAIs;
1086
+ private currentTick;
1087
+ private done;
1088
+ private deathTick;
1089
+ private allErrors;
1090
+ private history;
1091
+ private lastTickEvents;
1092
+ constructor(wizard1AI: WizardFunction, wizard2AI: WizardFunction, options?: ManualMatchOptions);
1093
+ /**
1094
+ * Advance the match by `count` ticks (default 1). Stops early if the
1095
+ * match completes mid-batch.
1096
+ */
1097
+ step(count?: number): StepResult;
1098
+ /**
1099
+ * Hot-swap a missile's AI function. Used by the missile-guide feature
1100
+ * in manual play. The first replacement remembers the original AI so
1101
+ * `restoreMissileAI` can put it back. Subsequent replacements update
1102
+ * the active AI but leave the remembered original alone.
1103
+ *
1104
+ * No-op if the projectile id doesn't exist.
1105
+ */
1106
+ replaceMissileAI(projectileId: string, ai: MissileFunction$1): void;
1107
+ /**
1108
+ * Restore a previously guided missile's original AI function.
1109
+ * No-op if the projectile id doesn't exist or was never guided.
1110
+ */
1111
+ restoreMissileAI(projectileId: string): void;
1112
+ /**
1113
+ * Set the invincibility flag for a wizard. Invincible wizards take 0
1114
+ * damage from all sources.
1115
+ */
1116
+ setInvincible(wizardIndex: 0 | 1, on: boolean): void;
1117
+ /**
1118
+ * Get the current game state from wizard-1's perspective.
1119
+ * Returned object is a deep clone — safe to mutate.
1120
+ */
1121
+ getGameState(): GameState;
1122
+ getCurrentTick(): number;
1123
+ isComplete(): {
1124
+ done: boolean;
1125
+ winner: MatchWinner;
1126
+ };
1127
+ getResult(): SimulateResult;
1128
+ dispose(): void;
1129
+ private computeWinner;
1130
+ }
1131
+
1132
+ /**
1133
+ * VIBEMANCER - MISSILE TEMPLATES
1134
+ *
1135
+ * Reusable missile config + AI factories for manual play and bot examples.
1136
+ * Each factory clamps its inputs to rules.ts minimums and returns a pure
1137
+ * AI function that's safe to register with the engine.
1138
+ */
1139
+
1140
+ interface BaseParams {
1141
+ damage: number;
1142
+ speed: number;
1143
+ duration: number;
1144
+ }
1145
+ interface TurningParams extends BaseParams {
1146
+ turnRate: number;
1147
+ }
1148
+ type StraightParams = BaseParams;
1149
+ type HomingParams = TurningParams;
1150
+ interface SpiralParams extends BaseParams {
1151
+ spiralRadius: number;
1152
+ spiralFreq: number;
1153
+ }
1154
+ interface SeekerParams extends TurningParams {
1155
+ minLockDistance: number;
1156
+ }
1157
+ interface MissileTemplate {
1158
+ config: MissileConfig;
1159
+ ai: MissileFunction$1;
1160
+ }
1161
+ /**
1162
+ * Fire-and-forget missile. No steering — flies in a straight line.
1163
+ */
1164
+ declare function straightMissile(p: StraightParams): MissileTemplate;
1165
+ /**
1166
+ * Homing missile. Steers toward the enemy each tick.
1167
+ */
1168
+ declare function homingMissile(p: HomingParams): MissileTemplate;
1169
+ /**
1170
+ * Spiral missile. Continuously orbits its current heading while advancing.
1171
+ * Uses missileState.remainingTicks as a deterministic phase counter so the
1172
+ * AI is fully pure (no closure state).
1173
+ */
1174
+ declare function spiralMissile(p: SpiralParams): MissileTemplate;
1175
+ /**
1176
+ * Seeker missile. Homes toward the enemy, but only when farther away than
1177
+ * minLockDistance — closer than that, the missile coasts straight (so it
1178
+ * doesn't whirl around a target it's about to hit).
1179
+ */
1180
+ declare function seekerMissile(p: SeekerParams): MissileTemplate;
1181
+
1182
+ /**
1183
+ * Calculate the distance between two points.
1184
+ */
1185
+ declare function distanceTo(a: Position, b: Position): number;
1186
+ /**
1187
+ * Check if two points are within a certain range of each other.
1188
+ */
1189
+ declare function inRange(a: Position, b: Position, range: number): boolean;
1190
+
1191
+ /**
1192
+ * Calculate the angle from one point to another in degrees.
1193
+ * 0° = right, 90° = down, 180° = left, 270° = up.
1194
+ */
1195
+ declare function angleTo(from: Position, to: Position): number;
1196
+ /**
1197
+ * Normalize an angle to the 0-360 range.
1198
+ */
1199
+ declare function normalizeAngle(angle: number): number;
1200
+ /**
1201
+ * Calculate the shortest difference between two angles (-180 to +180).
1202
+ */
1203
+ declare function angleDiff(angleA: number, angleB: number): number;
1204
+ /**
1205
+ * Check if an angle is within a certain range of a target angle.
1206
+ */
1207
+ declare function angleInRange(angle: number, target: number, range: number): boolean;
1208
+
1209
+ /**
1210
+ * Get the position after moving a certain distance in a direction.
1211
+ */
1212
+ declare function moveInDirection(position: Position, angle: number, distance: number): Position;
1213
+ /**
1214
+ * Predict the position after N ticks given current velocity.
1215
+ */
1216
+ declare function predictPosition(position: Position, velocity: Velocity, ticks: number): Position;
1217
+ /**
1218
+ * Calculate the intercept angle for a target moving at a certain velocity.
1219
+ * Returns null if no intercept solution exists.
1220
+ */
1221
+ declare function interceptAngle(shooterPosition: Position, targetPosition: Position, targetVelocity: Velocity, projectileSpeed: number): number | null;
1222
+
1223
+ /**
1224
+ * Find the nearest entity from a list.
1225
+ */
1226
+ declare function findNearest<T extends {
1227
+ position: Position;
1228
+ }>(from: Position, entities: T[]): T | null;
1229
+ /**
1230
+ * Find all entities within a certain range.
1231
+ */
1232
+ declare function findInRange<T extends {
1233
+ position: Position;
1234
+ }>(from: Position, entities: T[], range: number): T[];
1235
+ /**
1236
+ * Sort entities by distance (closest first).
1237
+ */
1238
+ declare function sortByDistance<T extends {
1239
+ position: Position;
1240
+ }>(from: Position, entities: T[]): T[];
1241
+
1242
+ /**
1243
+ * Seeded PRNG utilities for deterministic randomness.
1244
+ *
1245
+ * Each entity (wizard, missile) gets its own random sequence that:
1246
+ * - Is deterministic: same seed = same sequence
1247
+ * - Is isolated: one entity's calls don't affect another's
1248
+ * - Advances state: each call produces a different value
1249
+ */
1250
+ /**
1251
+ * Combine two seeds into one using a simple hash.
1252
+ */
1253
+ declare function hashCombine(a: number, b: number): number;
1254
+ /**
1255
+ * Advance the random state using a Linear Congruential Generator.
1256
+ * Parameters from glibc (widely tested).
1257
+ */
1258
+ declare function nextRandom(state: number): number;
1259
+ /**
1260
+ * Create a seeded random number generator.
1261
+ * Returns a function that produces values in [0, 1) and advances internal state.
1262
+ */
1263
+ declare function createRandom(seed: number): () => number;
1264
+ /**
1265
+ * Create a deterministic seed for an entity based on match seed, entity ID, and tick.
1266
+ * This ensures reproducibility: same match + same entity + same tick = same random sequence.
1267
+ */
1268
+ declare function createEntitySeed(matchSeed: number, entityId: string, tick: number): number;
1269
+
1270
+ /**
1271
+ * VIBEMANCER - SPATIAL UTILITIES
1272
+ *
1273
+ * Direction vectors and arena bounds utilities.
1274
+ */
1275
+
1276
+ /**
1277
+ * Normalize a vector to unit length.
1278
+ * Returns {x: 0, y: 0} for zero-length vectors.
1279
+ */
1280
+ declare function normalize(vector: Position): Position;
1281
+ /**
1282
+ * Get normalized direction vector from one position toward another.
1283
+ * Returns {x: 0, y: 0} if positions are identical.
1284
+ */
1285
+ declare function directionTo(from: Position, to: Position): Position;
1286
+ /**
1287
+ * Get normalized direction vector from one position away from another.
1288
+ * Returns {x: 0, y: 0} if positions are identical.
1289
+ */
1290
+ declare function directionAway(from: Position, to: Position): Position;
1291
+ /**
1292
+ * Clamp a position to valid arena bounds.
1293
+ * Note: For wizard-specific clamping with radius, use clampToArena from physics.ts
1294
+ */
1295
+ declare function clampPositionToArena(position: Position): Position;
1296
+ /**
1297
+ * Get the length/magnitude of a vector.
1298
+ */
1299
+ declare function magnitude(vector: Position): number;
1300
+
1301
+ /**
1302
+ * VIBEMANCER - COMBAT UTILITIES
1303
+ *
1304
+ * Utilities for combat calculations.
1305
+ */
1306
+
1307
+ /**
1308
+ * Get cast time in ticks for a missile configuration.
1309
+ * Applies the same clamps/validation as the engine before calculating,
1310
+ * so the result matches the actual cast time that will be used in-game.
1311
+ *
1312
+ * If lastMissileConfig is provided, includes warmup multiplier.
1313
+ * Pass undefined for first cast (full warmup) or null for base time only.
1314
+ */
1315
+ declare function getMissileCastTime(config: MissileConfig, lastMissileConfig?: MissileConfig | null): number;
1316
+ /**
1317
+ * Calculate the position to aim at to hit a moving target.
1318
+ * Returns the intercept point where a missile would hit the target.
1319
+ *
1320
+ * @param targetPos - Current target position
1321
+ * @param targetVel - Target velocity (units per tick)
1322
+ * @param missileSpeed - Missile speed (units per tick)
1323
+ * @param myPos - Shooter position
1324
+ * @returns The position to aim at
1325
+ */
1326
+ declare function getLeadPosition(targetPos: Position, targetVel: Velocity, missileSpeed: number, myPos: Position): Position;
1327
+ /**
1328
+ * Calculate optimal missile configuration based on target behavior.
1329
+ */
1330
+ declare function getAdaptiveMissileConfig(targetVelocity: Position, distance: number): {
1331
+ speed: number;
1332
+ turnRate: number;
1333
+ damage: number;
1334
+ duration: number;
1335
+ };
1336
+ /**
1337
+ * Given a cast-time budget (in ticks) and a target distance, find the best
1338
+ * missile config that fits. Maximizes damage while ensuring the missile
1339
+ * can reach the target and finishes casting in time.
1340
+ *
1341
+ * Returns null if no useful missile fits in the budget.
1342
+ *
1343
+ * How it works: tries several speed/turnRate templates. For each, calculates
1344
+ * the minimum duration to reach `distance`, then solves the cast-time formula
1345
+ * for the maximum damage that fits within `budgetTicks`.
1346
+ *
1347
+ * If `lastMissileConfig` is provided, accounts for warmup bonus: similar
1348
+ * missiles cast faster, so more damage can fit in the same budget.
1349
+ */
1350
+ /**
1351
+ * Simulate a missile trajectory to find the minimum duration (ticks) needed
1352
+ * to reach a target at the given distance. Works for all turnRate values:
1353
+ * positive (homing) and zero (straight).
1354
+ *
1355
+ * The simulation starts the missile aimed directly at the target and steps
1356
+ * through the trajectory tick by tick. For homing, the missile tracks the
1357
+ * target each tick matching the engine's steering physics.
1358
+ */
1359
+ /**
1360
+ * Simulate a missile trajectory to find the minimum duration (ticks) needed
1361
+ * to reach a target at the given distance. Works for straight (turnRate=0)
1362
+ * and homing (turnRate>0) missiles.
1363
+ *
1364
+ * The missile starts aimed directly at the target at (dist, 0) and steps
1365
+ * through the trajectory tick by tick. For homing, the missile tracks the
1366
+ * target each tick matching the engine's steering physics.
1367
+ *
1368
+ * Returns 500 if the missile cannot reach the target within 500 ticks.
1369
+ */
1370
+ declare function simulateMinDuration(speed: number, turnRateDeg: number, dist: number, collisionRadius?: number): number;
1371
+ declare function fitMissileToBudget(budgetTicks: number, distance: number, options?: {
1372
+ minTurnRate?: number;
1373
+ maxDamage?: number;
1374
+ lastMissileConfig?: MissileConfig;
1375
+ }): MissileConfig | null;
1376
+ /**
1377
+ * Fit a missile config that accounts for the enemy escaping during cast time.
1378
+ *
1379
+ * During casting, the caster moves at CASTING_MOVEMENT_MULT speed while
1380
+ * the enemy moves at full MOVEMENT_SPEED. This means the effective distance
1381
+ * at launch is larger than the current distance. This function iteratively
1382
+ * converges on a missile config whose range covers the escape distance.
1383
+ *
1384
+ * @param currentDistance - Current distance to enemy
1385
+ * @param budgetTicks - Maximum cast time budget in ticks
1386
+ * @param options - Same options as fitMissileToBudget, plus:
1387
+ * - enemyApproaching: if true, enemy is moving toward caster (reduces escape)
1388
+ * - distanceBuffer: flat units added to target distance for safety margin (default 20)
1389
+ * - maxIterations: convergence iterations (default 5)
1390
+ */
1391
+ declare function fitMissileForEscapingTarget(currentDistance: number, budgetTicks: number, options?: {
1392
+ minTurnRate?: number;
1393
+ maxDamage?: number;
1394
+ lastMissileConfig?: MissileConfig;
1395
+ enemyApproaching?: boolean;
1396
+ distanceBuffer?: number;
1397
+ maxIterations?: number;
1398
+ }): MissileConfig | null;
1399
+
1400
+ /**
1401
+ * Get a seeded random number generator. Returns a function that produces
1402
+ * deterministic values in [0, 1) — same seed + same tick = same sequence.
1403
+ * Use this instead of Math.random() so replays are deterministic.
1404
+ */
1405
+ declare function useRandom(): () => number;
1406
+ /**
1407
+ * Get your current health (0-60). Wizard dies at 0.
1408
+ */
1409
+ declare function useHealth(): number;
1410
+ /**
1411
+ * Get your current position as {x, y} in world coordinates (0-860).
1412
+ *
1413
+ * Clamped to [5, 855] — the ARENA bounds minus the wizard radius, NOT the playfield. That
1414
+ * distinction is the difference between living and dying: the playfield is [30, 830] and
1415
+ * everything outside it is lava, so you can walk straight out of the safe area and be
1416
+ * killed. Nothing stops you. Check against ARENA_MIN/ARENA_MAX, not against these numbers.
1417
+ *
1418
+ * (This previously quoted the playfield-sized bounds as the clamp, which told the reader
1419
+ * they were safely fenced in. They are not — see docs-match-engine.test.ts.)
1420
+ */
1421
+ declare function usePosition(): Position;
1422
+ /**
1423
+ * Get your current velocity as {x, y} in units/tick.
1424
+ * Max magnitude is 1 u/t when idle, 0.5 u/t when casting, 0 when channeling shield.
1425
+ */
1426
+ declare function useVelocity(): Velocity;
1427
+ /**
1428
+ * Get your current status:
1429
+ * - 'idle': free to act
1430
+ * - 'casting': casting a spell (missile or blink). Can move at 50% speed.
1431
+ * - 'channeling': channeling shield. Cannot move. Cancel anytime with cancel().
1432
+ * - 'gcd_locked': global cooldown after spell. Can move at full speed, but cannot cast.
1433
+ */
1434
+ declare function useStatus(): 'idle' | 'casting' | 'channeling' | 'gcd_locked';
1435
+ /**
1436
+ * Get ticks until you can start a new spell.
1437
+ *
1438
+ * Returns 0 when idle or channeling (shield can be canceled immediately).
1439
+ * During casting: remaining cast ticks. During GCD: remaining GCD ticks.
1440
+ *
1441
+ * Note: 100 ticks = 1 second.
1442
+ */
1443
+ declare function useTicksUntilReady(): number;
1444
+ /**
1445
+ * Get current shield block multiplier.
1446
+ *
1447
+ * Returns 0 if not channeling shield.
1448
+ * Returns 0.3-0.9 if channeling: starts at 0.9 (blocks 90%), decays by 0.2/sec,
1449
+ * minimum 0.3 (blocks 30%). The remaining damage gets through:
1450
+ * actualDamage = incomingDamage × (1 - shieldStrength).
1451
+ */
1452
+ declare function useShieldStrength(): number;
1453
+ /**
1454
+ * Get all projectiles currently in flight (yours and enemy's).
1455
+ * Used for blink safety calculations and threat analysis.
1456
+ */
1457
+ declare function useProjectiles(): ProjectileState[];
1458
+ /**
1459
+ * Get the config of the last missile you fired, or undefined if none fired yet.
1460
+ * Used for the warmup system: consecutive similar missiles cast faster.
1461
+ */
1462
+ declare function useLastMissileConfig(): MissileConfig | undefined;
1463
+ /**
1464
+ * Get blink cooldown remaining in ticks. Returns 0 if ready to blink.
1465
+ *
1466
+ * Cooldown scales with distance used:
1467
+ * - 100 units → ~100 ticks (1s)
1468
+ * - 300 units (max range) → 2000 ticks (20s)
1469
+ *
1470
+ * Note: 100 ticks = 1 second.
1471
+ */
1472
+ declare function useBlinkCooldown(): number;
1473
+ /**
1474
+ * Get currently casting spell, or null if not casting.
1475
+ * Returns 'missile', 'shield', or 'blink'.
1476
+ */
1477
+ declare function useCastingSpell(): 'missile' | 'shield' | 'blink' | null;
1478
+ /**
1479
+ * Get cast progress as {current, total} in ticks, or null if not casting.
1480
+ *
1481
+ * current = ticks elapsed, total = ticks needed. When current >= total, spell fires.
1482
+ * Note: 100 ticks = 1 second.
1483
+ */
1484
+ declare function useCastProgress(): {
1485
+ current: number;
1486
+ total: number;
1487
+ } | null;
1488
+ /**
1489
+ * Get enemy wizard state.
1490
+ *
1491
+ * Returns position, velocity, health, status, casting spell, and shield strength.
1492
+ * Note: you cannot see the enemy's missile configs or exact cooldown timers —
1493
+ * only their status and what's visible on the field.
1494
+ */
1495
+ declare function useEnemy(): EnemyState;
1496
+ /**
1497
+ * Get all your active (in-flight) projectiles.
1498
+ * Each has position, rotation (degrees), speed (u/t), turnRate, remainingTicks.
1499
+ */
1500
+ declare function useMyProjectiles(): ProjectileState[];
1501
+ /**
1502
+ * Get total damage you've dealt this match.
1503
+ */
1504
+ declare function useDamageDealt(): number;
1505
+ /**
1506
+ * Get total damage you've taken this match.
1507
+ */
1508
+ declare function useDamageTaken(): number;
1509
+ /**
1510
+ * Get the tick number when you last took damage. Returns 0 if never hit.
1511
+ * Compare with useTick() to get ticks since last hit.
1512
+ */
1513
+ declare function useLastHitTick(): number;
1514
+ /**
1515
+ * Get arena dimensions. Default: {width: 860, height: 860} — the FULL arena, lava included.
1516
+ * The safe playfield is [30, 830]; the outer 30 units on every side are lethal.
1517
+ *
1518
+ * Wizards are clamped to [5, 855] (arena bounds minus the radius of 5), which does not keep
1519
+ * them out of the lava.
1520
+ */
1521
+ declare function useArenaSize(): {
1522
+ width: number;
1523
+ height: number;
1524
+ };
1525
+ /**
1526
+ * Get current game tick (starts at 0, increments each tick).
1527
+ * 100 ticks = 1 second. Match ends at 30,000 ticks (5 minutes).
1528
+ */
1529
+ declare function useTick(): number;
1530
+ /**
1531
+ * Get analyzed threats from all incoming enemy projectiles.
1532
+ * Sorted by ticksToImpact (soonest first). Only includes missiles within 500 units
1533
+ * or that are predicted to hit.
1534
+ *
1535
+ * Each threat includes:
1536
+ * - ticksToImpact: ticks until hit (Infinity if will miss)
1537
+ * - willHit: true if missile hits your current position
1538
+ * - canDodgeLeft/Right: whether strafing perpendicular to missile heading works
1539
+ * - canOutrun: whether moving away from missile escapes it
1540
+ * - bestDodgeDirection: {x, y} unit vector to dodge optimally, or null if undodgeable
1541
+ * - canBlockInTime: whether you can raise shield before impact
1542
+ * - ticksToStartShield: when to START channeling shield to block in time
1543
+ */
1544
+ declare function useThreats(): AnalyzedThreat[];
1545
+ /**
1546
+ * Get the most imminent threat, or null if no threats.
1547
+ * Shorthand for useThreats()[0].
1548
+ */
1549
+ declare function useClosestThreat(): AnalyzedThreat | null;
1550
+ /**
1551
+ * Get your missiles analyzed from the enemy's perspective.
1552
+ * Useful to predict when enemy will shield/dodge your attacks.
1553
+ */
1554
+ declare function useMyThreatsToEnemy(): AnalyzedThreat[];
1555
+
1556
+ /**
1557
+ * VIBEMANCER - THREAT ANALYSIS
1558
+ *
1559
+ * Pre-computes threat information for incoming projectiles.
1560
+ * This handles the "subconscious" perception of missile trajectories.
1561
+ */
1562
+
1563
+ /**
1564
+ * Analyze all threats from enemy projectiles.
1565
+ *
1566
+ * @param myPos - Current position of the wizard
1567
+ * @param projectiles - All projectiles in the game
1568
+ * @param myProjectiles - Only the bot's own projectiles (used for filtering)
1569
+ * @param ticksUntilReady - Ticks until wizard can start a new action
1570
+ * @returns Array of analyzed threats sorted by ticksToImpact (soonest first)
1571
+ */
1572
+ declare function analyzeThreats(myPos: Position, projectiles: ProjectileState[], myProjectiles: ProjectileState[], ticksUntilReady: number): AnalyzedThreat[];
1573
+
1574
+ /**
1575
+ * VIBEMANCER - ACTION BUILDERS
1576
+ *
1577
+ * Fluent API for constructing bot actions with type-safe chaining.
1578
+ *
1579
+ * UNITS REFERENCE (100 ticks = 1 second):
1580
+ * Position: absolute world coordinates, 0-860 on each axis (860×860 arena, of which
1581
+ * the outer 30 units on every side are lethal lava — playfield is [30, 830])
1582
+ * Movement: direction vector, magnitude clamped to max 1 (speed in [0, 1])
1583
+ * Speed: units per tick (player moves at 1.5 units/tick = 150 units/sec)
1584
+ * Duration: ticks (divide by 100 for seconds)
1585
+ * Angles: degrees (0°=right, 90°=down, 180°=left, 270°=up)
1586
+ * Damage: raw HP removed on hit (wizard has 60 HP)
1587
+ * Turn rate: degrees per tick the missile can rotate
1588
+ */
1589
+
1590
+ /**
1591
+ * Channel a shield that blocks incoming damage.
1592
+ *
1593
+ * Starts at 90% block, decays by 20% per second, minimum 30%.
1594
+ * Takes 20 ticks (0.2s) to activate. Movement is disabled while channeling.
1595
+ * Cancel anytime with cancel(). Triggers 100-tick (1s) GCD after cancel.
1596
+ *
1597
+ * Can chain .move() — movement applies during the 20-tick cast, NOT during channel.
1598
+ *
1599
+ * @example
1600
+ * return shield(); // shield and stay still
1601
+ * return shield().move(1, 0); // move right while cast starts
1602
+ */
1603
+ declare function shield(): ActionBuilder;
1604
+ /**
1605
+ * Cast a missile spell.
1606
+ *
1607
+ * Cast time scales with damage, speed, duration, and turn rate — bigger missiles
1608
+ * take longer to cast. While casting you move at 50% speed. After firing, 100-tick
1609
+ * (1s) GCD before next spell.
1610
+ *
1611
+ * Repeated similar missiles cast 20% faster (warmup bonus). Switching styles
1612
+ * incurs a 20% penalty.
1613
+ *
1614
+ * Can chain .move() for simultaneous movement while casting.
1615
+ *
1616
+ * @param config - Missile stats:
1617
+ * - damage: HP removed on hit (1-60 typical). Also sets hitbox: radius = 2 + 0.1×damage.
1618
+ * - speed: units/tick (min 1.5). Player moves at 1 u/t, so 5 = 5× player speed.
1619
+ * - duration: ticks the missile lives (min 10). Range ≈ speed × duration.
1620
+ * - turnRate: degrees/tick of homing (0 = straight line, 3 = moderate homing, 5+ = strong).
1621
+ * Negative = no homing + minor speed cost reduction.
1622
+ * @param ai - Called every tick to control missile steering. Use getMissileContext()
1623
+ * to read the missile's state (position, rotation, speed, etc.), the full game
1624
+ * state (worldState), and a seeded PRNG (random). Return turnToward(x, y) to home
1625
+ * toward a position, or flyStraight() to fly straight.
1626
+ * @param direction - Launch angle in degrees (0°=right, 90°=down, 180°=left, 270°=up).
1627
+ * Tip: use Math.atan2(dy, dx) * (180 / Math.PI) to aim at a target.
1628
+ *
1629
+ * @example
1630
+ * // Straight missile aimed at enemy
1631
+ * const angle = Math.atan2(dy, dx) * (180 / Math.PI);
1632
+ * return missile({damage: 15, speed: 6, duration: 200, turnRate: 0}, () => flyStraight(), angle);
1633
+ *
1634
+ * // Homing missile that tracks enemy
1635
+ * return missile(
1636
+ * {damage: 10, speed: 5, duration: 300, turnRate: 3},
1637
+ * () => {
1638
+ * const ctx = getMissileContext();
1639
+ * const enemy = ctx.worldState.enemies[0];
1640
+ * return enemy ? turnToward(enemy.position.x, enemy.position.y) : flyStraight();
1641
+ * },
1642
+ * angle,
1643
+ * );
1644
+ */
1645
+ declare function missile(config: MissileConfig, ai: MissileFunction$1, direction: number): ActionBuilder;
1646
+ /**
1647
+ * Teleport to an absolute position on the arena.
1648
+ *
1649
+ * Max range: 300 units from current position (clamped by engine if further).
1650
+ * Cast time: 10 ticks (0.1s). Cooldown scales with distance:
1651
+ * - 100 units → 100 ticks (1s)
1652
+ * - 300 units → 2000 ticks (20s)
1653
+ *
1654
+ * Cannot chain .move() — blink IS the movement.
1655
+ *
1656
+ * @param x - Target X position (0-800, absolute world coordinate)
1657
+ * @param y - Target Y position (0-800, absolute world coordinate)
1658
+ *
1659
+ * @example
1660
+ * return blink(400, 400); // blink to center
1661
+ * return blink(enemy.position.x, enemy.position.y); // blink to enemy
1662
+ */
1663
+ declare function blink(x: number, y: number): FinalAction;
1664
+ /**
1665
+ * Cancel current cast or channel (e.g. stop shielding to attack).
1666
+ *
1667
+ * Canceling a cast/channel triggers 100-tick (1s) GCD.
1668
+ * Can chain .move() for simultaneous movement.
1669
+ *
1670
+ * @example
1671
+ * return cancel().move(-1, 0); // cancel and dodge left
1672
+ */
1673
+ declare function cancel(): ActionBuilder;
1674
+ /**
1675
+ * Move in a direction without casting any spell.
1676
+ *
1677
+ * This is a **direction vector**, not a target position. Values are in the
1678
+ * range [-1, 1] where 1 = full speed. Larger values (like raw position
1679
+ * deltas) are clamped to full speed automatically.
1680
+ *
1681
+ * @param x - Horizontal direction (positive = right, negative = left)
1682
+ * @param y - Vertical direction (positive = down, negative = up)
1683
+ *
1684
+ * @example
1685
+ * return move(1, 0); // move right at full speed
1686
+ * return move(dx / dist, dy / dist); // normalized unit vector = full speed
1687
+ * return move(enemy.position.x - myPos.x, enemy.position.y - myPos.y); // raw delta = clamped to full speed
1688
+ */
1689
+ declare function move(x: number, y: number): FinalAction;
1690
+ /**
1691
+ * Do nothing — no action, no movement.
1692
+ */
1693
+ declare function idle(): FinalAction;
1694
+ /**
1695
+ * Steer the missile toward a world position.
1696
+ * The engine clamps the actual turn to the missile's turnRate.
1697
+ *
1698
+ * @param x - Target X position (world coordinates)
1699
+ * @param y - Target Y position (world coordinates)
1700
+ */
1701
+ declare function turnToward(x: number, y: number): MissileAction;
1702
+ /**
1703
+ * Steer the missile toward a specific angle (degrees).
1704
+ * The engine clamps the actual turn to the missile's turnRate.
1705
+ *
1706
+ * @param degrees - Target rotation in degrees (0=right, 90=down, 180=left, 270=up)
1707
+ */
1708
+ declare function turnToAngle(degrees: number): MissileAction;
1709
+ /**
1710
+ * Fly straight — no steering this tick.
1711
+ */
1712
+ declare function flyStraight(): MissileAction;
1713
+ /**
1714
+ * Extract MissileActions from a MissileAction.
1715
+ * Used by the engine to get the actual missile action.
1716
+ */
1717
+ declare function extractMissileAction(action: MissileAction): MissileActions;
1718
+ /**
1719
+ * Extract WizardActions from a FinalAction.
1720
+ * Used by the engine to get the actual action.
1721
+ */
1722
+ declare function extractAction(finalAction: FinalAction): WizardActions;
1723
+
1724
+ /**
1725
+ * VIBEMANCER - PARAMETER RUNTIME
1726
+ *
1727
+ * Provides the useParam() hook for bots to declare tunable parameters,
1728
+ * and the infrastructure for the optimizer to inject/discover parameter values.
1729
+ *
1730
+ * Design: Module-level state (JS is single-threaded, no race conditions).
1731
+ * The optimizer sets param values before running a bot, and clears them after.
1732
+ * During discovery, all useParam calls are recorded.
1733
+ *
1734
+ * ## useParam API
1735
+ *
1736
+ * ```typescript
1737
+ * // Basic: just a value, no optimizer config
1738
+ * const damage = useParam('damage', 15);
1739
+ *
1740
+ * // With range: optimizer searches value ± range (sliding window)
1741
+ * const distance = useParam('distance', 350, {range: 150, min: 0});
1742
+ *
1743
+ * // With fixed min/max: optimizer searches [min, max] (fixed bounds)
1744
+ * const damage = useParam('damage', 15, {min: 5, max: 25});
1745
+ *
1746
+ * // With all: range defines search radius, min/max clamp it
1747
+ * const fraction = useParam('fraction', 0.25, {range: 0.2, min: 0, max: 1});
1748
+ *
1749
+ * // With custom step count: optimizer tests 20 values instead of default 10
1750
+ * const distance = useParam('distance', 500, {range: 200, min: 0, steps: 20});
1751
+ * ```
1752
+ *
1753
+ * - **Arg 1** `name` — unique parameter name (must be consistent across ticks)
1754
+ * - **Arg 2** `value` — the actual value used in gameplay. This is what your bot
1755
+ * uses during matches. The optimizer script automatically updates this value.
1756
+ * - **Arg 3** `config` (optional) — optimizer search configuration:
1757
+ * - `range` — search radius: optimizer checks `value ± range`. The auto-optimizer
1758
+ * rewrites `value` after each run, so the search window slides automatically.
1759
+ * - `min` / `max` — hard constraints (e.g., distance ≥ 0, fraction ≤ 1).
1760
+ * When `range` is omitted, these define fixed search bounds (old-style).
1761
+ * - `steps` — how many evenly-spaced values the optimizer tests per pass (default: 10).
1762
+ * - `substeps` — steps to use in refinement passes (passes 2+). Set to 0 to freeze
1763
+ * after pass 1 (ideal for boolean params). Defaults to `steps` if not specified.
1764
+ * - At least `range` or both `min` + `max` must be provided.
1765
+ *
1766
+ * Without optimizer config, useParam simply returns `value` every tick.
1767
+ * With optimizer config, the offline optimizer script can override the value during search.
1768
+ *
1769
+ * ## Rules of Hooks
1770
+ * useParam follows the same rules as useState/useEffect/etc:
1771
+ * - Must be called at the top level of your bot function (not inside conditionals)
1772
+ * - Must be called in the same order every tick
1773
+ * - Violations are detected and throw errors
1774
+ */
1775
+
1776
+ /**
1777
+ * Declaration of a tunable parameter, as discovered by the optimizer.
1778
+ */
1779
+ interface ParamDeclaration {
1780
+ name: string;
1781
+ value: number;
1782
+ range?: number;
1783
+ min?: number;
1784
+ max?: number;
1785
+ steps: number;
1786
+ /** Steps to use in refinement passes (passes 2+). 0 = freeze after pass 1. Defaults to `steps`. */
1787
+ substeps?: number;
1788
+ }
1789
+ /**
1790
+ * Declare a tunable parameter. Returns the current value (optimizer-injected or the provided value).
1791
+ *
1792
+ * @param name - Unique parameter name (consistent across ticks)
1793
+ * @param value - The gameplay value. The auto-optimizer rewrites this in source code.
1794
+ * @param config - Optional optimizer search configuration
1795
+ * @returns The optimizer-injected value during optimization, or `value` during normal play
1796
+ *
1797
+ * @example
1798
+ * // Simple: no optimizer config
1799
+ * const damage = useParam('damage', 15);
1800
+ *
1801
+ * // With range: optimizer searches value ± range (sliding window)
1802
+ * const distance = useParam('distance', 350, {range: 150, min: 0});
1803
+ *
1804
+ * // With fixed min/max: optimizer searches [min, max]
1805
+ * const damage = useParam('damage', 15, {min: 5, max: 25});
1806
+ */
1807
+ declare function useParam(name: string, value: number, config?: {
1808
+ range?: number;
1809
+ min?: number;
1810
+ max?: number;
1811
+ steps?: number;
1812
+ substeps?: number;
1813
+ }): number;
1814
+ /**
1815
+ * Inject parameter values for the next bot execution.
1816
+ * The wrapped bot will read these values via useParam().
1817
+ */
1818
+ declare function setParamValues(values: Record<string, number>): void;
1819
+ /**
1820
+ * Clear injected parameter values. useParam() will return its provided value.
1821
+ */
1822
+ declare function clearParamValues(): void;
1823
+ /**
1824
+ * Start discovery mode. All subsequent useParam() calls with optimizer config
1825
+ * will register their declarations.
1826
+ */
1827
+ declare function startDiscovery(): void;
1828
+ /**
1829
+ * Stop discovery mode and return all discovered parameter declarations.
1830
+ */
1831
+ declare function stopDiscovery(): ParamDeclaration[];
1832
+ /**
1833
+ * Wrap a bot function to inject specific parameter values.
1834
+ * The returned function sets params before calling the bot and clears them after.
1835
+ */
1836
+ declare function wrapWithParams(bot: WizardFunction, params: Record<string, number>): WizardFunction;
1837
+
1838
+ /**
1839
+ * Bot: TargetDummy
1840
+ *
1841
+ * BEHAVIOR: Does absolutely nothing. No movement, no spells, no AI.
1842
+ *
1843
+ * NAMING RATIONALE: "Target Dummy" is universal MMO player vocabulary for the
1844
+ * practice objects found in capital cities. Every WoW/FFXIV player has beaten
1845
+ * on a target dummy to test DPS rotations. That's exactly what this bot is —
1846
+ * a punching bag for testing missile mechanics and baseline damage output.
1847
+ * Nobody calls them "training dummies"; the player term is always "target dummy."
1848
+ *
1849
+ * STANDALONE — no tier progression. It's a test fixture, not a combatant.
1850
+ */
1851
+ declare function TargetDummy(): FinalAction;
1852
+
1853
+ /**
1854
+ * Bot: Rookie
1855
+ *
1856
+ * BEHAVIOR: Stands perfectly still and fires straight (non-homing) missiles at
1857
+ * the enemy. No movement, no dodging, no shielding. Knows one spell and uses
1858
+ * it on cooldown. The wizard equivalent of an FPS player who stands in the open
1859
+ * and holds left-click.
1860
+ *
1861
+ * NAMING RATIONALE: "Rookie" is the universal term for a first-timer who barely
1862
+ * knows what they're doing. This bot is a day-one player who learned how to cast
1863
+ * missile and nothing else. No movement, no defense, just raw "I press the button."
1864
+ * We considered "Noob" (more accurate) but Rookie is less abrasive while conveying
1865
+ * the same thing — a beginner who doesn't know any better.
1866
+ *
1867
+ * STANDALONE — no tier progression. Rookies either learn to play a real class
1868
+ * or quit. This bot represents the rock-bottom of "at least it shoots."
1869
+ */
1870
+ declare function Rookie(): FinalAction;
1871
+
1872
+ /**
1873
+ * Bot: Critter
1874
+ *
1875
+ * BEHAVIOR: Picks random valid actions each tick — random movement, random spells,
1876
+ * random missile configs, random directions. Occasionally cancels its own casts.
1877
+ * Uses engine-provided seeded random for deterministic behavior. Useful for
1878
+ * finding edge cases in the engine, but completely useless in combat.
1879
+ *
1880
+ * NAMING RATIONALE: In WoW, critters are the 1-HP ambient mobs (rabbits, squirrels,
1881
+ * prairie dogs) that wander around doing nothing useful and die to literally anything.
1882
+ * This bot is the wizard equivalent — it flails around randomly and gets destroyed by
1883
+ * anyone with a plan. The word "Critter" immediately tells any gamer "this thing is
1884
+ * helpless and exists only to fill space."
1885
+ *
1886
+ * STANDALONE — no tier progression. Critters don't level up. However, a future
1887
+ * "Hogger" bot could be an elite critter: same chaotic spirit but actually dangerous
1888
+ * (like the famous WoW elite that wipes unprepared lowbies).
1889
+ */
1890
+ declare function Critter(): FinalAction;
1891
+
1892
+ /**
1893
+ * Bot: Hogger
1894
+ *
1895
+ * BEHAVIOR: The elite critter. Chaotic and unpredictable but genuinely dangerous.
1896
+ * Randomly varies missile configs each cast (damage 7-15, speed 3-8, random homing),
1897
+ * moves erratically but still somewhat toward/away from the enemy, shields when
1898
+ * in real danger, and blinks unpredictably. The randomness makes Hogger hard to
1899
+ * predict — you never know if the next missile will be a slow tracker or a fast
1900
+ * snipe. Unlike Critter's pure randomness, Hogger has enough combat awareness
1901
+ * to actually win fights.
1902
+ *
1903
+ * NAMING RATIONALE: In WoW, Hogger is the iconic level 11 elite gnoll in Elwynn
1904
+ * Forest who infamously kills unprepared lowbies. He's technically a basic mob
1905
+ * but hits way harder than expected. This bot is the Critter that learned to
1906
+ * fight — still chaotic, still a bit dumb, but capable of ending you if you
1907
+ * underestimate it. "Hogger" is one of WoW's most recognizable references and
1908
+ * perfectly captures "deceptively dangerous chaos."
1909
+ *
1910
+ * STANDALONE — no tier progression. There's only one Hogger.
1911
+ */
1912
+ declare function Hogger(): FinalAction;
1913
+
1914
+ /**
1915
+ * Bot: Doombringer
1916
+ *
1917
+ * BEHAVIOR: Fires a single maximum-damage homing missile with infinite budget.
1918
+ * No damage cap — goes for the biggest possible hit. Exists as a benchmark to
1919
+ * demonstrate why lower-damage + shield play is superior. Has basic shield
1920
+ * defense but no sophisticated tactics. One fat cast, one fat hit.
1921
+ *
1922
+ * STANDALONE — no tier progression. Benchmark/test bot.
1923
+ */
1924
+ declare function Doombringer(): FinalAction;
1925
+
1926
+ declare function Turtle(): FinalAction;
1927
+
1928
+ /**
1929
+ * Bot: Sentinel
1930
+ *
1931
+ * BEHAVIOR: Stationary tank with last-moment shielding AND two-tier offense.
1932
+ * Like Turtle, never moves and shields at the last moment. Unlike Turtle,
1933
+ * fires bigger missiles (damage 20) when the safe window is large enough,
1934
+ * falling back to Turtle's fast missile (damage 12) when pressed.
1935
+ *
1936
+ * PROGRESSION LINE: Turtle → Sentinel → Golem
1937
+ * - Turtle (tier 1): Stationary, fixed missiles, reactive shield timing
1938
+ * - Sentinel (tier 2): Stationary, two-tier offense (big + fast missiles)
1939
+ * - Golem (tier 3): Immovable fortress, perfect shield timing
1940
+ *
1941
+ * TIER: 2 (enhanced Turtle)
1942
+ */
1943
+ declare function Sentinel(): FinalAction;
1944
+
1945
+ /**
1946
+ * Bot: Golem
1947
+ *
1948
+ * BEHAVIOR: Stationary fortress with perfect shield timing and devastating
1949
+ * counterattacks during enemy vulnerability windows. Reads enemy cast/GCD
1950
+ * state to time punish missiles that land when the enemy can't shield.
1951
+ * Handles multi-missile volleys by holding shield through consecutive impacts.
1952
+ * Uses progressive cast-cancel thresholds for optimal damage trading.
1953
+ *
1954
+ * KEY IMPROVEMENTS OVER SENTINEL:
1955
+ * - Counterattack punish: fires during enemy cast/GCD recovery
1956
+ * - Multi-threat volley awareness: holds shield through consecutive hits
1957
+ * - Progressive cast-cancel: graduated damage thresholds
1958
+ * - Perfect shield timing: uses ticksToStartShield precisely
1959
+ *
1960
+ * PROGRESSION LINE: Turtle → Sentinel → Golem
1961
+ * TIER: 3 (elite Defensive line)
1962
+ */
1963
+ declare function Golem(): FinalAction;
1964
+
1965
+ /**
1966
+ * Bot: Shadowblade
1967
+ *
1968
+ * BEHAVIOR: Melee assassin. Blinks to the enemy, then lands devastating point-blank
1969
+ * stab attacks (15 damage, 30u range, ~60 tick cast = 2-hit kill). Runs directly
1970
+ * at the enemy with minimal strafe, shields undodgeable threats. The entire
1971
+ * strategy is: get close, stab, kill. Simple and brutal.
1972
+ *
1973
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
1974
+ * - Shadowblade (tier 1): Offensive blink, melee stabs, basic shield
1975
+ * - Nightblade (tier 2): + missile-aware blinks, adaptive stabs, timed defense
1976
+ * - Voidblade (tier 3): Future — perfect assassination timing, inescapable engages
1977
+ *
1978
+ * TIER: 1 (base)
1979
+ */
1980
+ declare function Shadowblade(): FinalAction;
1981
+
1982
+ /**
1983
+ * Bot: Nightblade
1984
+ *
1985
+ * BEHAVIOR: Enhanced melee assassin. Same aggressive engagement as Shadowblade —
1986
+ * blinks directly to the enemy and stabs for 15 damage (2-hit kill). The tier 2
1987
+ * upgrade is PREEMPTIVE DEFENSE: Nightblade watches the enemy's cast bar and
1988
+ * shields before a point-blank missile is even launched. At melee range, missiles
1989
+ * arrive almost instantly after launch — too fast to react. Nightblade anticipates
1990
+ * the threat. Also has emergency blink and proper channeling management.
1991
+ *
1992
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
1993
+ * - Shadowblade (tier 1): Offensive blink, melee stabs, basic shield (reactive only)
1994
+ * - Nightblade (tier 2): + preemptive shield vs enemy casts, emergency blink
1995
+ * - Voidblade (tier 3): Future — perfect assassination timing, inescapable engages
1996
+ *
1997
+ * TIER: 2 (enhanced Shadowblade)
1998
+ */
1999
+ declare function Nightblade(): FinalAction;
2000
+
2001
+ /**
2002
+ * Bot: Voidblade
2003
+ *
2004
+ * BEHAVIOR: Reactive counter-puncher. Shields everything, then fires quick stabs
2005
+ * during enemy vulnerability windows (GCD/casting) when they can't shield back.
2006
+ * At melee range, the shield blocks ~90% of incoming damage while Voidblade's
2007
+ * counter-stabs land at full damage — winning through attrition.
2008
+ *
2009
+ * CORE LOOP (melee range):
2010
+ * 1. Enemy casts missile → Voidblade blink-dodges (100% avoid) or shields (90% block)
2011
+ * 2. Enemy enters GCD → Voidblade fires quick stab (lands unblocked)
2012
+ * 3. Voidblade enters GCD → enemy recovers → repeat
2013
+ *
2014
+ * KEY IMPROVEMENTS OVER NIGHTBLADE:
2015
+ * - Blink-dodge priority: avoids 100% of damage when blink available, shields as fallback
2016
+ * - Reads enemy vulnerability to time counter-stabs perfectly
2017
+ * - Cancel-into-defense: aborts own cast if enemy missile incoming
2018
+ * - Punish budget: sizes stabs to fit exactly in the vulnerability window
2019
+ *
2020
+ * PROGRESSION LINE: Shadowblade → Nightblade → Voidblade
2021
+ * TIER: 3 (elite Melee line)
2022
+ */
2023
+ declare function Voidblade(): FinalAction;
2024
+
2025
+ /**
2026
+ * Bot: Bonemancer
2027
+ *
2028
+ * BEHAVIOR: Stands still and fires slow, homing missiles constantly. Every missile
2029
+ * tracks the enemy with turnRate 2 — they curve relentlessly toward the target.
2030
+ * No movement, no shields, just an unending stream of seeking projectiles. The
2031
+ * missiles are slow (speed 3) but long-lived (300 ticks) and will chase you across
2032
+ * the entire arena.
2033
+ *
2034
+ * NAMING RATIONALE: Named after Diablo 2's Bone Necromancer ("Bonemancer"), whose
2035
+ * signature spell Bone Spirit is a slow-moving, auto-tracking projectile that hunts
2036
+ * enemies relentlessly. That's exactly what this bot does — it stands in place and
2037
+ * spams seeking missiles. The homing behavior is the key identity: these aren't
2038
+ * aimed shots, they're heat-seeking spirits that chase you down. Every D2 player
2039
+ * knows the Bonemancer — it's one of the most iconic builds.
2040
+ *
2041
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
2042
+ * - Bonemancer (tier 1): Stationary, spams slow homing missiles
2043
+ * - Lich (tier 2): Future — enhanced homing with adaptive missiles and defense
2044
+ * - Archlich (tier 3): Future — master of tracking magic, undodgeable death swarm
2045
+ * The progression follows the D2 necromancer power fantasy: from bone apprentice
2046
+ * to undead overlord, each tier's missiles become harder to escape.
2047
+ *
2048
+ * TIER: 1 (base)
2049
+ */
2050
+ declare function Bonemancer(): FinalAction;
2051
+
2052
+ /**
2053
+ * Bot: Lich
2054
+ *
2055
+ * BEHAVIOR: Homing missile specialist with strong-tracking adaptive missiles.
2056
+ * Uses fitMissileToBudget with minTurnRate 1.0 — higher than other bots (0.5) —
2057
+ * producing missiles with superior tracking at the cost of some damage/speed.
2058
+ * Strafing launches missiles from different angles, creating multi-angle pressure.
2059
+ *
2060
+ * Shields undodgeable/critical threats, emergency blinks. Cancels missile cast
2061
+ * only for lethal incoming damage.
2062
+ *
2063
+ * KEY DIFFERENCES FROM BONEMANCER:
2064
+ * - Bonemancer: stationary, no defense, fixed d=7/s=3/t=2/dur=300
2065
+ * - Lich: mobile, full defense, adaptive strong-tracking homing missiles
2066
+ *
2067
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
2068
+ * - Bonemancer (tier 1): Stationary, spams fixed slow homing missiles, no defense
2069
+ * - Lich (tier 2): Mobile + defense, adaptive strong-tracking missiles (minTurnRate 1.0)
2070
+ * - Archlich (tier 3): Future — converging web patterns, impossible to escape
2071
+ *
2072
+ * TIER: 2 (enhanced Bonemancer)
2073
+ */
2074
+ declare function Lich(): FinalAction;
2075
+
2076
+ /**
2077
+ * Bot: Archlich
2078
+ *
2079
+ * BEHAVIOR: Lich's proven core (mobile homing specialist) plus vulnerability
2080
+ * exploitation. Defense, movement, and standard offense are identical to Lich.
2081
+ * The T3 advantage: when the enemy is locked in GCD/cast, fires fast straight
2082
+ * punish missiles that land during the vulnerability window.
2083
+ *
2084
+ * PROGRESSION LINE: Bonemancer → Lich → Archlich
2085
+ * TIER: 3 (elite Homing line)
2086
+ */
2087
+ declare function Archlich(): FinalAction;
2088
+
2089
+ /**
2090
+ * Bot: Flamecaller
2091
+ *
2092
+ * BEHAVIOR: Long-range homing missile caster with fixed missile config.
2093
+ * Maintains 350u distance, strafes to dodge, and fires standard homing
2094
+ * missiles (d=10, s=5, t=1, dur=180). Shields undodgeable threats,
2095
+ * emergency blinks. A straightforward ranged caster that trades
2096
+ * consistency for adaptability.
2097
+ *
2098
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
2099
+ * - Flamecaller (tier 1): Fixed homing missiles, basic strafe and defense
2100
+ * - Pyromancer (tier 2): + adaptive fitting, cast canceling, smart fallbacks
2101
+ * - Infernalist (tier 3): Future — overwhelming adaptive fire
2102
+ *
2103
+ * TIER: 1 (base)
2104
+ */
2105
+ declare function Flamecaller(): FinalAction;
2106
+
2107
+ /**
2108
+ * Bot: Pyromancer
2109
+ *
2110
+ * BEHAVIOR: Adaptive homing missile specialist at long range. Maintains 400u
2111
+ * distance, strafes to dodge, and uses fitMissileToBudget with minTurnRate 0.5
2112
+ * to fire the highest-damage homing missile that fits in the safe window.
2113
+ * Shields undodgeable threats, emergency blinks. A versatile ranged caster
2114
+ * that adapts its missiles to the situation.
2115
+ *
2116
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
2117
+ * - Flamecaller (tier 1): Fixed homing missiles, basic strafe and defense
2118
+ * - Pyromancer (tier 2): + adaptive fitting, cast canceling, smart fallbacks
2119
+ * - Infernalist (tier 3): Future — overwhelming adaptive fire
2120
+ *
2121
+ * TIER: 2 (enhanced Flamecaller)
2122
+ */
2123
+ declare function Pyromancer(): FinalAction;
2124
+
2125
+ /**
2126
+ * Bot: Infernalist
2127
+ *
2128
+ * BEHAVIOR: Rapid-fire caster that exploits warmup bonus for accelerating DPS.
2129
+ * Fires consistent homing missiles to build warmup, punishes vulnerability windows
2130
+ * with warmup-boosted fast casts. Proactive blink kiting when enemy closes.
2131
+ *
2132
+ * KEY IMPROVEMENTS OVER PYROMANCER:
2133
+ * - Warmup exploitation: always passes lastMissileConfig for bonus
2134
+ * - Punish mode: straight missiles during enemy vulnerability
2135
+ * - Proactive blink kiting: monitors closing rate
2136
+ * - Progressive cast-cancel: graduated thresholds
2137
+ *
2138
+ * PROGRESSION LINE: Flamecaller → Pyromancer → Infernalist
2139
+ * TIER: 3 (elite Caster line)
2140
+ */
2141
+ declare function Infernalist(): FinalAction;
2142
+
2143
+ /**
2144
+ * Bot: Spellshot
2145
+ *
2146
+ * BEHAVIOR: Uses interceptAngle to calculate where the enemy will be and fires
2147
+ * fast, non-homing missiles (speed 8, turnRate 0) along the predicted path.
2148
+ * Strafes at medium range (300-400), shields undodgeable threats, emergency
2149
+ * blinks when shield isn't available. The key mechanic is PREDICTION — these
2150
+ * missiles don't track, they go exactly where you calculated the enemy would be.
2151
+ *
2152
+ * NAMING RATIONALE: "Spellshot" — a spell that is a single, precisely aimed shot.
2153
+ * Like a sniper's "called shot" but magical. The defining feature is the intercept
2154
+ * calculation: this bot doesn't fire tracking missiles, it calculates the exact
2155
+ * angle needed to hit a moving target. "Shot" implies precision, singular impact,
2156
+ * and skill-based aiming — everything this bot is about.
2157
+ *
2158
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
2159
+ * - Spellshot (tier 1): Basic intercept prediction, non-homing missiles
2160
+ * - Spelltracer (tier 2): Future — predictive homing (missiles that lead AND track)
2161
+ * - Spellseeker (tier 3): Future — perfect prediction, multi-angle attacks
2162
+ * The naming progression: shot (single bullet) → tracer (bullet that tracks a path)
2163
+ * → seeker (actively hunts). Each tier adds more intelligence to the projectile,
2164
+ * evolving from "I calculate where you'll be" to "my missile calculates where you'll be."
2165
+ *
2166
+ * NOTE: A separate future archetype "Spellslinger" (volume-of-fire) is reserved
2167
+ * for a rapid-fire bot that prioritizes quantity over prediction.
2168
+ *
2169
+ * TIER: 1 (base)
2170
+ */
2171
+ declare function Spellshot(): FinalAction;
2172
+
2173
+ /**
2174
+ * Bot: Spelltracer
2175
+ *
2176
+ * BEHAVIOR: Enhanced ranged sniper with adaptive missile fitting and intercept
2177
+ * prediction. Uses fitMissileToBudget to find the highest-damage fast missile
2178
+ * that fits the safe window, then fires it along the predicted intercept angle.
2179
+ * Maintains medium-long range (300-450), shields undodgeable threats with proper
2180
+ * timing, emergency blinks, and distance blinks when cornered. The key mechanic
2181
+ * is still PREDICTION — but now with adaptive damage optimization.
2182
+ *
2183
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
2184
+ * - Spellshot (tier 1): Fixed config intercept prediction, non-homing missiles
2185
+ * - Spelltracer (tier 2): + adaptive fitting, timed defense, distance management
2186
+ * - Spellseeker (tier 3): Future — perfect prediction, multi-angle attacks
2187
+ *
2188
+ * TIER: 2 (enhanced Spellshot)
2189
+ */
2190
+ declare function Spelltracer(): FinalAction;
2191
+
2192
+ /**
2193
+ * Bot: Spellseeker
2194
+ *
2195
+ * BEHAVIOR: Elite sniper that uses intercept-aimed straight missiles during vulnerability
2196
+ * windows. Combines Spelltracer's adaptive fitting with precise lead-position aiming
2197
+ * and vulnerability exploitation. Straight punish missiles at sniper range are nearly
2198
+ * unavoidable. Proactive distance control via closing rate detection.
2199
+ *
2200
+ * KEY IMPROVEMENTS OVER SPELLTRACER:
2201
+ * - Intercept-aimed punish: getLeadPosition + straight missiles during vulnerability
2202
+ * - Proactive distance blink: monitors closing rate, blinks before danger zone
2203
+ * - Progressive cast-cancel: graduated damage thresholds
2204
+ * - Warmup exploitation: always passes lastMissileConfig
2205
+ *
2206
+ * PROGRESSION LINE: Spellshot → Spelltracer → Spellseeker
2207
+ * TIER: 3 (elite Sniper line)
2208
+ */
2209
+ declare function Spellseeker(): FinalAction;
2210
+
2211
+ /**
2212
+ * Bot: Battlemage
2213
+ *
2214
+ * BEHAVIOR: Balanced mid-range duelist. Shields undodgeable threats, interrupts
2215
+ * enemy casts with quick missiles, saves blink for emergencies OR gap-closing.
2216
+ * Switches between quick (10 dmg, fast) and heavy (15 dmg, slow) missile configs
2217
+ * based on safety window and range. Will aggressively trade hits when health allows.
2218
+ * The unique trait is cast-interruption: fires quick missiles specifically when the
2219
+ * enemy is casting, punishing long cast times.
2220
+ *
2221
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
2222
+ * - Battlemage (tier 1): Quick/heavy fixed configs, cast interruption, basic defense
2223
+ * - Warmage (tier 2): Adaptive missile fitting (fitMissileToBudget), smarter attacks
2224
+ * - Archmage (tier 3): Future — supreme duelist, perfect tactical mastery
2225
+ *
2226
+ * TIER: 1 (base)
2227
+ */
2228
+ declare function Battlemage(): FinalAction;
2229
+
2230
+ /**
2231
+ * Bot: Warmage
2232
+ *
2233
+ * BEHAVIOR: Enhanced Battlemage with adaptive missile fitting. Uses fitMissileToBudget
2234
+ * to maximize damage within safe attack windows instead of fixed quick/heavy configs.
2235
+ * Same close-range playstyle: shields undodgeable threats, blinks to close distance
2236
+ * or escape, aggressive hit-trading when health allows. The adaptive fitting means
2237
+ * every attack is optimized for the current situation — no wasted cast time.
2238
+ *
2239
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
2240
+ * - Battlemage (tier 1): Quick/heavy fixed configs, cast interruption, basic defense
2241
+ * - Warmage (tier 2): Adaptive missile fitting, optimized damage windows
2242
+ * - Archmage (tier 3): Future — supreme duelist, perfect tactical mastery
2243
+ *
2244
+ * TIER: 2 (enhanced Battlemage)
2245
+ */
2246
+ declare function Warmage(): FinalAction;
2247
+
2248
+ /**
2249
+ * Bot: Archmage
2250
+ *
2251
+ * BEHAVIOR: Versatile duelist that adapts missile choice based on distance and HP.
2252
+ * Close range → straight missiles (no turn cost = more damage). Mid/far range → homing.
2253
+ * Uses dual-blink aggressively (gap-close during vulnerability, escape when trade is bad).
2254
+ * HP-aware: ahead → aggressive close range; behind → defensive ranged kiting.
2255
+ *
2256
+ * KEY IMPROVEMENTS OVER WARMAGE:
2257
+ * - Range-adaptive missiles: straight close, homing far
2258
+ * - Vulnerability-timed blinks: gap-close during enemy cast/GCD
2259
+ * - HP-aware aggression: adjusts distance + risk tolerance based on HP differential
2260
+ * - Progressive cast-cancel: graduated thresholds
2261
+ *
2262
+ * PROGRESSION LINE: Battlemage → Warmage → Archmage
2263
+ * TIER: 3 (elite Duelist line)
2264
+ */
2265
+ declare function Archmage(): FinalAction;
2266
+
2267
+ /**
2268
+ * Bot: Stormchaser
2269
+ *
2270
+ * BEHAVIOR: Fights aggressively while managing defense intelligently. Uses
2271
+ * two fixed missile configs (standard homing + quick attack) with predictive
2272
+ * homing missile AI (interceptAngle on the missile itself). Blink-dodges
2273
+ * incoming threats, shields when blink is on cooldown. Tight distance
2274
+ * management (350 units, ±30 band).
2275
+ *
2276
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
2277
+ * - Stormchaser (tier 1): Fixed missiles, predictive homing AI, blink-dodge
2278
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
2279
+ * - Stormforger (tier 3): Future — supreme berserker, perfect aggression
2280
+ *
2281
+ * TIER: 1 (base)
2282
+ */
2283
+ declare function Stormchaser(): FinalAction;
2284
+
2285
+ /**
2286
+ * Bot: Stormcaller
2287
+ *
2288
+ * BEHAVIOR: Enhanced Stormchaser with adaptive missile fitting (fitMissileToBudget)
2289
+ * AND predictive homing missiles. Combines aggressive fighting philosophy with
2290
+ * optimized damage output. Uses budget-based missile fitting to maximize damage
2291
+ * within safe windows. Falls back to quick missiles under pressure. Same smart
2292
+ * trade/shield decisions as Stormchaser but with better resource usage.
2293
+ *
2294
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
2295
+ * - Stormchaser (tier 1): Adaptive missiles, smart trading, aggressive defense
2296
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
2297
+ * - Stormforger (tier 3): Future — supreme berserker, perfect aggression
2298
+ *
2299
+ * TIER: 2 (enhanced Stormchaser)
2300
+ */
2301
+ declare function Stormcaller(): FinalAction;
2302
+
2303
+ /**
2304
+ * Bot: Stormforger
2305
+ *
2306
+ * BEHAVIOR: Enhanced Stormcaller with vulnerability exploitation. Takes the exact
2307
+ * Stormcaller foundation (adaptive missile fitting + predictive homing) and adds
2308
+ * a punish mode that fires fast straight missiles when the enemy is locked in
2309
+ * GCD or cast animation. During vulnerability windows, uses getLeadPosition for
2310
+ * accurate straight shots that arrive before the enemy can react.
2311
+ *
2312
+ * PROGRESSION LINE: Stormchaser → Stormcaller → Stormforger
2313
+ * - Stormchaser (tier 1): Adaptive missiles, smart trading, aggressive defense
2314
+ * - Stormcaller (tier 2): + fitMissileToBudget, predictive homing, optimized damage
2315
+ * - Stormforger (tier 3): + vulnerability exploitation, punish missiles during enemy GCD
2316
+ *
2317
+ * TIER: 3 (elite Berserker line)
2318
+ */
2319
+ declare function Stormforger(): FinalAction;
2320
+
2321
+ /**
2322
+ * Bot: Spellspinner
2323
+ *
2324
+ * BEHAVIOR: Maintains medium range (350 units), strafes constantly to dodge
2325
+ * missiles, and fires homing missiles (damage 10, speed 4, turnRate 2). Heavy
2326
+ * emphasis on movement — 80% strafe intensity when not dodging, 100% when dodging.
2327
+ * Shields only undodgeable threats, emergency blinks when shield isn't available.
2328
+ * The constant circular strafing motion traces patterns like thread being spun.
2329
+ *
2330
+ * NAMING RATIONALE: Like a spider spinning a web of projectiles while circling its
2331
+ * prey. The constant strafing movement pattern traces circles — spinning thread
2332
+ * around the arena. "Spell" + "spinner" = a wizard who spins spells around the
2333
+ * battlefield. The kiting behavior (maintaining distance while attacking) creates
2334
+ * a web-like pattern of missiles and movement that traps opponents.
2335
+ *
2336
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
2337
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
2338
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
2339
+ * - Spellbinder (tier 3): Future — inescapable web of magic, perfect distance control
2340
+ * The progression: spinner (raw thread) → weaver (creates patterns) → binder
2341
+ * (constrains and traps). Each tier's projectile web becomes harder to escape.
2342
+ *
2343
+ * TIER: 1 (base)
2344
+ */
2345
+ declare function Spellspinner(): FinalAction;
2346
+
2347
+ /**
2348
+ * Bot: Spellweaver
2349
+ *
2350
+ * BEHAVIOR: Enhanced Spellspinner with adaptive missile fitting. Same medium-range
2351
+ * kiting playstyle — maintains distance, strafes heavily — but uses fitMissileToBudget
2352
+ * to maximize damage within safe attack windows. Always uses homing missiles since
2353
+ * kiting means enemies are always moving. More sophisticated than Spellspinner's
2354
+ * fixed damage/speed/turnRate configuration.
2355
+ *
2356
+ * NAMING RATIONALE: A weaver creates intricate patterns from raw thread. Where the
2357
+ * Spellspinner produces raw threads of magic (fixed missiles), the Spellweaver
2358
+ * combines them into optimized patterns (adaptive fitting). The name suggests
2359
+ * craftsmanship and sophistication — the same kiting web, but deliberately woven
2360
+ * rather than chaotically spun.
2361
+ *
2362
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
2363
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
2364
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
2365
+ * - Spellbinder (tier 3): Future — inescapable web, perfect distance control
2366
+ *
2367
+ * TIER: 2 (enhanced Spellspinner)
2368
+ */
2369
+ declare function Spellweaver(): FinalAction;
2370
+
2371
+ /**
2372
+ * Bot: Spellbinder
2373
+ *
2374
+ * BEHAVIOR: Enhanced Spellweaver with vulnerability exploitation. Same medium-range
2375
+ * kiting playstyle — maintains distance, strafes heavily, uses fitMissileToBudget
2376
+ * for adaptive homing missiles. The T3 upgrade adds a punish mode that fires fast
2377
+ * straight missiles timed to land while the enemy is locked in a cast or GCD,
2378
+ * when they cannot shield. Defense, movement, and standard offense are identical
2379
+ * to Spellweaver.
2380
+ *
2381
+ * NAMING RATIONALE: A binder constrains and locks down opponents. Where the
2382
+ * Spellweaver optimizes missile patterns (adaptive fitting), the Spellbinder
2383
+ * reads the enemy's state and punishes vulnerability windows — binding them
2384
+ * to their commitments with unavoidable damage.
2385
+ *
2386
+ * PROGRESSION LINE: Spellspinner → Spellweaver → Spellbinder
2387
+ * - Spellspinner (tier 1): Fixed homing missiles, constant strafe, basic defense
2388
+ * - Spellweaver (tier 2): + adaptive missile fitting, more sophisticated patterns
2389
+ * - Spellbinder (tier 3): + vulnerability punish mode with fast straight missiles
2390
+ *
2391
+ * TIER: 3 (elite Spellspinner line)
2392
+ */
2393
+ declare function Spellbinder(): FinalAction;
2394
+
2395
+ /**
2396
+ * Bot: Hero
2397
+ *
2398
+ * BEHAVIOR: Adaptive duelist that classifies the opponent's range/missile style from
2399
+ * live visible signals (how close they hold / whether they're closing, and their active
2400
+ * missiles) and counters by adjusting engagement distance — KITE aggressors (close /
2401
+ * closing / fast-straight stabbers) and CLOSE on kiters/casters (far / homing missiles).
2402
+ * This opponent-classification layer sits on top of Archmage's HP-aware, range-adaptive
2403
+ * engine: close range → straight missiles (no turn cost = more damage), mid/far → homing,
2404
+ * aggressive dual-blink (gap-close during vulnerability, escape when a trade is bad), and
2405
+ * HP-aware aggression (ahead → fight closer, behind → kite at range).
2406
+ *
2407
+ * KEY IMPROVEMENTS OVER ARCHMAGE:
2408
+ * - Opponent classification: reads range/missile style and counters via distance offset
2409
+ * - Counters aggressors by kiting, counters kiters/casters by closing in
2410
+ *
2411
+ * INHERITED FROM ARCHMAGE:
2412
+ * - Range-adaptive missiles: straight close, homing far
2413
+ * - Vulnerability-timed blinks: gap-close during enemy cast/GCD
2414
+ * - HP-aware aggression: adjusts distance + risk tolerance based on HP differential
2415
+ * - Progressive cast-cancel: graduated thresholds
2416
+ */
2417
+ declare function Hero(): FinalAction;
2418
+
2419
+ /**
2420
+ * VIBEMANCER - BOT REGISTRY
2421
+ *
2422
+ * Single source of truth for all bots, ordered from weakest to strongest.
2423
+ * Run the tournament test to determine the correct ordering.
2424
+ *
2425
+ * To reorder: run `npx vitest run tests/bots/tournament.test.ts`
2426
+ * and update the list below based on the results.
2427
+ *
2428
+ * BOT NAMING SCHEME (3-tier progression):
2429
+ *
2430
+ * | Group | Tier 1 (base) | Tier 2 (enhanced) | Tier 3 (elite) |
2431
+ * |------------|----------------|-------------------|-----------------|
2432
+ * | Defensive | Turtle | Sentinel | Golem |
2433
+ * | Duelist | Battlemage | Warmage | Archmage |
2434
+ * | Homing | Bonemancer | Lich | Archlich |
2435
+ * | Caster | Flamecaller | Pyromancer | Infernalist |
2436
+ * | Melee | Shadowblade | Nightblade | Voidblade |
2437
+ * | Sniper | Spellshot | Spelltracer | Spellseeker |
2438
+ * | Berserker | Stormchaser | Stormcaller | Stormforger |
2439
+ * | Kiter | Spellspinner | Spellweaver | Spellbinder |
2440
+ *
2441
+ * Standalone: TargetDummy, Critter, Hogger, Rookie, Doombringer, Hero
2442
+ * (Hero is the adaptive SHOWCASE — the #1 reference bot users build their own to beat.
2443
+ * Deliberately kept as a single isolated bot, NOT a tier line: writing adaptive bots is
2444
+ * the game, so the roster ships one exemplar and players make the rest.)
2445
+ * Reserved: Spellslinger (future volume-of-fire archetype)
2446
+ *
2447
+ */
2448
+
2449
+ interface WizardEntry {
2450
+ name: string;
2451
+ ai: WizardFunction;
2452
+ description: string;
2453
+ tier?: number;
2454
+ group: string;
2455
+ }
2456
+ interface WizardGroup {
2457
+ label: string;
2458
+ bots: WizardEntry[];
2459
+ }
2460
+ /**
2461
+ * All bots organized by progression line.
2462
+ * Each group contains bots from the same archetype, ordered by tier.
2463
+ */
2464
+ declare const BOT_GROUPS: WizardGroup[];
2465
+ declare const ALL_BOTS: WizardEntry[];
2466
+
2467
+ /**
2468
+ * VIBEMANCER - OPTIMIZER UTILITIES
2469
+ *
2470
+ * Core functions used by the offline parameter optimizer script.
2471
+ * These handle combo generation, range narrowing, and fight scoring.
2472
+ *
2473
+ * The optimizer uses multi-pass coordinate descent:
2474
+ * - Pass 1: Coarse search across the effective range for each param
2475
+ * - Pass 2+: Fine search zoomed into the neighborhood of the best result
2476
+ *
2477
+ * Parameters can define their search window two ways:
2478
+ * - `range`: sliding window centered on current value (value ± range)
2479
+ * - `min`/`max`: fixed bounds (old-style)
2480
+ *
2481
+ * Both can be combined: range defines the search radius, min/max clamp it.
2482
+ */
2483
+
2484
+ /**
2485
+ * Compute the effective min/max search window for a parameter.
2486
+ *
2487
+ * - If `range` is set: window is `[value - range, value + range]`, clamped by optional min/max
2488
+ * - If only `min`/`max` are set: window is `[min, max]` directly
2489
+ * - If neither: returns `[value, value]` (no search)
2490
+ */
2491
+ declare function getEffectiveRange(p: ParamDeclaration): {
2492
+ min: number;
2493
+ max: number;
2494
+ };
2495
+ /**
2496
+ * Generate evenly-spaced candidate values for a single parameter.
2497
+ *
2498
+ * Divides [min, max] into `steps` evenly-spaced values. For example,
2499
+ * min=0, max=100, steps=5 produces [0, 25, 50, 75, 100].
2500
+ *
2501
+ * @param min - Lower bound of search range
2502
+ * @param max - Upper bound of search range
2503
+ * @param steps - Number of evenly-spaced values to generate (minimum 2)
2504
+ * @returns Array of candidate values, sorted ascending
2505
+ */
2506
+ declare function generateCandidates(min: number, max: number, steps: number): number[];
2507
+ /**
2508
+ * Generate all combinations (cartesian product) of candidate values for multiple params.
2509
+ *
2510
+ * For N params with S1, S2, ... SN steps each, produces S1 × S2 × ... × SN combinations.
2511
+ * Each combination is a Record<string, number> mapping param name to value.
2512
+ *
2513
+ * @param params - Parameter declarations with search ranges and step counts
2514
+ * @returns Array of all parameter combinations to evaluate
2515
+ */
2516
+ declare function generateCombos(params: ParamDeclaration[]): Record<string, number>[];
2517
+ /**
2518
+ * Narrow parameter ranges around the best combo found in the previous pass.
2519
+ *
2520
+ * Centers each param on its best value and shrinks the search range to one gap width.
2521
+ * This provides finer resolution in subsequent passes. Hard min/max constraints are preserved.
2522
+ *
2523
+ * @param params - Original parameter declarations
2524
+ * @param best - Best parameter combination from the previous pass
2525
+ * @returns New parameter declarations with narrowed ranges for the next pass
2526
+ */
2527
+ declare function narrowRange(params: ParamDeclaration[], best: Record<string, number>): ParamDeclaration[];
2528
+ /**
2529
+ * Score a FightResult from one bot's perspective.
2530
+ *
2531
+ * Returns a continuous score that provides gradient information beyond binary win/loss:
2532
+ * - Win: 3.0 base + up to 0.5 HP bonus (higher remaining HP = better)
2533
+ * - Draw: 1.0
2534
+ * - Loss: 0.0 base + up to 0.5 bonus for low enemy HP (closer fights = better)
2535
+ *
2536
+ * For a mirrored fight set (bot as wizard-1 AND wizard-2), call this twice
2537
+ * and sum the scores for a balanced evaluation.
2538
+ *
2539
+ * @param result - The fight result to score
2540
+ * @returns Continuous score in range [0, 3.5] per match
2541
+ */
2542
+ declare function scoreFight(result: FightResult): number;
2543
+ /**
2544
+ * Score a FightResult from wizard-2's perspective.
2545
+ * Same scoring logic as scoreFight but with roles reversed.
2546
+ *
2547
+ * Use this for tournaments where both sides of a pairing need scoring.
2548
+ */
2549
+ declare function scoreFightAsWizard2(result: FightResult): number;
2550
+
2551
+ /**
2552
+ * Bot-name filter — the single source of truth for which bot names are
2553
+ * disallowed. Called everywhere a bot name is served or displayed (matchmaker,
2554
+ * upload, handle/botname selectors, leaderboard, CLI) so the rule is consistent.
2555
+ *
2556
+ * Deliberately a pure function over stateless rules: nothing is written to the
2557
+ * bot, so adding a rule hides matching bots everywhere at once, and REMOVING a
2558
+ * rule brings them straight back — no data to migrate or un-flag. Editing the
2559
+ * lists below is a (rare) release; the bots themselves are never mutated.
2560
+ *
2561
+ * On a takedown (trademark / defamation / illegal content), add the exact name
2562
+ * to BANNED_EXACT, or a pattern to BANNED_PATTERNS for a family of names.
2563
+ *
2564
+ * FULL RUNBOOK (read this before banning anything): docs/BANNING_BOT_NAMES.md
2565
+ * — it explains the why, the exact-match semantics, and the release steps
2566
+ * required for the change to reach the (published-core) Cloud Functions.
2567
+ */
2568
+ /**
2569
+ * Pure matcher — exported for testing. Returns true if `name` matches any of the
2570
+ * given exact names or patterns (case-insensitive, trimmed).
2571
+ */
2572
+ declare function matchesAnyBanRule(name: string, exact: ReadonlySet<string>, patterns: readonly RegExp[]): boolean;
2573
+ /**
2574
+ * True if a bot name is disallowed. Call this at every surface that serves or
2575
+ * displays bot names; never persist the result onto the bot.
2576
+ */
2577
+ declare function isBannedBotName(name: string): boolean;
2578
+
2579
+ /**
2580
+ * VIBEMANCER — BROWSER SANDBOX
2581
+ *
2582
+ * Provides Web Worker-based sandboxing for bot code execution in the browser.
2583
+ * Same compiled bundles as the isolated-vm sandbox (MatchSandbox), but runs
2584
+ * in a Web Worker instead of a V8 isolate.
2585
+ *
2586
+ * Architecture:
2587
+ * - Host: creates Worker from Blob URL, communicates via postMessage
2588
+ * - Worker: loads compiled bundle (sets globalThis.__fight/__simulate),
2589
+ * dispatches fight/simulate calls, posts results back
2590
+ *
2591
+ * Safety:
2592
+ * - Timeout via setTimeout + worker.terminate() catches infinite loops
2593
+ * - No memory limit (browser manages worker memory; worst case = tab crash)
2594
+ * - Prototype freeze prevents cross-bot sabotage (same banner as isolated-vm)
2595
+ * - No Node.js APIs available in Web Workers
2596
+ *
2597
+ * NOTE: This file has ZERO Node.js dependencies. It works in any JS environment.
2598
+ */
2599
+
2600
+ /**
2601
+ * Minimal Worker interface for dependency injection.
2602
+ * Matches the browser Worker API subset we need.
2603
+ * For tests, a Node.js worker_threads adapter can implement this.
2604
+ */
2605
+ interface WorkerLike {
2606
+ postMessage(data: unknown): void;
2607
+ terminate(): void;
2608
+ addEventListener(type: string, listener: (ev: unknown) => void): void;
2609
+ removeEventListener(type: string, listener: (ev: unknown) => void): void;
2610
+ }
2611
+ /**
2612
+ * Factory function that creates a WorkerLike from a JavaScript code string.
2613
+ * Default: creates a browser Web Worker via Blob URL.
2614
+ * Override in options.createWorker for testing with Node.js worker_threads.
2615
+ */
2616
+ type WorkerFactory = (code: string) => {
2617
+ worker: WorkerLike;
2618
+ cleanup?: () => void;
2619
+ };
2620
+ interface BrowserSandboxOptions {
2621
+ /** Timeout in ms for fight/simulate calls (default: 30000). */
2622
+ timeoutMs?: number;
2623
+ /** Custom worker factory for dependency injection (testing). */
2624
+ createWorker?: WorkerFactory;
2625
+ }
2626
+ /**
2627
+ * Create the full worker script from a compiled match bundle.
2628
+ * Appends the message-handling bootstrap to the bundle IIFE.
2629
+ */
2630
+ declare function createWorkerScript(bundle: string): string;
2631
+ /**
2632
+ * Browser-compatible sandboxed match runner using Web Workers.
2633
+ *
2634
+ * Same compiled bundles as MatchSandbox (isolated-vm), but runs in a
2635
+ * Web Worker instead. All fight/simulate calls are async (postMessage-based).
2636
+ *
2637
+ * Usage:
2638
+ * ```ts
2639
+ * // Bundle is compiled server-side or at build time (Node.js only)
2640
+ * const bundle = await MatchSandbox.compile(bot1, bot2);
2641
+ *
2642
+ * // Run in browser via Web Worker
2643
+ * const sandbox = await BrowserMatchSandbox.fromBundle(bundle);
2644
+ * const result = await sandbox.fight({ seed: 42 });
2645
+ * sandbox.dispose();
2646
+ * ```
2647
+ */
2648
+ declare class BrowserMatchSandbox {
2649
+ private worker;
2650
+ private workerCleanup;
2651
+ private timeout;
2652
+ private disposed;
2653
+ private nextId;
2654
+ private pending;
2655
+ private messageHandler;
2656
+ private errorHandler;
2657
+ private constructor();
2658
+ /**
2659
+ * Create a browser sandbox from a pre-compiled bundle string.
2660
+ * The bundle should be the output of MatchSandbox.compile() (or equivalent IIFE
2661
+ * that sets globalThis.__fight and globalThis.__simulate).
2662
+ */
2663
+ static fromBundle(bundle: string, options?: BrowserSandboxOptions): Promise<BrowserMatchSandbox>;
2664
+ /**
2665
+ * Wait for the worker to post {type: 'ready'}, then attach permanent handlers.
2666
+ */
2667
+ private waitForReady;
2668
+ /**
2669
+ * Extract message data from a browser MessageEvent or raw Node.js data.
2670
+ */
2671
+ private unwrapEvent;
2672
+ /**
2673
+ * Attach permanent message and error handlers for fight/simulate responses.
2674
+ */
2675
+ private attachHandlers;
2676
+ /**
2677
+ * Run a full fight (10 matches: 5 spawn distances x 2 sides).
2678
+ * Returns a Promise because Worker communication is async.
2679
+ */
2680
+ fight(options?: {
2681
+ seed?: number;
2682
+ maxTicks?: number;
2683
+ }): Promise<FightResult>;
2684
+ /**
2685
+ * Run a single simulation. Returns a Promise.
2686
+ *
2687
+ * @param options.params1 - useParam overrides for bot 1 (wizard-1)
2688
+ * @param options.params2 - useParam overrides for bot 2 (wizard-2)
2689
+ */
2690
+ simulate(options?: {
2691
+ seed?: number;
2692
+ maxTicks?: number;
2693
+ spawnDistance?: number;
2694
+ skipHistory?: boolean;
2695
+ params1?: Record<string, number>;
2696
+ params2?: Record<string, number>;
2697
+ }): Promise<SimulateResult>;
2698
+ /**
2699
+ * Dispose the worker and free all resources.
2700
+ * The sandbox cannot be used after disposal.
2701
+ */
2702
+ dispose(): void;
2703
+ /**
2704
+ * Whether this sandbox has been disposed.
2705
+ */
2706
+ get isDisposed(): boolean;
2707
+ /**
2708
+ * Send a generic method call to the worker. Used by sibling sandboxes
2709
+ * (e.g. BrowserManualMatchSandbox) that need to dispatch to method
2710
+ * names other than fight/simulate. The worker bootstrap looks up
2711
+ * `globalThis['__' + method]` and calls it with `options`.
2712
+ */
2713
+ callRaw(method: string, options: unknown): Promise<unknown>;
2714
+ /**
2715
+ * Send a method call to the worker and wait for the response.
2716
+ * Times out and terminates the worker if no response within timeout.
2717
+ */
2718
+ private call;
2719
+ private ensureNotDisposed;
2720
+ }
2721
+ /**
2722
+ * One-shot browser-sandboxed fight. Creates worker, runs fight, disposes.
2723
+ */
2724
+ declare function browserSandboxFight(bundle: string, options?: {
2725
+ seed?: number;
2726
+ maxTicks?: number;
2727
+ } & BrowserSandboxOptions): Promise<FightResult>;
2728
+ /**
2729
+ * One-shot browser-sandboxed simulate. Creates worker, runs simulate, disposes.
2730
+ */
2731
+ declare function browserSandboxSimulate(bundle: string, options?: {
2732
+ seed?: number;
2733
+ maxTicks?: number;
2734
+ spawnDistance?: number;
2735
+ skipHistory?: boolean;
2736
+ params1?: Record<string, number>;
2737
+ params2?: Record<string, number>;
2738
+ } & BrowserSandboxOptions): Promise<SimulateResult>;
2739
+ /**
2740
+ * Options accepted by `__manualMatchInit` (worker-side). Mirrors
2741
+ * `ManualMatchOptions` from manual-match.ts, but without the constructor's
2742
+ * AI parameters since the player AI is a worker-local stub.
2743
+ */
2744
+ interface ManualMatchInitOptions {
2745
+ seed?: number;
2746
+ spawnDistance?: number;
2747
+ maxTicks?: number;
2748
+ initialHumanActions?: WizardActions;
2749
+ }
2750
+ interface ManualMatchStepRequest {
2751
+ humanActions?: WizardActions;
2752
+ humanMissileTargets?: Record<string, {
2753
+ x: number;
2754
+ y: number;
2755
+ }>;
2756
+ count?: number;
2757
+ }
2758
+ /**
2759
+ * Long-lived Web Worker sandbox holding a single ManualMatch instance.
2760
+ *
2761
+ * Unlike BrowserMatchSandbox (which runs one batched fight/simulate per
2762
+ * worker), BrowserManualMatchSandbox keeps the worker alive across many
2763
+ * step calls so the engine state and hook state persist between ticks.
2764
+ * This is what manual play mode uses: one worker per session, disposed
2765
+ * when the user leaves the page or starts a new match.
2766
+ *
2767
+ * Usage:
2768
+ * ```ts
2769
+ * const sandbox = await BrowserManualMatchSandbox.fromBundle(opponentBundle);
2770
+ * await sandbox.init({seed: 42});
2771
+ * for (let i = 0; i < 100; i++) {
2772
+ * await sandbox.step({humanActions: {move: {x: 100, y: 0}}, count: 1});
2773
+ * }
2774
+ * await sandbox.dispose();
2775
+ * ```
2776
+ */
2777
+ declare class BrowserManualMatchSandbox {
2778
+ private readonly inner;
2779
+ private constructor();
2780
+ /**
2781
+ * Create a manual-match sandbox from a pre-compiled bundle. The bundle
2782
+ * must be the output of `compileManualMatchBundle()` — the regular
2783
+ * `compileMatchBundle()` output won't work since it doesn't expose the
2784
+ * `__manualMatch*` globals.
2785
+ */
2786
+ static fromBundle(bundle: string, options?: BrowserSandboxOptions): Promise<BrowserManualMatchSandbox>;
2787
+ /**
2788
+ * Initialize the worker-side ManualMatch instance.
2789
+ * Returns the initial GameState (tick 0).
2790
+ */
2791
+ init(options?: ManualMatchInitOptions): Promise<GameState>;
2792
+ /**
2793
+ * Advance the match by `request.count` ticks (default 1), updating
2794
+ * the player's human actions and any guided missile targets first.
2795
+ */
2796
+ step(request?: ManualMatchStepRequest): Promise<StepResult>;
2797
+ /**
2798
+ * Replace a missile's AI with a worker-local guide stub that reads
2799
+ * from `latestHumanMissileTargets[projectileId]`. Subsequent step()
2800
+ * calls with `humanMissileTargets` populated for this id steer the
2801
+ * missile.
2802
+ */
2803
+ guideMissile(projectileId: string): Promise<void>;
2804
+ /**
2805
+ * Restore a guided missile's original AI.
2806
+ */
2807
+ releaseMissile(projectileId: string): Promise<void>;
2808
+ /**
2809
+ * Toggle invincibility for a wizard.
2810
+ */
2811
+ setInvincible(wizardIndex: 0 | 1, on: boolean): Promise<void>;
2812
+ /**
2813
+ * Get the current game state without advancing.
2814
+ */
2815
+ getState(): Promise<GameState>;
2816
+ /**
2817
+ * Get the full SimulateResult-compatible result object (history + winner).
2818
+ */
2819
+ getResult(): Promise<SimulateResult>;
2820
+ /**
2821
+ * Dispose the worker-side ManualMatch instance. Does NOT terminate the
2822
+ * worker — call dispose() for that.
2823
+ */
2824
+ resetMatch(): Promise<void>;
2825
+ /**
2826
+ * Terminate the worker and free all resources.
2827
+ */
2828
+ dispose(): void;
2829
+ get isDisposed(): boolean;
2830
+ }
2831
+
2832
+ /**
2833
+ * VIBEMANCER - FIGHT STATISTICS
2834
+ *
2835
+ * Extracts detailed per-bot statistics from a SimulateResult history.
2836
+ * Used by testBot().simulate() and vibemancer trace for debugging.
2837
+ */
2838
+
2839
+ /** Detailed statistics for one bot in a single match. */
2840
+ interface FightStats {
2841
+ /** Total damage dealt to the opponent. */
2842
+ damageDealt: number;
2843
+ /** Total damage taken from the opponent. */
2844
+ damageTaken: number;
2845
+ /** Number of missiles launched. */
2846
+ missilesLaunched: number;
2847
+ /** Number of missiles that dealt damage (hit the opponent). */
2848
+ missileHits: number;
2849
+ /** Hit rate (0-1). NaN if no missiles fired. */
2850
+ hitRate: number;
2851
+ /** Number of our missiles that hit while enemy was shielding. */
2852
+ hitsEnemyShielded: number;
2853
+ /** Number of our missiles that hit while enemy had no shield. */
2854
+ hitsEnemyUnshielded: number;
2855
+ /** Total raw damage our missiles would have dealt without shields. */
2856
+ rawDamageDealt: number;
2857
+ /** Damage blocked by enemy shields. */
2858
+ damageBlockedByEnemy: number;
2859
+ /** Percentage of our raw damage blocked by enemy shields (0-1). */
2860
+ enemyBlockRate: number;
2861
+ /** Number of times we were hit by enemy missiles. */
2862
+ hitsReceived: number;
2863
+ /** Number of hits received while shield was channeling. */
2864
+ hitsShielded: number;
2865
+ /** Number of hits received without shield. */
2866
+ hitsUnshielded: number;
2867
+ /** Total raw damage that hit us (before shield reduction). */
2868
+ rawDamageReceived: number;
2869
+ /** Total damage blocked by shields. */
2870
+ damageBlocked: number;
2871
+ /** Percentage of incoming raw damage that was blocked (0-1). */
2872
+ blockRate: number;
2873
+ /** Ticks spent in 'casting' state. */
2874
+ castingTicks: number;
2875
+ /** Ticks spent channeling shield. */
2876
+ shieldTicks: number;
2877
+ /** Ticks spent in GCD lockout. */
2878
+ gcdTicks: number;
2879
+ /** Ticks spent idle (not casting, channeling, or in GCD). */
2880
+ idleTicks: number;
2881
+ /** Number of times shield was activated. */
2882
+ shieldCount: number;
2883
+ /** Number of times blink was used. */
2884
+ blinkCount: number;
2885
+ /** Total match duration in ticks. */
2886
+ totalTicks: number;
2887
+ }
2888
+ /**
2889
+ * Extract fight statistics from a SimulateResult.
2890
+ * Returns stats for wizard-1 (the bot under test).
2891
+ */
2892
+ declare function extractStats(result: SimulateResult): FightStats;
2893
+ /** Format stats as a human-readable summary string. */
2894
+ declare function formatStats(stats: FightStats, botName: string): string;
2895
+
2896
+ /**
2897
+ * VIBEMANCER - TESTING UTILITIES
2898
+ *
2899
+ * Helpers for writing automated tests for your bot.
2900
+ * Import from '@vibemancer/core' in your test files.
2901
+ *
2902
+ * @example
2903
+ * import {testBot} from '@vibemancer/core';
2904
+ * import {MyWizard} from '../src/bot';
2905
+ *
2906
+ * test('beats TargetDummy', async () => {
2907
+ * const result = await testBot(MyWizard).fight('TargetDummy');
2908
+ * expect(result.won).toBe(true);
2909
+ * });
2910
+ */
2911
+
2912
+ /** Result of a testBot().fight() call with convenience accessors. */
2913
+ interface TestFightResult {
2914
+ /** The raw FightResult from the simulation engine. */
2915
+ raw: FightResult;
2916
+ /** Overall winner: 'wizard-1' | 'wizard-2' | 'draw'. */
2917
+ winner: FightWinner;
2918
+ /** True if your bot won the fight. */
2919
+ won: boolean;
2920
+ /** True if your bot lost the fight. */
2921
+ lost: boolean;
2922
+ /** True if the fight was a draw. */
2923
+ drawn: boolean;
2924
+ /** Number of individual matches your bot won (out of 10). */
2925
+ wins: number;
2926
+ /** Number of individual matches your bot lost (out of 10). */
2927
+ losses: number;
2928
+ /** Number of individual matches that were draws. */
2929
+ draws: number;
2930
+ }
2931
+ /** Result of a testBot().simulate() call with convenience accessors. */
2932
+ interface TestSimulateResult {
2933
+ /** The raw SimulateResult from the simulation engine. */
2934
+ raw: SimulateResult;
2935
+ /** Match winner. */
2936
+ winner: MatchWinner;
2937
+ /** True if your bot won. */
2938
+ won: boolean;
2939
+ /** True if your bot lost. */
2940
+ lost: boolean;
2941
+ /** True if the match was a draw or timeout. */
2942
+ drawn: boolean;
2943
+ /** Number of ticks the match lasted. */
2944
+ ticks: number;
2945
+ /** Your bot's remaining HP. */
2946
+ myHealth: number;
2947
+ /** Enemy's remaining HP. */
2948
+ enemyHealth: number;
2949
+ /** Detailed fight statistics (missiles, damage, shield usage, time breakdown). */
2950
+ stats: FightStats;
2951
+ /** Runtime errors thrown by bot or missile AI (empty if none). */
2952
+ errors: Array<{
2953
+ tick: number;
2954
+ entityId: string;
2955
+ message: string;
2956
+ }>;
2957
+ }
2958
+ /** Builder returned by testBot(). */
2959
+ interface TestBotBuilder {
2960
+ /**
2961
+ * Run a full fight (10 matches) against a named built-in bot.
2962
+ * @param opponent - Built-in bot name (e.g., 'Battlemage', 'TargetDummy').
2963
+ */
2964
+ fight(opponent: string, options?: {
2965
+ seed?: number;
2966
+ }): TestFightResult;
2967
+ /**
2968
+ * Run a single match against a named built-in bot.
2969
+ * @param opponent - Built-in bot name.
2970
+ */
2971
+ simulate(opponent: string, options?: {
2972
+ seed?: number;
2973
+ spawnDistance?: number;
2974
+ maxTicks?: number;
2975
+ }): TestSimulateResult;
2976
+ }
2977
+ /**
2978
+ * Create a test builder for your bot.
2979
+ *
2980
+ * @param bot - Your bot function (the same function you export from src/bot.ts).
2981
+ * @returns A builder with .fight() and .simulate() methods.
2982
+ *
2983
+ * @example
2984
+ * ```ts
2985
+ * import {testBot} from '@vibemancer/core';
2986
+ * import {MyWizard} from '../src/bot';
2987
+ *
2988
+ * test('beats TargetDummy', () => {
2989
+ * const result = testBot(MyWizard).fight('TargetDummy');
2990
+ * expect(result.won).toBe(true);
2991
+ * });
2992
+ *
2993
+ * test('survives 10 seconds against Battlemage', () => {
2994
+ * const result = testBot(MyWizard).simulate('Battlemage', {maxTicks: 1000});
2995
+ * expect(result.myHealth).toBeGreaterThan(0);
2996
+ * });
2997
+ *
2998
+ * test('kills at close range', () => {
2999
+ * const result = testBot(MyWizard).simulate('TargetDummy', {spawnDistance: 200});
3000
+ * expect(result.won).toBe(true);
3001
+ * expect(result.ticks).toBeLessThan(1000);
3002
+ * });
3003
+ * ```
3004
+ */
3005
+ declare function testBot(bot: WizardFunction): TestBotBuilder;
3006
+
3007
+ /**
3008
+ * VIBEMANCER - FIGHT TRACE
3009
+ *
3010
+ * Extracts a structured event log from a SimulateResult history.
3011
+ * Both bots' actions are tracked: state changes, missile launches with
3012
+ * full config, hits, damage, dodge proximity, movement patterns.
3013
+ *
3014
+ * Used by:
3015
+ * - vibemancer trace (CLI debug command)
3016
+ * - scripts/fight-trace.ts (internal diagnostic)
3017
+ * - User tests that want event-level analysis
3018
+ */
3019
+
3020
+ interface TraceEvent {
3021
+ tick: number;
3022
+ /** 'W1' = wizard-1, 'W2' = wizard-2 */
3023
+ actor: 'W1' | 'W2';
3024
+ type: TraceEventType;
3025
+ detail: string;
3026
+ }
3027
+ type TraceEventType = 'STATE' | 'FIRE' | 'HIT' | 'HURT' | 'DEATH' | 'LAVA_DEATH' | 'SHIELD_BLOCK' | 'KNOCKBACK' | 'BLINK' | 'DODGE_START' | 'DODGE_CLOSE' | 'MOVE' | 'ERROR' | 'WARNING';
3028
+ interface TraceSummary {
3029
+ winner: string;
3030
+ ticks: number;
3031
+ w1Name: string;
3032
+ w2Name: string;
3033
+ w1FinalHp: number;
3034
+ w2FinalHp: number;
3035
+ w1: TraceBotSummary;
3036
+ w2: TraceBotSummary;
3037
+ }
3038
+ interface TraceBotSummary {
3039
+ missilesLaunched: number;
3040
+ hits: number;
3041
+ damageDealt: number;
3042
+ damageReceived: number;
3043
+ shields: number;
3044
+ blinks: number;
3045
+ dodgeEncounters: number;
3046
+ causeOfDeath: 'missile' | 'lava' | 'alive' | 'timeout';
3047
+ movement: {
3048
+ strafe: number;
3049
+ approach: number;
3050
+ retreat: number;
3051
+ still: number;
3052
+ };
3053
+ }
3054
+ /**
3055
+ * Extract a structured event log from simulation history.
3056
+ * Tracks both bots' state changes, missile launches (with full config + range),
3057
+ * hits, damage, dodge proximity, movement patterns, and runtime errors.
3058
+ */
3059
+ declare function extractTraceEvents(history: GameState[], errors?: BotError[]): TraceEvent[];
3060
+ /**
3061
+ * Generate a summary from trace events and the simulation result.
3062
+ */
3063
+ declare function summarizeTrace(events: TraceEvent[], result: SimulateResult, w1Name: string, w2Name: string): TraceSummary;
3064
+ /** Format trace events as a human-readable string. */
3065
+ declare function formatTraceEvents(events: TraceEvent[]): string;
3066
+ /** Format a full trace summary as a human-readable string. */
3067
+ declare function formatTraceSummary(summary: TraceSummary): string;
3068
+ /**
3069
+ * Generate diagnostic tips based on trace analysis.
3070
+ * Identifies common problems and suggests fixes.
3071
+ * Returns an array of human-readable tips (empty if no issues found).
3072
+ */
3073
+ declare function diagnoseTrace(events: TraceEvent[], summary: TraceSummary): string[];
3074
+ /** Format diagnostic tips as a human-readable string. */
3075
+ declare function formatDiagnosis(tips: string[]): string;
3076
+
3077
+ export { type InternalWizardState as $, ALL_BOTS as A, BLINK_CAST_TIME as B, CASTING_MOVEMENT_MULT as C, Critter as D, DEFAULT_BUDGET as E, type FightResult as F, DEFAULT_FIGHT_BACKSTOP_MS as G, DEFAULT_SEED as H, Doombringer as I, ENGINE_VERSION as J, type EnemyState as K, FIGHT_SPAWN_DISTANCES as L, type FightBudget as M, type FightStats as N, type FightWinner as O, type FinalAction as P, Flamecaller as Q, GCD_DURATION as R, type SimulateResult as S, type GameConfig as T, type GameState as U, Golem as V, Hero as W, Hogger as X, type HomingParams as Y, type HookState as Z, Infernalist as _, ARENA_MAX as a, Spellseeker as a$, KNOCKBACK_DAMAGE_THRESHOLD as a0, KNOCKBACK_DECAY as a1, KNOCKBACK_DELAY as a2, KNOCKBACK_SPEED_PER_DAMAGE as a3, LAVA_BORDER_WIDTH as a4, Lich as a5, MATCH_DURATION as a6, MAX_HEALTH as a7, MISSILE_BASE_CAST as a8, MISSILE_BASE_RADIUS as a9, type MissileLaunchEvent as aA, type MissileOobEvent as aB, type MissileTemplate as aC, Nightblade as aD, type ParamDeclaration as aE, type Position as aF, type ProjectileState as aG, Pyromancer as aH, RULES as aI, RULESET_RANGES as aJ, type RefObject as aK, Rookie as aL, SHIELD_CAST_TIME as aM, SHIELD_DECAY_PER_SECOND as aN, SHIELD_DECAY_RATE as aO, SHIELD_MAX_BLOCK as aP, SHIELD_MAX_STRENGTH as aQ, SHIELD_MIN_BLOCK as aR, SHIELD_MIN_STRENGTH as aS, SPAWN_DISTANCE as aT, type SeekerParams as aU, Sentinel as aV, Shadowblade as aW, type ShieldBlockEvent as aX, type ShieldStartEvent as aY, type SimEvent as aZ, Spellbinder as a_, MISSILE_DAMAGE_POWER as aa, MISSILE_DAMAGE_RADIUS_SCALE as ab, MISSILE_DAMAGE_SCALE as ac, MISSILE_HOMING_COEFF as ad, MISSILE_MIN_CAST_TIME as ae, MISSILE_MIN_DAMAGE as af, MISSILE_MIN_DURATION as ag, MISSILE_MIN_SPEED as ah, MISSILE_RADIUS_PER_DAMAGE as ai, MISSILE_SPEED_DURATION_BASELINE as aj, MISSILE_SPEED_DURATION_COEFF as ak, MISSILE_TURN_DURATION_COEFF as al, MOVEMENT_SPEED as am, MOVE_SPEED as an, ManualMatch as ao, type ManualMatchInitOptions as ap, type ManualMatchOptions as aq, type ManualMatchStepRequest as ar, type MatchWinner as as, type MissileAction as at, type MissileActions as au, type MissileConfig as av, type MissileContext as aw, type MissileExpiredEvent as ax, type MissileFunction$1 as ay, type MissileHitEvent as az, ARENA_MIN as b, createBudgetState as b$, Spellshot as b0, Spellspinner as b1, Spelltracer as b2, Spellweaver as b3, type SpiralParams as b4, type StepResult as b5, Stormcaller as b6, Stormchaser as b7, Stormforger as b8, type StraightParams as b9, type WizardGroup as bA, type WizardLavaDeathEvent as bB, type WizardState as bC, type WorkerFactory as bD, type WorkerLike as bE, analyzeThreats as bF, angleDiff as bG, angleInRange as bH, angleTo as bI, applyDamage as bJ, applyRulesetOverrides as bK, blink as bL, browserSandboxFight as bM, browserSandboxSimulate as bN, calculateBlinkCooldown as bO, calculateMissileCastTime as bP, calculateMissileRadius as bQ, calculateMissileSimilarity as bR, calculateShieldBlock as bS, calculateWarmupMultiplier as bT, cancel as bU, cancelCast as bV, clampPositionToArena as bW, clampToArena as bX, clearHooks as bY, clearParamValues as bZ, completeCast as b_, TICKS_PER_SECOND as ba, TICK_DURATION_MS as bb, TargetDummy as bc, type TestBotBuilder as bd, type TestFightResult as be, type TestSimulateResult as bf, type TraceBotSummary as bg, type TraceEvent as bh, type TraceEventType as bi, type TraceSummary as bj, Turtle as bk, type Velocity as bl, Voidblade as bm, WARMUP_DURATION_TOLERANCE as bn, WARMUP_MAX_BONUS as bo, WARMUP_MAX_PENALTY as bp, WARMUP_SPEED_TOLERANCE as bq, WARMUP_TURN_TOLERANCE as br, WIZARD_HEALTH as bs, WIZARD_RADIUS as bt, Warmage as bu, type WizardActions as bv, type WizardContext as bw, type WizardDeathEvent as bx, type WizardEntry as by, type WizardFunction as bz, ARENA_SIZE as c, setParamValues as c$, createEntitySeed as c0, createFightBudget as c1, createInitialState as c2, createRandom as c3, createWorkerScript as c4, currentRuleset as c5, diagnoseTrace as c6, directionAway as c7, directionTo as c8, distanceTo as c9, idle as cA, inRange as cB, interceptAngle as cC, isBannedBotName as cD, isInLava as cE, magnitude as cF, matchesAnyBanRule as cG, mayAct as cH, missile as cI, move as cJ, moveInDirection as cK, moveProjectile as cL, moveWizard as cM, narrowRange as cN, nextRandom as cO, normalize as cP, normalizeAngle as cQ, predictPosition as cR, recordSpend as cS, resetAllHooks as cT, resetRuleset as cU, resolveWizardCollision as cV, runWithHooks as cW, runWizardWithContext as cX, scoreFight as cY, scoreFightAsWizard2 as cZ, seekerMissile as c_, effectiveTurnRateCost as ca, extractAction as cb, extractMissileAction as cc, extractStats as cd, extractTraceEvents as ce, fight as cf, findInRange as cg, findNearest as ch, fitMissileForEscapingTarget as ci, fitMissileToBudget as cj, flyStraight as ck, formatDiagnosis as cl, formatStats as cm, formatTraceEvents as cn, formatTraceSummary as co, generateCandidates as cp, generateCombos as cq, getAdaptiveMissileConfig as cr, getEffectiveRange as cs, getLeadPosition as ct, getMissileCastTime as cu, getMissileContext as cv, getPlayerState as cw, getWizardContext as cx, hashCombine as cy, homingMissile as cz, ARENA_WATER_BUFFER as d, shield as d0, simulate as d1, simulateMinDuration as d2, sortByDistance as d3, spiralMissile as d4, startCast as d5, startDiscovery as d6, stopDiscovery as d7, straightMissile as d8, summarizeTrace as d9, useRef as dA, useShieldStrength as dB, useState as dC, useStatus as dD, useThreats as dE, useTick as dF, useTicksUntilReady as dG, useVelocity as dH, validateHookCall as dI, validateMissileConfig as dJ, withMissileContext as dK, withWizardContext as dL, wrapWithParams as dM, sweptCircleCollision as da, testBot as db, tick as dc, turnToAngle as dd, turnToward as de, updateShield as df, useArenaSize as dg, useBlinkCooldown as dh, useCastProgress as di, useCastingSpell as dj, useClosestThreat as dk, useDamageDealt as dl, useDamageTaken as dm, useEffect as dn, useEnemy as dp, useHealth as dq, useLastHitTick as dr, useLastMissileConfig as ds, useMemo as dt, useMyProjectiles as du, useMyThreatsToEnemy as dv, useParam as dw, usePosition as dx, useProjectiles as dy, useRandom as dz, type ActionBuilder as e, type AnalyzedThreat as f, Archlich as g, Archmage as h, BLINK_COOLDOWN as i, BLINK_MAX_COOLDOWN as j, BLINK_MAX_RANGE as k, BLINK_MIN_COOLDOWN as l, BLINK_RANGE as m, BOT_GROUPS as n, Battlemage as o, type BlinkEvent as p, Bonemancer as q, type BotBudgetState as r, type BotError as s, BrowserManualMatchSandbox as t, BrowserMatchSandbox as u, type BrowserSandboxOptions as v, type BudgetLimits as w, COLLISION_RADIUS as x, type CastCancelEvent as y, type CastStartEvent as z };