IPvGO

IPvGO

You must pass BN14.2 first

/** @param {NS} ns */ export async function main(ns) { const getRandomMove = (board, liberties, validMoves) => { const moveOptions = []; const size = board[0].length; // Look through all the points on the board for (let x = 0; x < size; x++) { for (let y = 0; y < size; y++) { // Make sure the point is a valid move const isValidMove = validMoves[x][y] === true; const N = board[x + 1]?.[y]; const n = liberties[x + 1]?.[y]; const S = board[x - 1]?.[y]; const s = liberties[x - 1]?.[y]; const E = board[x]?.[y + 1]; const e = liberties[x]?.[y + 1]; const W = board[x]?.[y - 1]; const w = liberties[x]?.[y - 1]; const NE = board[x + 1]?.[y + 1]; const ne = liberties[x + 1]?.[y + 1]; const SE = board[x - 1]?.[y + 1]; const se = liberties[x - 1]?.[y + 1]; const SW = board[x - 1]?.[y - 1]; const sw = liberties[x - 1]?.[y - 1]; const NW = board[x + 1]?.[y - 1]; const nw = liberties[x + 1]?.[y - 1]; // const bd = board[x][y]; const lb = liberties[x][y]; let white = N === 'O' || S === 'O' || E === 'O' || W === 'O' || NE === 'O' || SE === 'O' || SW === 'O' || NW === 'O'; // let white2 = NE === 'O' || SE === 'O' || SW === 'O' || NW === 'O'; let black = N === 'X' || S === 'X' || E === 'X' || W === 'X'; let p = n == 1 || s == 1 || e == 1 || w == 1; let p1 = n == 2 || s == 2 || e == 2 || w == 2; let p2 = n == 3 || s == 3 || e == 3 || w == 3; let p3 = n == 4 || s == 4 || e == 4 || w == 4; let p4 = n > 4 || s > 4 || e > 4 || w > 4; if (isValidMove) { if (black && p) { moveOptions.push([x, y]); } else if (white && p) { moveOptions.push([x, y]); } else if (white && p1) { moveOptions.push([x, y]); } else if (white && p2) { moveOptions.push([x, y]); } else if (white && p3) { moveOptions.push([x, y]); } else if (white && p4) { moveOptions.push([x, y]); } } /* if (isValidMove && black && bd !== '#' && isNotReservedSpace) { moveOptions.push([x, y]); }; */ } } // Choose one of the found moves at random const randomIndex = Math.floor(Math.random() * moveOptions.length); return moveOptions[randomIndex] ?? []; }; let result, x, y, m, n; let bo = ["Netburners", "Slum Snakes", "The Black Hand", "Daedalus", "Illuminati"] let success = ns.go.cheat.getCheatSuccessChance() const reset = ns.go.resetBoardState while (1) { ns.disableLog('ALL'); if (success < 0.8) { reset(bo[1], 13) } else if (ns.getHackingLevel() < 1000) { reset(bo[4], 13) } else { reset(bo[2], 13) } do { const board = ns.go.getBoardState(); // const board = ns.go.analysis.getControlledEmptyNodes(); const liberties = ns.go.analysis.getLiberties(); // const liberties = ns.go.analysis.getChains() const validMoves = ns.go.analysis.getValidMoves(); const [randX, randY] = getRandomMove(board, liberties, validMoves); const [randm, randn] = getRandomMove(board, liberties, validMoves); // TODO: more move options // Choose a move from our options x = randX; y = randY; m = randm; n = randn; if (x === undefined || m === undefined) { // Pass turn if no moves are found result = await ns.go.passTurn(); } else if (success < 0.8) { result = await ns.go.makeMove(x, y); } else { result = await ns.go.cheat.playTwoMoves(x, y, m, n); } ns.clearLog(); ns.print(`CheatSuccess ${ns.formatPercent(success)}`); ns.print(board) await ns.sleep(200); // Keep looping as long as the opponent is playing moves } while (result?.type !== "gameOver"); // After the opponent passes, end the game by passing as well await ns.go.passTurn(); await ns.sleep(1000); } }

Source: https://steamcommunity.com/sharedfiles/filedetails/?id=3244081827					

More Bitburner guilds