Skip to content

Commit 3f02ff2

Browse files
committed
✨ GomokuBoard support for Ultimate
Tic Tac Toe double play
1 parent 937b515 commit 3f02ff2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/scala/com/truelaurel/samplegames/gomoku/GomokuBoard.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ case class GomokuBoard(
3434
def play(x: Int, y: Int): GomokuBoard = play(Pos(x, y))
3535

3636
def play(p: Pos): GomokuBoard =
37-
if (nextPlayer)
37+
forcePlay(p, nextPlayer)
38+
39+
def forcePlay(p: Pos, player: Boolean): GomokuBoard = {
40+
if (player)
3841
copy(
39-
nextPlayer = false,
42+
nextPlayer = !player,
4043
dataFree = dataFree - (p.x, p.y),
4144
dataTrue = dataTrue + (p.x, p.y))
4245
else
4346
copy(
44-
nextPlayer = true,
47+
nextPlayer = !player,
4548
dataFree = dataFree - (p.x, p.y),
4649
dataFalse = dataFalse + (p.x, p.y))
50+
}
4751

4852
def remove(p: Pos): GomokuBoard =
4953
copy(

0 commit comments

Comments
 (0)