IPVGO: Add optional board state argument to the go analysis functions (#1716)

This commit is contained in:
Michael Ficocelli
2024-10-27 20:31:06 -04:00
committed by GitHub
parent ecc2d92edb
commit 6df3dcdc82
11 changed files with 231 additions and 39 deletions

View File

@@ -24,6 +24,7 @@ import {
handlePassTurn,
makePlayerMove,
resetBoardState,
validateBoardState,
validateMove,
validateTurn,
} from "../Go/effects/netscriptGoImplementation";
@@ -78,17 +79,21 @@ export function NetscriptGo(): InternalAPI<NSGo> {
return resetBoardState(logger(ctx), error(ctx), opponent, boardSize);
},
analysis: {
getValidMoves: () => () => {
return getValidMoves();
getValidMoves: (ctx) => (_boardState, _priorBoardState) => {
const State = validateBoardState(error(ctx), _boardState, _priorBoardState);
return getValidMoves(State);
},
getChains: () => () => {
return getChains();
getChains: (ctx) => (_boardState) => {
const State = validateBoardState(error(ctx), _boardState);
return getChains(State?.board);
},
getLiberties: () => () => {
return getLiberties();
getLiberties: (ctx) => (_boardState) => {
const State = validateBoardState(error(ctx), _boardState);
return getLiberties(State?.board);
},
getControlledEmptyNodes: () => () => {
return getControlledEmptyNodes();
getControlledEmptyNodes: (ctx) => (_boardState) => {
const State = validateBoardState(error(ctx), _boardState);
return getControlledEmptyNodes(State?.board);
},
getStats: () => () => {
return getStats();