mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 12:45:45 +01:00
IPVGO: Fix self-capture move evaluation (#1140)
This commit is contained in:
parent
1755b7cd7f
commit
1547581c24
@ -480,12 +480,12 @@ export function findAllCapturedChains(chainList: PointState[][], playerWhoMoved:
|
|||||||
const opposingPlayer = playerWhoMoved === GoColor.white ? GoColor.black : GoColor.white;
|
const opposingPlayer = playerWhoMoved === GoColor.white ? GoColor.black : GoColor.white;
|
||||||
const enemyChainsToCapture = findCapturedChainOfColor(chainList, opposingPlayer);
|
const enemyChainsToCapture = findCapturedChainOfColor(chainList, opposingPlayer);
|
||||||
|
|
||||||
if (enemyChainsToCapture) {
|
if (enemyChainsToCapture.length) {
|
||||||
return enemyChainsToCapture;
|
return enemyChainsToCapture;
|
||||||
}
|
}
|
||||||
|
|
||||||
const friendlyChainsToCapture = findCapturedChainOfColor(chainList, playerWhoMoved);
|
const friendlyChainsToCapture = findCapturedChainOfColor(chainList, playerWhoMoved);
|
||||||
if (friendlyChainsToCapture) {
|
if (friendlyChainsToCapture.length) {
|
||||||
return friendlyChainsToCapture;
|
return friendlyChainsToCapture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import { setPlayer } from "@player";
|
import { setPlayer } from "@player";
|
||||||
import { GoColor } from "@enums";
|
import { GoColor, GoValidity } from "@enums";
|
||||||
import { PlayerObject } from "../../../src/PersonObjects/Player/PlayerObject";
|
import { PlayerObject } from "../../../src/PersonObjects/Player/PlayerObject";
|
||||||
import { getAllEyes, getAllValidMoves, boardStateFromSimpleBoard } from "../../../src/Go/boardAnalysis/boardAnalysis";
|
import {
|
||||||
|
getAllEyes,
|
||||||
|
getAllValidMoves,
|
||||||
|
boardStateFromSimpleBoard,
|
||||||
|
evaluateIfMoveIsValid,
|
||||||
|
} from "../../../src/Go/boardAnalysis/boardAnalysis";
|
||||||
import { findAnyMatchedPatterns } from "../../../src/Go/boardAnalysis/patternMatching";
|
import { findAnyMatchedPatterns } from "../../../src/Go/boardAnalysis/patternMatching";
|
||||||
|
|
||||||
setPlayer(new PlayerObject());
|
setPlayer(new PlayerObject());
|
||||||
@ -40,4 +45,12 @@ describe("Go board analysis tests", () => {
|
|||||||
expect(point?.x).toEqual(3);
|
expect(point?.x).toEqual(3);
|
||||||
expect(point?.y).toEqual(2);
|
expect(point?.y).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("identifies invalid moves from self-capture", async () => {
|
||||||
|
const board = [".X...", "X....", ".....", ".....", "....."];
|
||||||
|
const boardState = boardStateFromSimpleBoard(board);
|
||||||
|
const validity = evaluateIfMoveIsValid(boardState, 0, 0, GoColor.white, false);
|
||||||
|
|
||||||
|
expect(validity).toEqual(GoValidity.noSuicide);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user