Skip to main content

Overview

The Elimination Stage automaton handles Head-to-Head matches (1v1 or Team vs Team) with a sophisticated state machine that manages:
  • Ban phases (single or double ban rounds)
  • Pick phases (turn-based map selection)
  • Timeout system (one per team)
  • Best-of logic (BO7, BO9, BO11, etc.)
  • Tiebreaker enforcement
  • Score validation and win condition checking
Unlike the linear qualifier flow, elimination matches are dynamic and turn-based, requiring player interaction at each phase.

Match Flow

A typical elimination match follows this sequence:
1

Ban Phase

Teams alternate banning maps from the pool. The team with firstban privilege goes first.
  • Each team bans 2 maps (configurable)
  • Banned maps cannot be picked
  • Tiebreaker (TB1) cannot be banned
2

Pick Phase

Teams alternate picking maps to play. The team with firstpick privilege goes first.
  • Picked maps are loaded and played
  • Scores are tallied after each map
  • Picking alternates based on last pick (not based on who won)
3

Playing

When a map is picked:
  1. Map is loaded with correct mods
  2. 90-second timer starts
  3. Match begins when players ready or timer expires
  4. Scores are extracted via regex when match finishes
  5. Point awarded to winning team
4

Win Condition Check

After each map:
  • Check if either team reached (BestOf - 1) / 2 + 1 points
  • If tied at match point, automatically load tiebreaker
  • If win condition met, match ends

State Machine

The elimination automaton uses a complex state machine to manage the turn-based flow:

State Categories

CategoryStatesDescription
InitializationIdleWaiting for referee to configure and start
Banning PhaseBanPhaseStart
WaitingForBanRed
WaitingForBanBlue
System enforces map bans based on configured order
Picking PhasePickPhaseStart
WaitingForPickRed
WaitingForPickBlue
System waits for active team to select a map
GameplayWaitingForStart
Playing
Map loaded, timer running, or match in progress
ResolutionMatchFinishedOne team reached win condition
InterruptsOnTimeout
MatchOnHold
Timeout active or panic mode engaged

Pick and Ban Mechanics

Map Validation

When a player types a map slot (e.g., NM1, HD2), the system validates:
  1. Map exists in the current round’s pool
  2. Map is not already banned
  3. Map is not already picked
  4. Map is not TB1 (tiebreaker handled separately)
Source reference: AutoRefEliminationStage.cs:518-531

Ban Phase Logic

Default configuration: 2 bans per team, alternating
FirstBan: Red
Red bans → Blue bans → Red bans → Blue bans → Pick phase starts
Bans are stored with team attribution:
bannedMaps.Add(new RoundChoice { 
    Slot = content.ToUpper(), 
    TeamColor = TeamColor.TeamRed 
});

Pick Phase Logic

Picking alternates based on lastPick (who picked last, not who won):
FirstPick: Red
Red picks → Map plays → Blue picks → Map plays → Red picks...
Pick Timer Expiration: If the timer runs out without a pick:
  • Opponent gets to pick for them
  • Picking order is not altered
  • Next pick returns to original alternation
Source reference: AutoRefEliminationStage.cs:607-635

Tiebreaker Enforcement

When both teams reach match point:
if (pickedMaps.Count == currentMatch.Round.BestOf - 1)
{
    await PreparePick("TB1");
    pickedMaps.Add(new RoundChoice { 
        Slot = "TB1", 
        TeamColor = TeamColor.None 
    });
}
The tiebreaker is automatically loaded—no pick required. Source reference: AutoRefEliminationStage.cs:804-809

Best-Of Logic

Win condition is calculated dynamically:
int pointsToWin = (currentMatch.Round.BestOf - 1) / 2 + 1;

bool redWin = matchScore[0] == pointsToWin;
bool blueWin = matchScore[1] == pointsToWin;
Best OfPoints to WinExample Score
BO744-2, 4-3
BO955-3, 5-4
BO1166-4, 6-5
BO1377-5, 7-6
Source reference: AutoRefEliminationStage.cs:811-826

Score Processing

Scores are extracted using regex when BanchoBot announces results:
var match = Regex.Match(content, @"^(.*) finished playing \(Score: (\d+),");

if (match.Success)
{
    string nick = match.Groups[1].Value;
    int score = int.Parse(match.Groups[2].Value);
    currentMapScores[nick] = score;
}
After “The match has finished!” is detected, scores are aggregated:
foreach (var player in currentMapScores)
{
    if (player.Key.Equals(currentMatch.TeamRed.DisplayName, ...))
        redTotal += player.Value;
    else if (player.Key.Equals(currentMatch.TeamBlue.DisplayName, ...))
        blueTotal += player.Value;
}
The team with the higher total wins the point. Source reference: AutoRefEliminationStage.cs:270-289, 336-364

Double Ban Rounds

For certain rounds (e.g., semifinals, finals), a second ban phase occurs mid-match:
if (currentMatch.Round.BanRounds == 2 && pickedMaps.Count == 4)
{
    currentState = MatchState.SecondBanPhaseStart;
    // Each team bans 2 more maps
}
Workflow:
  1. Initial ban phase (2 per team)
  2. Play 4 maps
  3. Second ban phase (2 per team)
  4. Continue picking from remaining maps
