IPVGO: Remove current game history from savefile, re-implement superko (#1175)

This commit is contained in:
Michael Ficocelli
2024-03-20 20:37:20 -04:00
committed by GitHub
parent fc8958af83
commit 1e5f7184a2
12 changed files with 45 additions and 29 deletions

View File

@@ -81,7 +81,7 @@ describe("Netscript Go API unit tests", () => {
it("should correctly retrieve the current game state", async () => {
const board = ["OXX..", ".....", ".....", "...XX", "...X."];
const boardState = boardStateFromSimpleBoard(board, GoOpponent.Daedalus, GoColor.black);
boardState.previousBoard = ["OX..", ".....", ".....", "...XX", "...X."];
boardState.previousBoards = [["OX..", ".....", ".....", "...XX", "...X."]];
Go.currentGame = boardState;
const result = getGameState();
@@ -232,7 +232,7 @@ describe("Netscript Go API unit tests", () => {
await cheatPlayTwoMoves(mockLogger, 4, 3, 3, 4, 1, 0);
expect(mockLogger).toHaveBeenCalledWith("Cheat failed! You have been ejected from the subnet.");
expect(Go.currentGame.previousBoard).toEqual(null);
expect(Go.currentGame.previousBoards).toEqual([]);
});
});
describe("cheatRemoveRouter() tests", () => {
@@ -270,7 +270,7 @@ describe("Netscript Go API unit tests", () => {
await cheatRemoveRouter(mockLogger, 0, 0, 1, 0);
expect(mockLogger).toHaveBeenCalledWith("Cheat failed! You have been ejected from the subnet.");
expect(Go.currentGame.previousBoard).toEqual(null);
expect(Go.currentGame.previousBoards).toEqual([]);
});
});
describe("cheatRepairOfflineNode() tests", () => {

View File

@@ -53,4 +53,16 @@ describe("Go board analysis tests", () => {
expect(validity).toEqual(GoValidity.noSuicide);
});
it("identifies invalid moves from repeat", async () => {
const board = [".X...", ".....", ".....", ".....", "....."];
const boardState = boardStateFromSimpleBoard(board);
boardState.previousBoards.push([".X...", ".....", ".....", ".....", "....."]);
boardState.previousBoards.push([".X...", ".....", ".....", ".....", "....."]);
boardState.previousBoards.push([".X...", ".....", ".....", ".....", "....."]);
boardState.previousBoards.push(["OX...", ".....", ".....", ".....", "....."]);
const validity = evaluateIfMoveIsValid(boardState, 0, 0, GoColor.white, false);
expect(validity).toEqual(GoValidity.boardRepeated);
});
});

View File

@@ -41,7 +41,6 @@ exports[`Check Save File Continuity GoSave continuity 1`] = `
],
"cheatCount": 0,
"passCount": 0,
"previousBoard": null,
"previousPlayer": "White",
},
"previousGame": null,