Created
October 29, 2020 06:02
-
-
Save khajavi/c3ba09e145389969097f67941abb9c91 to your computer and use it in GitHub Desktop.
Revisions
-
khajavi created this gist
Oct 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ object TicTocToe { sealed trait Action object Action { case object X extends Action case object O extends Action } sealed trait Player object Player { case object X extends Player case object O extends Player } sealed trait State object State { case object NotStarted extends State case object Playing extends State case object Finished extends State } type Board = Array[Array[Action]] case class Game[S <: State](state: S, board: Board) type Cell = (Int, Int) trait PlayGround { /** * Who is the winner? */ def winner[S <: State.Finished.type](game: Game[S]): Player /** * Who is the next player? */ def nextPlayer(board: Board): Player //FIXME: who start the game? //FIXME: pick shouldn't work on Finished state def pick[S](game: Game[S]): Cell } }