IPVGO: Add new analysis method to set a custom testing board state (#2029)

This commit is contained in:
Michael Ficocelli
2025-03-23 02:52:26 -04:00
committed by GitHub
parent de8c8691c2
commit 17ffabdfa5
11 changed files with 76 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ import {
makePlayerMove,
resetBoardState,
resetStats,
setTestingBoardState,
validateBoardState,
validateMove,
} from "../Go/effects/netscriptGoImplementation";
@@ -104,6 +105,15 @@ export function NetscriptGo(): InternalAPI<NSGo> {
(resetAll = false) => {
resetStats(!!resetAll);
},
setTestingBoardState: (ctx) => (_boardState, _komi) => {
const State = validateBoardState(error(ctx), _boardState);
if (!State) {
error(ctx)("Invalid board state passed to setTestingBoardState()");
return;
}
const komi: number | undefined = _komi !== undefined ? helpers.number(ctx, "komi", _komi) : undefined;
return setTestingBoardState(State.board, komi);
},
},
cheat: {
getCheatSuccessChance: (ctx: NetscriptContext) => (_cheatCount, playAsWhite) => {