Example #1
0
        void NextMove(GameAIAbstract gameAI, TicTacToeSign sign)
        {
            int row;
            int column;

            stopWatch.Restart();

            if (gameAI.GetNextMove(sign, out row, out column))
            {
                stopWatch.Stop();

                TextBlockAITime.Text = stopWatch.ElapsedMilliseconds.ToString() + " ms";

                if (gameAI is IGameAIMinimax)
                {
                    TextBlockAISteps.Text = gameAI.Steps.ToString();

                    int    bestResult = (gameAI as IGameAIMinimax).GetBestResult();
                    string bestText;

                    switch (bestResult)
                    {
                    case -1:
                        bestText = "A gépi játékos veszíteni fog";
                        break;

                    case 0:
                        bestText = "A gépi játékos döntetlent ér el";
                        break;

                    case 1:
                        bestText = "A gépi játékos győzni fog";
                        break;

                    default:
                        bestText = "???";
                        break;
                    }

                    TextBlockAIBestResult.Text = bestText;
                }

                playingBoard.SetSign(row, column, sign);
                gameBoard.SetSign(row, column, sign);

                TicTacToeResult winner = gameBoard.Winner();

                if (winner != TicTacToeResult.None)
                {
                    AnnounceWinner(winner);
                }
            }
            else
            {
                MessageBox.Show("Nincs következő lépés...");
            }
        }
Example #2
0
 private void SetGameAIO()
 {
     foreach (RadioButtonAI item in StackPanelAIO.Children)
     {
         if (item.IsChecked == true)
         {
             gameAIO = GameAIFactory.GetGameAI(item.AIType, gameBoard);
             break;
         }
     }
 }