@vibemancer/core 1.0.3 → 1.0.4

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