示例#1
0
        public void Initialize()
        {
            ServiceProviderMock = new Mock <IServiceProvider>();
            GameMock            = new Mock <IGame>();

            TicTacToeFactory = new TicTacToeFactory(ServiceProviderMock.Object);
        }
示例#2
0
 private void InitializeTicTacToeGame()
 {
     this.ticTacToeGame            = TicTacToeFactory.Create(Team.Zero);
     ticTacToeGame.ScoreChanged   += OnScoreChanged;
     ticTacToeGame.TeamAndLineWon += OnTeamAndLineWon;
     ticTacToeGame.TeamChanged    += OnTeamChanged;
 }
示例#3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var ticTacToe  = TicTacToeFactory.Create(Team.Zero);
            var mainWindow = new MainWindow(ticTacToe);

            mainWindow.ShowDialog();
        }
示例#4
0
        public void WhenIStartANewGameWithTheFollowingMoves(string movesString)
        {
            Invoke(() =>
            {
                var moves = ToMoves(movesString);

                Game = TicTacToeFactory.NewGame(moves);
            });
        }
示例#5
0
        public void GivenIStartANewGameWithTheFollowingMoves(Table table)
        {
            Invoke(() =>
            {
                var moves = ToMoves(table);

                Game = TicTacToeFactory.NewGame(moves);
            });
        }
示例#6
0
        private static void PlayTicTacToe()
        {
            TicTacToeFactory factory = new TicTacToeFactory();

            IGameLogic logic = factory.CreateLogic();

            MiniMaxAlgorithm alg = new MiniMaxAlgorithm(5, factory);

            IGameState state = new TicTacToeState();

            while (true)
            {
                IGameMove move = alg.FindBestMove(state, GamePlayer.PlayerMax);

                if (null != move)
                {
                    state = logic.MakeMove(move, state);
                }
                else
                {
                    break;
                }

                PrintState((TicTacToeState)state);

                if (logic.IsFinished(state))
                {
                    break;
                }

                Int32 x = Int32.Parse(Console.ReadLine());
                Int32 y = Int32.Parse(Console.ReadLine());

                state = logic.MakeMove(new TicTacToeMove
                {
                    X      = x,
                    Y      = y,
                    Symbol = TicTacToeFieldState.Circle
                }, state);

                if (logic.IsFinished(state))
                {
                    break;
                }
            }

            PrintState((TicTacToeState)state);
        }
示例#7
0
 public static MatchState CreateNewMatch(GameType matchType, Guid firstPlayerId)
 {
     return(new MatchState
     {
         id = Guid.NewGuid(),
         gameType = matchType,
         operationState = GameOperationState.WaitingForPlayers,
         gameStartTime = DateTime.Now,
         playerTurnId = firstPlayerId,
         players = new List <Guid>
         {
             firstPlayerId,
         },
         inGameState = TicTacToeFactory.CreateNewTicTacToe(firstPlayerId)
     });
 }
示例#8
0
 public MainWindow() : this(TicTacToeFactory.Create(Team.Zero))
 {
 }
示例#9
0
 public void GivenIHaveADatabaseBuilder()
 {
     Invoke(() => DatabaseBuilder = TicTacToeFactory.NewDatabaseBuilder());
 }
示例#10
0
 public void GivenIStartANewGameInTheFollowingState(Table table)
 {
     Invoke(() => Game = TicTacToeFactory.NewGame(ToPlausibleMoveListFromBoardState(table)));
 }
示例#11
0
 public void GivenIStartANewGame()
 {
     Invoke(() => Game = TicTacToeFactory.NewGame());
 }
示例#12
0
 public void GivenIHaveTheArtificialIntelligence(string ai)
 {
     ArtificialIntelligence = TicTacToeFactory.NewArtificialIntelligence(ai);
 }