Skip to content
28 changes: 1 addition & 27 deletions src/games/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class GoGame extends GameBase {
{ uid: "size-25", group: "board" },
{ uid: "size-37", group: "board" },
],
categories: ["goal>connect", "mechanic>place", "mechanic>capture", "mechanic>enclose", "board>connect>rect", "components>simple"],
categories: ["goal>area", "mechanic>place", "mechanic>capture", "mechanic>enclose", "board>shape>rect", "components>simple>2c"],
flags: ["scores", "custom-buttons", "custom-colours", "experimental"],
};

Expand Down Expand Up @@ -213,23 +213,6 @@ export class GoGame extends GameBase {
return moves;
}

private hasMoves(player?: playerid): boolean {
// Check if the player has any valid moves.
if (player === undefined) {
player = this.currplayer;
}
for (let row = 0; row < this.boardSize; row++) {
for (let col = 0; col < this.boardSize; col++) {
const cell = this.coords2algebraic(col, row);
if (this.board.has(cell)) { continue; }
if (this.isSelfCapture(cell, player)) { continue; }
if (this.checkKo(cell, player)) { continue; }
return true;
}
}
return false;
}

public randomMove(): string {
const moves = this.moves();
return moves[Math.floor(Math.random() * moves.length)];
Expand Down Expand Up @@ -601,15 +584,6 @@ export class GoGame extends GameBase {
this.gameover = this.lastmove === "pass" &&
this.stack[this.stack.length - 1].lastmove === "pass";

const otherPlayer = this.currplayer % 2 + 1 as playerid;

if (!this.gameover && !this.hasMoves(this.currplayer)) {
this.gameover = true;
this.winner = [otherPlayer];
this.results.push({ type: "eog", reason: "stalemate" });
return this;
}

// if a cycle is found, the game ends in a draw
// NB: when Super-Ko is implemented, this should never happen
if (!this.gameover) {
Expand Down
1 change: 1 addition & 0 deletions src/games/stiletto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class StilettoGame extends InARowBase {
this.board = new Map(state.board);
this.winningLines = state.winningLines.map(a => [...a]);
this.swapped = state.swapped;
this.lastmove = state.lastmove;
this.boardSize = this.getBoardSize();
this.lastDaggerUse = [...state.lastDaggerUse];
return this;
Expand Down