MapList
app/features/map-list-generator/core/MapList.tsNo overview comment at the top of the file.
- Imports
- no other modules
- Used by
- 1 route1 module3 other
Functions & values
Unique key of a mode-stage combination, e.g. modeStageKey("SZ", 1) gives "SZ-1".
export function modeStageKey(mode: ModeShort, stageId: StageId): string
Generates map lists avoiding stage repeats, optionally following a mode pattern.
export function* generate(args: { mapPool: MapPool; /** Bias towards maps not guaranteed to be played (e.g. maps 4 & 5 of a Bo5). True for best of formats. */ considerGuaranteed?: boolean; /** Initial weights keyed by `modeStageKey`. Negative weights deprioritize maps. */ initialWeights?: Map<string, number>; /** Skip inflating weights so half the pool is available, e.g. when initial weights already define the selection. */ skipEnsureMinimumCandidates?: boolean; /** Fixed mode order instead of a random shuffle. Intended for `resume`. */ modeOrder?: ModeShort[]; /** Mode-agnostic initial stage weights, how `resume` carries over stage-level penalties from history. */ initialStageWeights?: Map<StageId, number>; /** Filters per map index of a set, tried in order. The first one leaving any candidate narrows the draw. */ candidateFilters?: (index: number) => Array<(map: ModeWithStage) => boolean>; }): Generator<Array<ModeWithStage>, Array<ModeWithStage>, GenerateNext>
Unit tests (35)
- singular map list › returns an array of %d items× 3
- singular map list › includes
- singular map list › contains
- singular map list › repeats
- singular map list › does not repeat the stage order when the list goes through every stage twice
- singular map list › handles
- singular map list › follows
- singular map list › guarantees a must-include even when the pattern's only ANY slot is in the back half
- singular map list › places a non-guaranteed must-include when the pattern has no flexible slots but more maps than pattern parts
- singular map list › ignores
- many map lists › generates many map lists
- many map lists › has different maps in each list
- many map lists › randomizes the stage order
- many map lists › cycles a single mode order continuously across sets
- many map lists › uses the same mode order when a set spans the whole rotation
- many map lists › keeps
- many map lists › advances the cycle by the ANY slots consumed when a positional pattern is set
- many map lists › replenishes the stage id pool with different order
- many map lists › finds
- many map lists › applies different weight penalties based on guaranteed positions when considerGuaranteed is true
Generator primed to continue after history: mode order kept stable (rotated so the next mode is first) and played (mode, stage) pairs avoided unless every option in that mode was played.
export function resume(args: { mapPool: MapPool; history: Array<{ mode: ModeShort; stageId: StageId }>; })
Unit tests (6)
Modulesscrims/ScrimMapByMap.ts
Unit tests not about one export (19)
- MapList.generate() with initialWeights › accepts initialWeights parameter without errors
- MapList.generate() with initialWeights › handles
- MapList.generate() with initialWeights › initialWeights affect stage selection
- MapList.generate() with candidateFilters › draws
- MapList.generate() with candidateFilters › passes the map's index in the set to the filters
- parses
- handles
- returns
- if starts and ends with ANY, the ending ANY is dropped
- ignores repeated must include mode
- return error on lorem ipsum
Not shown, only used by tests: parsePattern