@vibemancer/core 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunk-W7HWJFQ4.js +10599 -0
- package/dist/chunk-W7HWJFQ4.js.map +1 -0
- package/dist/index-browser.d.ts +1300 -1051
- package/dist/index-browser.js +55 -17
- package/dist/index.d.ts +53 -3
- package/dist/index.js +200 -54
- package/dist/index.js.map +1 -1
- package/package.json +21 -15
- package/src/bots/Hero.ts +867 -0
- package/src/bots/berserker/01_Stormchaser.ts +162 -120
- package/src/bots/berserker/02_Stormcaller.ts +160 -116
- package/src/bots/berserker/03_Stormforger.ts +162 -129
- package/src/bots/caster/01_Flamecaller.ts +126 -84
- package/src/bots/caster/02_Pyromancer.ts +148 -101
- package/src/bots/caster/03_Infernalist.ts +180 -160
- package/src/bots/defensive/01_Turtle.ts +48 -44
- package/src/bots/defensive/02_Sentinel.ts +57 -53
- package/src/bots/defensive/03_Golem.ts +85 -97
- package/src/bots/duelist/01_Battlemage.ts +157 -122
- package/src/bots/duelist/02_Warmage.ts +166 -121
- package/src/bots/duelist/03_Archmage.ts +198 -178
- package/src/bots/homing/01_Bonemancer.ts +20 -32
- package/src/bots/homing/02_Lich.ts +145 -93
- package/src/bots/homing/03_Archlich.ts +129 -60
- package/src/bots/kiter/01_Spellspinner.ts +145 -107
- package/src/bots/kiter/02_Spellweaver.ts +153 -105
- package/src/bots/kiter/03_Spellbinder.ts +168 -123
- package/src/bots/melee/01_Shadowblade.ts +131 -75
- package/src/bots/melee/02_Nightblade.ts +174 -130
- package/src/bots/melee/03_Voidblade.ts +266 -168
- package/src/bots/registry.ts +44 -37
- package/src/bots/shared.ts +185 -25
- package/src/bots/sniper/01_Spellshot.ts +151 -98
- package/src/bots/sniper/02_Spelltracer.ts +173 -128
- package/src/bots/sniper/03_Spellseeker.ts +177 -152
- package/src/bots/standalone/Critter.ts +46 -52
- package/src/bots/standalone/Doombringer.ts +36 -40
- package/src/bots/standalone/Hogger.ts +120 -89
- package/src/bots/standalone/Rookie.ts +21 -23
- package/src/bots/standalone/TargetDummy.ts +5 -6
- package/src/bots/test/cheater.ts +91 -85
- package/src/bots/test/crasher.ts +26 -28
- package/src/engine/bundle-fight.ts +242 -0
- package/src/engine/hooks-runtime.ts +58 -18
- package/src/engine/manual-match.ts +33 -25
- package/src/engine/missile-templates.ts +25 -43
- package/src/engine/optimizer.ts +7 -7
- package/src/engine/params-runtime.ts +3 -3
- package/src/engine/physics.ts +33 -23
- package/src/engine/sandbox-browser.ts +8 -7
- package/src/engine/sandbox-compile.ts +1 -1
- package/src/engine/sandbox-harness.ts +299 -367
- package/src/engine/sandbox.ts +3 -3
- package/src/engine/simulation.ts +291 -76
- package/src/engine/spells.ts +9 -12
- package/src/engine-version.ts +1 -1
- package/src/hooks/action-builders.ts +76 -21
- package/src/hooks/index.ts +17 -9
- package/src/hooks/state-hooks.ts +61 -25
- package/src/hooks/threat-analysis.ts +44 -20
- package/src/hooks/types.ts +62 -5
- package/src/index.ts +2 -0
- package/src/rules.ts +209 -63
- package/src/stats.ts +2 -2
- package/src/testing.ts +6 -30
- package/src/trace.ts +63 -3
- package/src/types.ts +127 -14
- package/src/utils/angles.ts +1 -0
- package/src/utils/combat.ts +98 -6
- package/src/utils/spatial.ts +3 -3
- package/dist/chunk-74FFJCFF.js +0 -9140
- package/dist/chunk-74FFJCFF.js.map +0 -1
- package/src/hooks/bot-wrapper.ts +0 -84
package/dist/index-browser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ALL_BOTS,
|
|
3
|
-
|
|
3
|
+
ARENA_MAX,
|
|
4
|
+
ARENA_MIN,
|
|
4
5
|
ARENA_SIZE,
|
|
5
6
|
ARENA_WATER_BUFFER,
|
|
6
|
-
ARENA_WIDTH,
|
|
7
7
|
Archlich,
|
|
8
8
|
Archmage,
|
|
9
9
|
BLINK_CAST_TIME,
|
|
@@ -28,6 +28,11 @@ import {
|
|
|
28
28
|
Golem,
|
|
29
29
|
Hogger,
|
|
30
30
|
Infernalist,
|
|
31
|
+
KNOCKBACK_DAMAGE_THRESHOLD,
|
|
32
|
+
KNOCKBACK_DECAY,
|
|
33
|
+
KNOCKBACK_DELAY,
|
|
34
|
+
KNOCKBACK_SPEED_PER_DAMAGE,
|
|
35
|
+
LAVA_BORDER_WIDTH,
|
|
31
36
|
Lich,
|
|
32
37
|
MATCH_DURATION,
|
|
33
38
|
MAX_HEALTH,
|
|
@@ -50,6 +55,8 @@ import {
|
|
|
50
55
|
ManualMatch,
|
|
51
56
|
Nightblade,
|
|
52
57
|
Pyromancer,
|
|
58
|
+
RULES,
|
|
59
|
+
RULESET_RANGES,
|
|
53
60
|
Rookie,
|
|
54
61
|
SHIELD_CAST_TIME,
|
|
55
62
|
SHIELD_DECAY_PER_SECOND,
|
|
@@ -87,8 +94,8 @@ import {
|
|
|
87
94
|
angleDiff,
|
|
88
95
|
angleInRange,
|
|
89
96
|
angleTo,
|
|
90
|
-
antiHomingMissile,
|
|
91
97
|
applyDamage,
|
|
98
|
+
applyRulesetOverrides,
|
|
92
99
|
blink,
|
|
93
100
|
browserSandboxFight,
|
|
94
101
|
browserSandboxSimulate,
|
|
@@ -109,18 +116,22 @@ import {
|
|
|
109
116
|
createInitialState,
|
|
110
117
|
createRandom,
|
|
111
118
|
createWorkerScript,
|
|
119
|
+
currentRuleset,
|
|
112
120
|
diagnoseTrace,
|
|
113
121
|
directionAway,
|
|
114
122
|
directionTo,
|
|
115
123
|
distanceTo,
|
|
116
124
|
effectiveTurnRateCost,
|
|
117
125
|
extractAction,
|
|
126
|
+
extractMissileAction,
|
|
118
127
|
extractStats,
|
|
119
128
|
extractTraceEvents,
|
|
120
129
|
fight,
|
|
121
130
|
findInRange,
|
|
122
131
|
findNearest,
|
|
132
|
+
fitMissileForEscapingTarget,
|
|
123
133
|
fitMissileToBudget,
|
|
134
|
+
flyStraight,
|
|
124
135
|
formatDiagnosis,
|
|
125
136
|
formatStats,
|
|
126
137
|
formatTraceEvents,
|
|
@@ -128,17 +139,18 @@ import {
|
|
|
128
139
|
generateCandidates,
|
|
129
140
|
generateCombos,
|
|
130
141
|
getAdaptiveMissileConfig,
|
|
131
|
-
getBotContext,
|
|
132
142
|
getEffectiveRange,
|
|
133
143
|
getLeadPosition,
|
|
134
144
|
getMissileCastTime,
|
|
145
|
+
getMissileContext,
|
|
135
146
|
getPlayerState,
|
|
147
|
+
getWizardContext,
|
|
136
148
|
hashCombine,
|
|
137
149
|
homingMissile,
|
|
138
150
|
idle,
|
|
139
151
|
inRange,
|
|
140
152
|
interceptAngle,
|
|
141
|
-
|
|
153
|
+
isInLava,
|
|
142
154
|
magnitude,
|
|
143
155
|
missile,
|
|
144
156
|
move,
|
|
@@ -151,15 +163,17 @@ import {
|
|
|
151
163
|
normalizeAngle,
|
|
152
164
|
predictPosition,
|
|
153
165
|
resetAllHooks,
|
|
166
|
+
resetRuleset,
|
|
154
167
|
resolveWizardCollision,
|
|
155
|
-
runBotWithContext,
|
|
156
168
|
runWithHooks,
|
|
169
|
+
runWizardWithContext,
|
|
157
170
|
scoreFight,
|
|
158
171
|
scoreFightAsWizard2,
|
|
159
172
|
seekerMissile,
|
|
160
173
|
setParamValues,
|
|
161
174
|
shield,
|
|
162
175
|
simulate,
|
|
176
|
+
simulateMinDuration,
|
|
163
177
|
sortByDistance,
|
|
164
178
|
spiralMissile,
|
|
165
179
|
startCast,
|
|
@@ -170,6 +184,8 @@ import {
|
|
|
170
184
|
sweptCircleCollision,
|
|
171
185
|
testBot,
|
|
172
186
|
tick,
|
|
187
|
+
turnToAngle,
|
|
188
|
+
turnToward,
|
|
173
189
|
updateShield,
|
|
174
190
|
useArenaSize,
|
|
175
191
|
useBlinkCooldown,
|
|
@@ -182,11 +198,14 @@ import {
|
|
|
182
198
|
useEnemy,
|
|
183
199
|
useHealth,
|
|
184
200
|
useLastHitTick,
|
|
201
|
+
useLastMissileConfig,
|
|
185
202
|
useMemo,
|
|
186
203
|
useMyProjectiles,
|
|
187
204
|
useMyThreatsToEnemy,
|
|
188
205
|
useParam,
|
|
189
206
|
usePosition,
|
|
207
|
+
useProjectiles,
|
|
208
|
+
useRandom,
|
|
190
209
|
useRef,
|
|
191
210
|
useShieldStrength,
|
|
192
211
|
useState,
|
|
@@ -197,16 +216,16 @@ import {
|
|
|
197
216
|
useVelocity,
|
|
198
217
|
validateHookCall,
|
|
199
218
|
validateMissileConfig,
|
|
200
|
-
|
|
201
|
-
|
|
219
|
+
withMissileContext,
|
|
220
|
+
withWizardContext,
|
|
202
221
|
wrapWithParams
|
|
203
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-W7HWJFQ4.js";
|
|
204
223
|
export {
|
|
205
224
|
ALL_BOTS,
|
|
206
|
-
|
|
225
|
+
ARENA_MAX,
|
|
226
|
+
ARENA_MIN,
|
|
207
227
|
ARENA_SIZE,
|
|
208
228
|
ARENA_WATER_BUFFER,
|
|
209
|
-
ARENA_WIDTH,
|
|
210
229
|
Archlich,
|
|
211
230
|
Archmage,
|
|
212
231
|
BLINK_CAST_TIME,
|
|
@@ -231,6 +250,11 @@ export {
|
|
|
231
250
|
Golem,
|
|
232
251
|
Hogger,
|
|
233
252
|
Infernalist,
|
|
253
|
+
KNOCKBACK_DAMAGE_THRESHOLD,
|
|
254
|
+
KNOCKBACK_DECAY,
|
|
255
|
+
KNOCKBACK_DELAY,
|
|
256
|
+
KNOCKBACK_SPEED_PER_DAMAGE,
|
|
257
|
+
LAVA_BORDER_WIDTH,
|
|
234
258
|
Lich,
|
|
235
259
|
MATCH_DURATION,
|
|
236
260
|
MAX_HEALTH,
|
|
@@ -253,6 +277,8 @@ export {
|
|
|
253
277
|
ManualMatch,
|
|
254
278
|
Nightblade,
|
|
255
279
|
Pyromancer,
|
|
280
|
+
RULES,
|
|
281
|
+
RULESET_RANGES,
|
|
256
282
|
Rookie,
|
|
257
283
|
SHIELD_CAST_TIME,
|
|
258
284
|
SHIELD_DECAY_PER_SECOND,
|
|
@@ -290,8 +316,8 @@ export {
|
|
|
290
316
|
angleDiff,
|
|
291
317
|
angleInRange,
|
|
292
318
|
angleTo,
|
|
293
|
-
antiHomingMissile,
|
|
294
319
|
applyDamage,
|
|
320
|
+
applyRulesetOverrides,
|
|
295
321
|
blink,
|
|
296
322
|
browserSandboxFight,
|
|
297
323
|
browserSandboxSimulate,
|
|
@@ -312,18 +338,22 @@ export {
|
|
|
312
338
|
createInitialState,
|
|
313
339
|
createRandom,
|
|
314
340
|
createWorkerScript,
|
|
341
|
+
currentRuleset,
|
|
315
342
|
diagnoseTrace,
|
|
316
343
|
directionAway,
|
|
317
344
|
directionTo,
|
|
318
345
|
distanceTo,
|
|
319
346
|
effectiveTurnRateCost,
|
|
320
347
|
extractAction,
|
|
348
|
+
extractMissileAction,
|
|
321
349
|
extractStats,
|
|
322
350
|
extractTraceEvents,
|
|
323
351
|
fight,
|
|
324
352
|
findInRange,
|
|
325
353
|
findNearest,
|
|
354
|
+
fitMissileForEscapingTarget,
|
|
326
355
|
fitMissileToBudget,
|
|
356
|
+
flyStraight,
|
|
327
357
|
formatDiagnosis,
|
|
328
358
|
formatStats,
|
|
329
359
|
formatTraceEvents,
|
|
@@ -331,17 +361,18 @@ export {
|
|
|
331
361
|
generateCandidates,
|
|
332
362
|
generateCombos,
|
|
333
363
|
getAdaptiveMissileConfig,
|
|
334
|
-
getBotContext,
|
|
335
364
|
getEffectiveRange,
|
|
336
365
|
getLeadPosition,
|
|
337
366
|
getMissileCastTime,
|
|
367
|
+
getMissileContext,
|
|
338
368
|
getPlayerState,
|
|
369
|
+
getWizardContext,
|
|
339
370
|
hashCombine,
|
|
340
371
|
homingMissile,
|
|
341
372
|
idle,
|
|
342
373
|
inRange,
|
|
343
374
|
interceptAngle,
|
|
344
|
-
|
|
375
|
+
isInLava,
|
|
345
376
|
magnitude,
|
|
346
377
|
missile,
|
|
347
378
|
move,
|
|
@@ -354,15 +385,17 @@ export {
|
|
|
354
385
|
normalizeAngle,
|
|
355
386
|
predictPosition,
|
|
356
387
|
resetAllHooks,
|
|
388
|
+
resetRuleset,
|
|
357
389
|
resolveWizardCollision,
|
|
358
|
-
runBotWithContext,
|
|
359
390
|
runWithHooks,
|
|
391
|
+
runWizardWithContext,
|
|
360
392
|
scoreFight,
|
|
361
393
|
scoreFightAsWizard2,
|
|
362
394
|
seekerMissile,
|
|
363
395
|
setParamValues,
|
|
364
396
|
shield,
|
|
365
397
|
simulate,
|
|
398
|
+
simulateMinDuration,
|
|
366
399
|
sortByDistance,
|
|
367
400
|
spiralMissile,
|
|
368
401
|
startCast,
|
|
@@ -373,6 +406,8 @@ export {
|
|
|
373
406
|
sweptCircleCollision,
|
|
374
407
|
testBot,
|
|
375
408
|
tick,
|
|
409
|
+
turnToAngle,
|
|
410
|
+
turnToward,
|
|
376
411
|
updateShield,
|
|
377
412
|
useArenaSize,
|
|
378
413
|
useBlinkCooldown,
|
|
@@ -385,11 +420,14 @@ export {
|
|
|
385
420
|
useEnemy,
|
|
386
421
|
useHealth,
|
|
387
422
|
useLastHitTick,
|
|
423
|
+
useLastMissileConfig,
|
|
388
424
|
useMemo,
|
|
389
425
|
useMyProjectiles,
|
|
390
426
|
useMyThreatsToEnemy,
|
|
391
427
|
useParam,
|
|
392
428
|
usePosition,
|
|
429
|
+
useProjectiles,
|
|
430
|
+
useRandom,
|
|
393
431
|
useRef,
|
|
394
432
|
useShieldStrength,
|
|
395
433
|
useState,
|
|
@@ -400,8 +438,8 @@ export {
|
|
|
400
438
|
useVelocity,
|
|
401
439
|
validateHookCall,
|
|
402
440
|
validateMissileConfig,
|
|
403
|
-
|
|
404
|
-
|
|
441
|
+
withMissileContext,
|
|
442
|
+
withWizardContext,
|
|
405
443
|
wrapWithParams
|
|
406
444
|
};
|
|
407
445
|
//# sourceMappingURL=index-browser.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FightResult, SimulateResult } from './index-browser.js';
|
|
2
|
-
export { ALL_BOTS,
|
|
2
|
+
export { ALL_BOTS, ARENA_MAX, ARENA_MIN, ARENA_SIZE, ARENA_WATER_BUFFER, ActionBuilder, AnalyzedThreat, Archlich, Archmage, BLINK_CAST_TIME, BLINK_COOLDOWN, BLINK_MAX_COOLDOWN, BLINK_MAX_RANGE, BLINK_MIN_COOLDOWN, BLINK_RANGE, BOT_GROUPS, Battlemage, BlinkEvent, Bonemancer, BotError, BrowserManualMatchSandbox, BrowserMatchSandbox, BrowserSandboxOptions, CASTING_MOVEMENT_MULT, COLLISION_RADIUS, CastCancelEvent, CastStartEvent, Critter, Doombringer, ENGINE_VERSION, EnemyState, FIGHT_SPAWN_DISTANCES, FightStats, FightWinner, FinalAction, Flamecaller, GCD_DURATION, GameConfig, GameState, Golem, Hogger, HomingParams, HookState, Infernalist, 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, ManualMatchInitOptions, ManualMatchOptions, ManualMatchStepRequest, MatchWinner, MissileAction, MissileActions, MissileConfig, MissileContext, MissileExpiredEvent, MissileFunction, MissileHitEvent, MissileLaunchEvent, MissileOobEvent, MissileTemplate, Nightblade, ParamDeclaration, Position, ProjectileState, Pyromancer, RULES, RULESET_RANGES, 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, SeekerParams, Sentinel, Shadowblade, ShieldBlockEvent, ShieldStartEvent, SimEvent, Spellbinder, Spellseeker, Spellshot, Spellspinner, Spelltracer, Spellweaver, SpiralParams, StepResult, Stormcaller, Stormchaser, Stormforger, StraightParams, TICKS_PER_SECOND, TICK_DURATION_MS, TargetDummy, TestBotBuilder, TestFightResult, TestSimulateResult, TraceBotSummary, TraceEvent, TraceEventType, TraceSummary, Turtle, Velocity, Voidblade, WARMUP_DURATION_TOLERANCE, WARMUP_MAX_BONUS, WARMUP_MAX_PENALTY, WARMUP_SPEED_TOLERANCE, WARMUP_TURN_TOLERANCE, WIZARD_HEALTH, WIZARD_RADIUS, Warmage, WizardActions, WizardContext, WizardDeathEvent, WizardEntry, WizardFunction, WizardGroup, WizardLavaDeathEvent, WizardState, WorkerFactory, 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, isInLava, magnitude, 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 } from './index-browser.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A compiled bot ready for sandboxed execution.
|
|
@@ -54,7 +54,7 @@ declare function compileMatchBundle(bot1: BotBundle, bot2: BotBundle, options?:
|
|
|
54
54
|
interface SandboxOptions {
|
|
55
55
|
/** Memory limit in MB for the isolate (default: 512). */
|
|
56
56
|
memoryLimitMB?: number;
|
|
57
|
-
/** Timeout in ms for fight/simulate calls (default:
|
|
57
|
+
/** Timeout in ms for fight/simulate calls (default: 60000). */
|
|
58
58
|
timeoutMs?: number;
|
|
59
59
|
/** Options passed to esbuild compilation (aliases, externals). */
|
|
60
60
|
compileOptions?: CompileOptions;
|
|
@@ -147,4 +147,54 @@ declare function sandboxSimulate(bot1: BotBundle, bot2: BotBundle, options?: {
|
|
|
147
147
|
params2?: Record<string, number>;
|
|
148
148
|
} & SandboxOptions): Promise<SimulateResult>;
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Run a fight between two PRECOMPILED bot bundles — the canonical uploaded-wizard
|
|
152
|
+
* format where each IIFE sets `globalThis.__injectedBot1` (see compileSingleBotBundle).
|
|
153
|
+
*
|
|
154
|
+
* Shared by the Cloud Functions matchmaker and the devkit CLI so that a
|
|
155
|
+
* `handle/botname` fight runs through the exact same engine as the live ladder.
|
|
156
|
+
*
|
|
157
|
+
* Both bundles run inside an isolated-vm isolate alongside a "match template" —
|
|
158
|
+
* the engine + a `__fight` harness that reads the injected bots. The template is
|
|
159
|
+
* built lazily from the engine source on first use and cached; callers that
|
|
160
|
+
* already have one (the Cloud Functions committed MATCH_TEMPLATE) pass it in to
|
|
161
|
+
* skip the esbuild step.
|
|
162
|
+
*
|
|
163
|
+
* Execution order inside the isolate: bot1 bundle → bot2 bundle → match template.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Build (and cache) the match template: the engine + `__fight`/`__simulate`
|
|
168
|
+
* harness bundled into a single IIFE string, ready to run after two bot bundles
|
|
169
|
+
* have set `globalThis.__injectedBot1`/`__injectedBot2`.
|
|
170
|
+
*/
|
|
171
|
+
declare function buildMatchTemplate(): Promise<string>;
|
|
172
|
+
interface RunBundleFightOptions {
|
|
173
|
+
seed: number;
|
|
174
|
+
/** Prebuilt match template (e.g. the committed Cloud Functions one). Built lazily if omitted. */
|
|
175
|
+
matchTemplate?: string;
|
|
176
|
+
/** Skip per-tick history in the result (smaller copy out of the isolate). Default true. */
|
|
177
|
+
skipHistory?: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Run a fight between two compiled `__injectedBot1`-format bundles.
|
|
181
|
+
*
|
|
182
|
+
* bundle1 is saved and its global cleared before bundle2 runs, so bot code can
|
|
183
|
+
* never read the opponent's function off globalThis. Both globals are deleted
|
|
184
|
+
* after wiring so runtime bot code can't reach them either.
|
|
185
|
+
*/
|
|
186
|
+
declare function runBundleFight(bundle1: string, bundle2: string, options: RunBundleFightOptions): Promise<FightResult>;
|
|
187
|
+
interface RunBundleSimulateOptions {
|
|
188
|
+
seed?: number;
|
|
189
|
+
spawnDistance?: number;
|
|
190
|
+
maxTicks?: number;
|
|
191
|
+
matchTemplate?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Run a SINGLE match between two compiled bundles, returning the full per-tick
|
|
195
|
+
* history (for tracing/debugging). Same isolate wiring as runBundleFight, but
|
|
196
|
+
* calls the template's `__simulate` so the caller gets a SimulateResult.
|
|
197
|
+
*/
|
|
198
|
+
declare function runBundleSimulate(bundle1: string, bundle2: string, options?: RunBundleSimulateOptions): Promise<SimulateResult>;
|
|
199
|
+
|
|
200
|
+
export { BotBundle, type CompileOptions, FightResult, MatchSandbox, type RunBundleFightOptions, type RunBundleSimulateOptions, type SandboxOptions, SimulateResult, buildMatchTemplate, compileMatchBundle, runBundleFight, runBundleSimulate, sandboxFight, sandboxSimulate };
|