summaryrefslogtreecommitdiff
path: root/src/main/scala/me/robbyzambito/othello/game/Player.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/me/robbyzambito/othello/game/Player.scala')
-rw-r--r--src/main/scala/me/robbyzambito/othello/game/Player.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/scala/me/robbyzambito/othello/game/Player.scala b/src/main/scala/me/robbyzambito/othello/game/Player.scala
index 925f7d2..c55f6db 100644
--- a/src/main/scala/me/robbyzambito/othello/game/Player.scala
+++ b/src/main/scala/me/robbyzambito/othello/game/Player.scala
@@ -13,6 +13,15 @@ import scala.util.Try
* @param color The color of the player.
*/
abstract class Player(val color: Position) {
+
+ /**
+ * The players decision on where to move based on
+ * the current board. It is assumed that there is
+ * at least one valid move.
+ *
+ * @param board
+ * @return
+ */
def nextMove(board: Board): Move
def canMove(board: Board): Boolean =
@@ -85,7 +94,8 @@ abstract class Player(val color: Position) {
Some(
Move(rowCount,
colCount,
- acc.map(_.takenPositions).getOrElse(List.empty) ::: vert.map(_.takenPositions).getOrElse(List.empty))
+ (acc.map(_.takenPositions).getOrElse(List.empty) :::
+ vert.map(_.takenPositions).getOrElse(List.empty)).distinct)
)
else None
}).flatten