From 17ffabdfa512347682d5ab718c4d007e39575448 Mon Sep 17 00:00:00 2001
From: Michael Ficocelli Displays the game history, captured nodes, and gained bonuses for each opponent you have played against. The details are keyed by opponent name, in this structure: {
Shows if each point on the board is a valid move for the player. By default, analyzes the current board state. Takes an optional boardState (and an optional prior-move boardState, if desired) to analyze a custom board.
The true/false validity of each move can be retrieved via the X and Y coordinates of the move. const validMoves = ns.go.analysis.getValidMoves();
const moveIsValid = validMoves[x][y];
Note that the \[0\]\[0\] point is shown on the bottom-left on the visual board (as is traditional), and each string represents a vertical column on the board. In other words, the printed example above can be understood to be rotated 90 degrees clockwise compared to the board UI as shown in the IPvGO subnet tab.
Also note that, when given a custom board state, only one prior move can be analyzed. This means that the superko rules (no duplicate board states in the full game history) is not supported; you will have to implement your own analysis for that.
playAsWhite is optional, and gets the current valid moves for the white player. Intended to be used when playing as white when the opponent is set to "No AI"
| | [resetStats(resetAll)](./bitburner.goanalysis.resetstats.md) | Reset all win/loss and winstreak records for the No AI opponent. | +| [setTestingBoardState(boardState)](./bitburner.goanalysis.settestingboardstate.md) | Starts a new game against the "No AI" opponent, and sets the initial board size, pieces, and offline nodes to the given board state. "X" represent black pieces, "O" white, and "." empty points. "\#" are dead nodes that are not part of the subnet. | diff --git a/markdown/bitburner.goanalysis.settestingboardstate.md b/markdown/bitburner.goanalysis.settestingboardstate.md new file mode 100644 index 000000000..14a4e4efd --- /dev/null +++ b/markdown/bitburner.goanalysis.settestingboardstate.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [GoAnalysis](./bitburner.goanalysis.md) > [setTestingBoardState](./bitburner.goanalysis.settestingboardstate.md) + +## GoAnalysis.setTestingBoardState() method + +Starts a new game against the "No AI" opponent, and sets the initial board size, pieces, and offline nodes to the given board state. "X" represent black pieces, "O" white, and "." empty points. "\#" are dead nodes that are not part of the subnet. + +**Signature:** + +```typescript +setTestingBoardState(boardState: string[]): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| boardState | string\[\] | The initial board state to use for the new game, in the format used by getBoardState(). | + +**Returns:** + +void + +## Remarks + +RAM cost: 4 GB + diff --git a/src/Go/Types.ts b/src/Go/Types.ts index 677555104..492bdb785 100644 --- a/src/Go/Types.ts +++ b/src/Go/Types.ts @@ -54,6 +54,7 @@ export type BoardState = { passCount: number; cheatCount: number; cheatCountForWhite: number; + komiOverride: number | null; }; export type PointState = { diff --git a/src/Go/boardAnalysis/goAI.ts b/src/Go/boardAnalysis/goAI.ts index 21775f9f6..5a123e0e2 100644 --- a/src/Go/boardAnalysis/goAI.ts +++ b/src/Go/boardAnalysis/goAI.ts @@ -860,8 +860,11 @@ function getMoveOptions(boardState: BoardState, player: GoColor, rng: number, sm /** * Gets the starting score for white. */ -export function getKomi(opponent: GoOpponent) { - return opponentDetails[opponent].komi; +export function getKomi(state: BoardState): number { + if (state.komiOverride !== null) { + return state.komiOverride; + } + return opponentDetails[state.ai].komi; } /** diff --git a/src/Go/boardAnalysis/scoring.ts b/src/Go/boardAnalysis/scoring.ts index 2189ea740..556bfed26 100644 --- a/src/Go/boardAnalysis/scoring.ts +++ b/src/Go/boardAnalysis/scoring.ts @@ -17,7 +17,7 @@ import { Go, GoEvents } from "../Go"; * fully surrounded by their pieces */ export function getScore(boardState: BoardState) { - const komi = getKomi(boardState.ai) ?? 6.5; + const komi = getKomi(boardState) ?? 6.5; const whitePieces = getColoredPieceCount(boardState, GoColor.white); const blackPieces = getColoredPieceCount(boardState, GoColor.black); const territoryScores = getTerritoryScores(boardState.board); diff --git a/src/Go/boardState/boardState.ts b/src/Go/boardState/boardState.ts index c03440096..070591bbb 100644 --- a/src/Go/boardState/boardState.ts +++ b/src/Go/boardState/boardState.ts @@ -35,6 +35,7 @@ export function getNewBoardState( passCount: 0, cheatCount: 0, cheatCountForWhite: 0, + komiOverride: null, board: Array.from({ length: boardSize }, (_, x) => Array.from({ length: boardSize }, (_, y) => !boardToCopy || boardToCopy?.[x]?.[y] diff --git a/src/Go/effects/netscriptGoImplementation.ts b/src/Go/effects/netscriptGoImplementation.ts index ac8230d9f..7348ae239 100644 --- a/src/Go/effects/netscriptGoImplementation.ts +++ b/src/Go/effects/netscriptGoImplementation.ts @@ -2,7 +2,7 @@ import { Board, BoardState, OpponentStats, Play, SimpleBoard, SimpleOpponentStat import { Player } from "@player"; import { AugmentationName, GoColor, GoOpponent, GoPlayType, GoValidity } from "@enums"; -import { Go } from "../Go"; +import { Go, GoEvents } from "../Go"; import { getNewBoardState, getNewBoardStateFromSimpleBoard, @@ -263,6 +263,20 @@ export function getControlledEmptyNodes(_board?: Board) { ); } +export function setTestingBoardState(board: Board, komi?: number) { + resetBoardState( + () => {}, + () => {}, + GoOpponent.none, + board.length, + ); + Go.currentGame.board = board; + if (komi != undefined) { + Go.currentGame.komiOverride = komi; + } + GoEvents.emit(); +} + /** * Returns all previous board states as SimpleBoards */ diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 924ab0edc..524980668 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -271,6 +271,7 @@ const go = { getControlledEmptyNodes: 16, getStats: 0, resetStats: 0, + setTestingBoardState: 4, }, cheat: { getCheatSuccessChance: 1, diff --git a/src/NetscriptFunctions/Go.ts b/src/NetscriptFunctions/Go.ts index 8a8aa2a05..f23e96e74 100644 --- a/src/NetscriptFunctions/Go.ts +++ b/src/NetscriptFunctions/Go.ts @@ -25,6 +25,7 @@ import { makePlayerMove, resetBoardState, resetStats, + setTestingBoardState, validateBoardState, validateMove, } from "../Go/effects/netscriptGoImplementation"; @@ -104,6 +105,15 @@ export function NetscriptGo(): InternalAPI