IPVGO: Add history, and details to status, to go API (#1348)

This commit is contained in:
Michael Ficocelli
2024-06-05 21:24:48 -04:00
committed by GitHub
parent 30a6419b11
commit cf48d666f5
6 changed files with 44 additions and 2 deletions
+10 -1
View File
@@ -612,6 +612,15 @@ export function boardStringFromBoard(board: Board): string {
* ```
*/
export function boardFromBoardString(boardString: string): Board {
const simpleBoardArray = simpleBoardFromBoardString(boardString);
return boardFromSimpleBoard(simpleBoardArray);
}
/**
* Slices a string representation of a board into an array of strings representing the rows on the board
*/
export function simpleBoardFromBoardString(boardString: string): SimpleBoard {
// Turn the SimpleBoard string into a string array, allowing access of each point via indexes e.g. [0][1]
const boardSize = Math.round(Math.sqrt(boardString.length));
const boardTiles = boardString.split("");
@@ -621,7 +630,7 @@ export function boardFromBoardString(boardString: string): Board {
.fill("")
.map((_, index) => boardTiles.slice(index * boardSize, (index + 1) * boardSize).join(""));
return boardFromSimpleBoard(simpleBoardArray);
return simpleBoardArray;
}
/** Creates a board object from a simple board. The resulting board has no analytics (liberties/chains) */