Files
bitburner-src/markdown/bitburner.goanalysis.getvalidmoves.md
Michael Taylor dcd2f33f7c CODEBASE: Update api-documentor and api-extractor (#2320)
* Update api-documentor and api-extractor. #1566 follow-up.

I have verified that the HTML/markdown table generation bug in
[#4878](https://github.com/microsoft/rushstack/issues/4878) in rushstack
for api-documentor has been fixed as per rushstack#5256. The testcase
[repro](https://github.com/catloversg/api-documenter-bug-pr-4578) now
produces the correct expected output.

I have confirmed that the generated output in bitburner from
`npm run doc` now generated HTML tables, and correctly inserts
a blank line between the </table> and the follow line (e.g. Returns).

Stylisticly it could use some whitespace, but it is correctly rendered.

This commit is only the updated packages, not the updated generated
documentation. I assume that is automatically generated by the GitHub
workflow.

* Follow up to 5f732a6f35, include `npm run doc` changed docs.

* Add missing license info

* Fix React warning

---------

Co-authored-by: CatLover <152669316+catloversg@users.noreply.github.com>
2025-09-26 14:52:39 -07:00

2.6 KiB

Home > bitburner > GoAnalysis > getValidMoves

GoAnalysis.getValidMoves() method

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.

The current valid moves for white can also be seen by simply calling ns.go.analysis.getValidMoves(true) .

Signature:

getValidMoves(boardState?: string[] | boolean, priorBoardState?: string[], playAsWhite?: boolean): boolean[][];

Parameters

Parameter

Type

Description

boardState

string[] | boolean

(Optional) Optional. The board state to analyze, in the string[] format used by getBoardState(). Defaults to the current board state. Alternatively can be simply "true" to get current valid moves for white.

priorBoardState

string[]

(Optional) Optional. The move before the board state to analyze, in the format used by getBoardState(). Defaults to the current board's prior move state.

playAsWhite

boolean

(Optional) Optional. Whether to analyze the board state as if the white player is the current player. Defaults to false. Intended to be used when playing as white when the opponent is set to "No AI".

Returns:

boolean[][]

A 2D array of booleans indicating the validity of each move.

Remarks

RAM cost: 8 GB (This is intentionally expensive; you can derive this info from just getBoardState() and getMoveHistory() )