IPVGO: Bugfixes (#1193)

* IPVGO: Explicitly link the generated API documentation in the algorithm design doc
* IPVGO: Fix missing factions in netscript docs
* IPVGO: Linting
* IPVGO: Ensure resetBoardState() logs that a new game has started
This commit is contained in:
Michael Ficocelli
2024-03-28 01:02:53 -04:00
committed by GitHub
parent 8553bcb8fc
commit fe87f1f628
9 changed files with 34 additions and 14 deletions
@@ -4,6 +4,8 @@ IPvGO is a strategic territory control minigame accessible from DefComm in New T
For basic instructions, go to DefComm or CIA to access the current subnet, and look through the "How to Play" section. This document is specifically focused on building scripts to automate subnet takeover, which will be more applicable you have played a few subnets.
For a full list of all IpvGO methods and their descriptions and documentation, you can use the game's [API documentation page](https://github.com/bitburner-official/bitburner-src/blob/dev/markdown/bitburner.go.md).
 
#### Overview
+8 -2
View File
@@ -336,7 +336,12 @@ function logEndGame(logger: (s: string) => void) {
/**
* Clears the board, resets winstreak if applicable
*/
export function resetBoardState(error: (s: string) => void, opponent: GoOpponent, boardSize: number) {
export function resetBoardState(
logger: (s: string) => void,
error: (s: string) => void,
opponent: GoOpponent,
boardSize: number,
) {
if (![5, 7, 9, 13].includes(boardSize) && opponent !== GoOpponent.w0r1d_d43m0n) {
error(`Invalid subnet size requested (${boardSize}), size must be 5, 7, 9, or 13`);
return;
@@ -354,6 +359,7 @@ export function resetBoardState(error: (s: string) => void, opponent: GoOpponent
Go.currentGame = getNewBoardState(boardSize, opponent, true);
GoEvents.emit(); // Trigger a Go UI rerender
logger(`New game started: ${opponent}, ${boardSize}x${boardSize}`);
return simpleBoardFromBoard(Go.currentGame.board);
}
@@ -392,7 +398,7 @@ export async function determineCheatSuccess(
// If there have been prior cheat attempts, and the cheat fails, there is a 10% chance of instantly losing
else if (state.cheatCount && (ejectRngOverride ?? rng.random()) < 0.1) {
logger(`Cheat failed! You have been ejected from the subnet.`);
resetBoardState(logger, state.ai, state.board[0].length);
resetBoardState(logger, logger, state.ai, state.board[0].length);
return {
type: GoPlayType.gameOver,
x: null,
+1 -1
View File
@@ -68,7 +68,7 @@ export function NetscriptGo(): InternalAPI<NSGo> {
const opponent = getEnumHelper("GoOpponent").nsGetMember(ctx, _opponent);
const boardSize = helpers.number(ctx, "boardSize", _boardSize);
return resetBoardState(error(ctx), opponent, boardSize);
return resetBoardState(logger(ctx), error(ctx), opponent, boardSize);
},
analysis: {
getValidMoves: () => () => {
+10 -3
View File
@@ -3926,7 +3926,14 @@ export interface Gang {
}
/** @public */
type GoOpponent = "Netburners" | "Slum Snakes" | "The Black Hand" | "Tetrads" | "Daedalus" | "Illuminati";
type GoOpponent =
| "Netburners"
| "Slum Snakes"
| "The Black Hand"
| "Tetrads"
| "Daedalus"
| "Illuminati"
| "????????????";
/**
* IPvGO api
@@ -4035,7 +4042,7 @@ export interface Go {
/**
* Returns the name of the opponent faction in the current subnet.
*/
getOpponent(): GoOpponent | "No AI" | "????????????";
getOpponent(): GoOpponent | "No AI";
/**
* Gets new IPvGO subnet with the specified size owned by the listed faction, ready for the player to make a move.
@@ -4044,7 +4051,7 @@ export interface Go {
*
* Note that some factions will have a few routers on the subnet at this state.
*
* opponent is "Netburners" or "Slum Snakes" or "The Black Hand" or "Daedalus" or "Illuminati",
* opponent is "Netburners" or "Slum Snakes" or "The Black Hand" or "Tetrads" or "Daedalus" or "Illuminati" or "????????????",
*
* @returns a simplified version of the board state as an array of strings representing the board columns. See ns.Go.getBoardState() for full details
*