Пример #1
0
        //////////
        //// HANDLERS FOR BOARD, PIECES, LOGIC AND HIGHLIGHTING LOCATED BELOW HERE
        //////////
        public static void MakeMove(int boardX, int boardY)
        {
            if (wait_for_timer || !player_turn || wait_for_computer || !canMove())
            {
                return;
            }
            if (MainPage.game_state == GameState.OUT_OF_GAME || MainPage.game_state == GameState.END_GAME || (checkerX == -1 && checkerY == -1))
            {
                return;
            }

            if (game_type == GameState.SINGLE_PLAYER)
            {
                player_turn = false;
            }
            wait_for_timer = true;
            Move m;

            try
            {
                PieceColor whoseTurn = logic.whoseMove();
                int        locX      = checkerX;
                int        locY      = checkerY;
                // Unhighlight the selected piece
                handleHighlighting(checkerX, checkerY);
                m = logic.makeMove(locY, locX, boardY, boardX);

                handleMove(m);
                if (whoseTurn.Equals(logic.whoseMove()))
                {
                    checkerX   = boardX;
                    checkerY   = boardY;
                    multi_jump = true;
                }

                TURN_TIMER.Start();
            }
            catch (PlayerMustJumpException)
            {
                MessageBox.Show("You must take an available jump!");
                wait_for_timer = false;
                player_turn    = true;
            }
            catch (WrongMultiJumpPieceException)
            {
                MessageBox.Show("You must finish the multijump!");
                wait_for_timer = false;
                player_turn    = true;
            }
            catch (InvalidMoveException)
            {
                System.Diagnostics.Debug.WriteLine("invalid move");
                wait_for_timer = false;
                player_turn    = true;
            }
        }
Пример #2
0
 private static double getOptimizedHeuristic(int depth, int maxDepth, GameLogic g)
 {
     if (depth == maxDepth || g.getGameStatus() != GameStatus.NOWINNER)
     {
         return(g.calculateHeuristic());
     }
     else
     {
         PieceColor                 currentPlayer = g.whoseMove();
         List <MoveAttempt>         starting      = g.getAllDoableMoveJumpAttempts();
         List <List <MoveAttempt> > poss          = new List <List <MoveAttempt> >();
         foreach (MoveAttempt possibility in starting)
         {
             List <MoveAttempt> p = new List <MoveAttempt>();
             p.Add(possibility);
             foreach (List <MoveAttempt> fullturn in getFullTurns(p, new GameLogic(g)))
             {
                 poss.Add(fullturn);
             }
         }
         System.Diagnostics.Debug.WriteLine("starting length: " + starting.Count + ". poss length: " + poss.Count);
     }
     return(.345);
 }
Пример #3
0
        private static double getOptimizedHeuristic(int depth, int maxDepth, GameLogic g)
        {
            if (depth == maxDepth || g.getGameStatus() != GameStatus.NOWINNER) {
                return g.calculateHeuristic();
            } else {
                PieceColor currentPlayer = g.whoseMove();
                List<MoveAttempt> starting = g.getAllDoableMoveJumpAttempts();
                List<List<MoveAttempt>> poss = new List<List<MoveAttempt>>();
                foreach (MoveAttempt possibility in starting) {
                    List<MoveAttempt> p = new List<MoveAttempt>();
                    p.Add(possibility);
                    foreach(List<MoveAttempt> fullturn in getFullTurns(p, new GameLogic(g))) {
                        poss.Add(fullturn);
                    }
                }
                System.Diagnostics.Debug.WriteLine("starting length: " + starting.Count + ". poss length: " + poss.Count);

            }
            return .345;
        }