コード例 #1
0
        private bool isLegalMove(Player i_Player, Move i_Move)
        {
            bool moveIsLegal;

            List <Move> possibleEatingMoves    = i_Player.PossibleEatingMoves(m_GameBoard);
            List <Move> possibleNonEatingMoves = i_Player.PossibleNonEatingMoves(m_GameBoard);

            if (possibleEatingMoves.Count > 0)
            {
                moveIsLegal = isMoveInList(possibleEatingMoves, i_Move);
            }
            else if (possibleNonEatingMoves.Count > 0)
            {
                moveIsLegal = isMoveInList(possibleNonEatingMoves, i_Move);
            }
            else
            {
                moveIsLegal = false;
            }

            if (!moveIsLegal)
            {
                if (i_Move.Source != i_Move.Destination)
                {
                    MessageBox.Show(@"Invalid move!");
                }
            }

            return(moveIsLegal);
        }
コード例 #2
0
        private Point destinationInEatingSerie(Player i_Player, Point i_LocationOfCurrentEatingPawn)
        {
            List <Move> possibleEatingMoves = i_Player.PossibleEatingMoves(m_GameBoard);

            Point newDestinationInEatingSerie = new Point();

            foreach (Move eatingMove in possibleEatingMoves)
            {
                if (eatingMove.Source == i_LocationOfCurrentEatingPawn)
                {
                    newDestinationInEatingSerie = eatingMove.Destination;
                    break;
                }
            }

            return(newDestinationInEatingSerie);
        }
コード例 #3
0
        private Move choosePcMove(Player i_Player)
        {
            List <Move> possibleEatingMoves    = i_Player.PossibleEatingMoves(m_GameBoard);
            List <Move> possibleNonEatingMoves = i_Player.PossibleNonEatingMoves(m_GameBoard);
            Move        pcMove;
            int         indexInList;

            if (possibleEatingMoves.Count > 0)
            {
                indexInList = r_RandomGenerator.Next(possibleEatingMoves.Count);
                pcMove      = possibleEatingMoves[indexInList];
            }
            else if (possibleNonEatingMoves.Count > 0)
            {
                indexInList = r_RandomGenerator.Next(possibleNonEatingMoves.Count);
                pcMove      = possibleNonEatingMoves[indexInList];
            }
            else
            {
                pcMove = new Move();
            }

            return(pcMove);
        }
コード例 #4
0
 private bool noMoveLeft(Player i_Player)
 {
     return(!i_Player.PossibleEatingMoves(m_GameBoard).Any() && !i_Player.PossibleNonEatingMoves(m_GameBoard).Any());
 }