The second ban phase reverses the ban order (if Red banned first initially, Blue bans first in round 2). Source reference: AutoRefEliminationStage.cs:655-667, 795-800

Administrative Commands

Commands prefixed with > can be issued by the assigned referee via IRC or Discord.

Configuration Commands

1

Set First Pick

>firstpick [red/blue]
Sets which team picks first. Required before starting automation.Example:
>firstpick red
2

Set First Ban

>firstban [red/blue]
Sets which team bans first. Required before starting automation.Example:
>firstban blue

Control Commands

1

Start Automation

>start
Engages auto mode. Requires firstpick and firstban to be set.The system will:
  1. Validate configuration
  2. Enter BanPhaseStart
  3. Begin the state machine cycle
You cannot start automation if firstpick or firstban are not configured. The bot will respond with “Properties not initialized.”
2

Stop Automation

>stop
Stops automation and returns manual control. The current state is preserved for resume.
3

Invoke Timeout

>timeout
Referee-initiated timeout (doesn’t consume player timeout quota). Pauses the match indefinitely until manually resumed.To resume, the referee types any command or waits for the system to auto-resume after the countdown.

Utility Commands

1

Invite Players

>invite
Invites both team captains to the lobby:
!mp invite {TeamRed}
!mp invite {TeamBlue}
2

Show Map Status

>maps
Displays current match state:
Bans: NM1, HD2, HR1, DT2 | Picks: NM3, HD1, HR2
Available maps: NM2, NM4, DT1, FM1, FM2, TB1
Timeouts available: Red: true | Blue: false
3

Manually Set Map

>setmap [slot]
Manually loads a specific map with mods. Can only be used when automaton is idle.Example:
>setmap HD2
Loads the second HardRock map with mods HD NF and starts a 90-second timer.
4

Force Close

>finish
Forces lobby closure. Being phased out—use /endref instead.

Player Commands

Players interact with the automation by typing in IRC chat:

Pick and Ban

During their turn, players type the map slot:
NM1
HD2
HR3
DT1
FM2
The system validates and processes the input automatically.

Timeout Request

Players can request a timeout:
!timeout
Timeout Rules:
  • Each team gets one timeout per match
  • Can be called during ban phase, pick phase, or while waiting for start
  • Timeout lasts for a fixed duration (configurable timer)
  • System tracks usage via redTimeoutRequest and blueTimeoutRequest flags
Source reference: AutoRefEliminationStage.cs:569-602
Timeout requests are validated against the sender’s team. If a team already used their timeout, subsequent requests are ignored.

Room Settings

Elimination rooms use TeamVs mode with ScoreV2 and 3 slots (1 per team + referee):
!mp set 2 3 3
  • TeamMode: 2 (TeamVs)
  • WinCondition: 3 (ScoreV2)
  • Slots: 3

Safety and Logging

Discord Thread Integration

Every elimination match gets its own Discord thread:
  • All IRC messages mirrored in real-time
  • Pick/ban history logged
  • Score updates posted automatically
  • Win condition announcements

Manual IRC Access

On match start, the bot provides the IRC join command:
Join this match via an IRC app with this command:
- /join #mp_987654321
Use this if:
  • The server disconnects
  • Manual intervention is required during panic
  • You want to observe the match directly

Panic Protocol

See Panic Protocol for emergency override procedures.

Best Practices

1

Pre-Match Configuration

  1. Verify both teams are correctly assigned in database
  2. Confirm map pool is loaded for the round
  3. Determine first pick/ban (coin flip, higher seed, etc.)
  4. Set >firstpick and >firstban before starting
2

During Match

  1. Use >invite to bring players into lobby
  2. Ensure both teams are in correct slots (Red vs Blue)
  3. Start automation with >start
  4. Monitor Discord thread for disputes or technical issues
  5. Use !panic if anything goes wrong
  6. Use >maps to check current match status
3

Post-Match

  1. Wait for win condition (state reaches MatchFinished)
  2. Verify final score in Discord thread
  3. Use /endref [match-id] to save picks, bans, and MP link
  4. Archive thread for future reference
Never use !mp close before /endref. Closing the lobby early prevents the system from saving picks, bans, and the MP link ID to the database.

Technical Details

State Transition Logic

The state machine is event-driven, triggered by:
  • Player chat input (map slot during pick/ban)
  • BanchoBot messages (“All players are ready”, “Countdown finished”, “The match has finished”)
  • Admin commands (>start, >stop, >timeout)
  • Panic triggers (!panic, >panic_over)
Source reference: AutoRefEliminationStage.cs:564-845

Data Persistence

On /endref, the following are saved:
await db.MatchRooms
    .Where(m => m.Id == matchId)
    .ExecuteUpdateAsync(s => s
        .SetProperty(m => m.MpLinkId, mpLinkId)
        .SetProperty(m => m.PickedMaps, pickedMaps) 
        .SetProperty(m => m.BannedMaps, bannedMaps)
        .SetProperty(m => m.EndTime, DateTime.UtcNow)
    );
This ensures picks, bans, and match history are permanently stored. Source reference: AutoRefEliminationStage.cs:174-183

Build docs developers (and LLMs) love