Exemple #1
0
        private void computerPlayerWork(object sender, DoWorkEventArgs e)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                MyButton.clientWindow.menuBar.IsEnabled             = false;
                MyButton.clientWindow.showAllowMoveButton.IsEnabled = false;
                MyButton.clientWindow.showBestMoveButton.IsEnabled  = false;
            }));

            if (!game.isPlayerTurn())
            {
                game.getCountdownTimer().Stop();
                game.getCountdownTimer().Start(game.getMoveTime());
            }

            MoveScenarios bestScenario =
                ClientWindow.serverService.GetBestMove(game.getBoard(), game.getMaxDepth(), game.getMoveTime());

            if (game.isPlayerTurn())
            {
                showBestMove(bestScenario);
                execCompMove = false;
            }
            else
            {
                game.getCountdownTimer().Stop();

                MyButton.game.execMove(bestScenario);
                execCompMove = true;
            }
        }
Exemple #2
0
        private void showBestMove(MoveScenarios bestScenario)
        {
            if (bestScenario != null)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    Position fromPos = bestScenario.getFromPosition();
                    MyButton.buttonsArray[fromPos.Row, fromPos.Col].Background = hoverColor;

                    foreach (Position pos in bestScenario.getScenario(0))
                    {
                        MyButton.buttonsArray[pos.Row, pos.Col].Background = hoverColor;
                    }
                }));

                shownHint = true;
            }
        }