Esempio n. 1
0
        private static void CheckForComputerMoves()
        {
            bool aiCanMove = true; // Used to prevent moving twice in 1 turn

            while (ai == null && T1.IsAlive)
            {
            }
            while (ai != null && T1.IsAlive)
            {
                if (game.Winner == null && game.SettingsSecondPlayer.Equals("AI") && game.Turn.Equals("O"))
                {
                    ai.SelectMove();
                    aiCanMove = false;
                }
                else if (game.Winner == null && game.SettingsSecondPlayer.Equals("AI") && game.Turn.Equals("X"))
                {
                    aiCanMove = true;
                }
                else if (game.Winner != null && game.GameEndedStats == true)
                {
                    int gameResult = 0;
                    if (game.Winner == "X")
                    {
                        gameResult = 2;
                    }
                    else if (game.Winner == "draw")
                    {
                        gameResult = 1;
                    }

                    gameStates.CalculateMoveScore(game, gameResult);
                    gameStates.PrintMoveScores();
                    gameStates.gamePlayedStates.Clear();
                    game.GameEndedStats = false;
                }

                Thread.Sleep(1000);
            }
        }