Select bulk opponent

This commit is contained in:
2025-11-03 16:40:59 -08:00
parent bfbd9d35bc
commit 0db5b7a8f1
7 changed files with 413 additions and 12 deletions

View File

@@ -53,7 +53,9 @@ export async function startScript(
}
export async function startScriptBulk(
script: string,
redScript: string,
blueScript: string,
opponentName: string,
appendOutput: (line: string) => void,
appendTerminal: (line: string) => void,
rounds: number = 1000
@@ -93,7 +95,7 @@ export async function startScriptBulk(
reject(error);
};
worker.postMessage({ type: "run", script, rounds });
worker.postMessage({ type: "run", redScript, blueScript, opponentName, rounds });
});
}

View File

@@ -56,11 +56,11 @@ self.onmessage = async (event) => {
appendTerminal(`============\n\n\r`);
currentGame = new MinMaxGame(
event_data.script,
event_data.redScript,
() => {},
() => {},
event_data.script,
event_data.blueScript,
() => {},
() => {},
@@ -89,13 +89,19 @@ self.onmessage = async (event) => {
}
const elapsed = Math.round((performance.now() - start) / 100) / 10;
const r_winrate = Math.round((red_wins / n_rounds) * 1000) / 10
const b_winrate = Math.round((blue_wins / n_rounds) * 1000) / 10
const r_winrate = Math.round((red_wins / n_rounds) * 1000) / 10;
const b_winrate = Math.round((blue_wins / n_rounds) * 1000) / 10;
const opponentName = event_data.opponentName || "Unknown";
appendTerminal("\r\n");
appendTerminal(`Ran ${n_rounds} rounds in ${elapsed}s\r\n`);
appendTerminal(`Red won: ${red_wins} (${r_winrate}%)\r\n`);
appendTerminal(`Blue won: ${blue_wins} (${b_winrate}%)\r\n`);
appendTerminal(
`Red won: ${red_wins} (${r_winrate}%) (script)\r\n`
);
appendTerminal(
`Blue won: ${blue_wins} (${b_winrate}%) (${opponentName})\r\n`
);
appendTerminal("\r\n");
appendTerminal(`Draws: ${draw_score}\r\n`);
appendTerminal(`Invalid: ${draw_invalid}\r\n`);