コード例 #1
0
        internal void PlayTurn()
        {
            int originRowIndex = m_CurrentMove.Origin.Coordinates.RowIndex;
            int originColIndex = m_CurrentMove.Origin.Coordinates.ColIndex;
            int destRowIndex   = m_CurrentMove.Destination.Coordinates.RowIndex;
            int destColIndex   = m_CurrentMove.Destination.Coordinates.ColIndex;

            Board.BoardSquare origin      = m_Board.getBoardSquare(originRowIndex, originColIndex);
            Board.BoardSquare destination = m_Board.getBoardSquare(destColIndex, destRowIndex);
            m_Board.setBoardSquare(originRowIndex, originColIndex, eShape.Blank, ePlayerColor.Blank);

            if (m_CurPlayer.Color == ePlayerColor.White && destRowIndex == 0)
            {
                m_Board.setBoardSquare(destRowIndex, destColIndex, eShape.WhiteKing, m_CurPlayer.Color);
            }
            else if (m_CurPlayer.Color == ePlayerColor.Black && destRowIndex == m_Board.Size - 1)
            {
                m_Board.setBoardSquare(destRowIndex, destColIndex, eShape.BlackKing, m_CurPlayer.Color);
            }
            else
            {
                m_Board.setBoardSquare(destRowIndex, destColIndex, origin.GetShape, m_CurPlayer.Color);
            }

            if (m_CurrentMove.IsEatMove)
            {
                int toEatRowIndex = (originRowIndex > destRowIndex) ? (originRowIndex - 1) : (originRowIndex + 1);
                int toEatColIndex = (originColIndex > destColIndex) ? (originColIndex - 1) : (originColIndex + 1);
                m_Board.setBoardSquare(toEatRowIndex, toEatColIndex, eShape.Blank, ePlayerColor.Blank);
                m_JustAte = true;
                CheckForExtraEat(m_Board.getBoardSquare(destRowIndex, destColIndex));
            }
        }
コード例 #2
0
        private Move GetMoveFromString(string i_UserInput)
        {
            string origin = i_UserInput.Substring(0, 2);
            string dest   = i_UserInput.Substring(3);

            Board.BoardSquare originSquare = m_Board.getBoardSquare(origin[1] - 'a', origin[0] - 'A');
            Board.BoardSquare destSquare   = m_Board.getBoardSquare(dest[1] - 'a', dest[0] - 'A');
            return(new Move(originSquare, destSquare, false));
        }
コード例 #3
0
        private void CheckForExtraEat(Board.BoardSquare i_Origin)
        {
            List <Move> legalMoves = SquareLegalMove(i_Origin);

            legalMoves = UpdateEdibleMoves(legalMoves);
            if (legalMoves.Count > 0)
            {
                m_SwitchTurn = false;
                m_LegalMoves = legalMoves;
            }
            else
            {
                m_SwitchTurn = true;
            }
        }
コード例 #4
0
        private List <Move> SquareLegalMove(Board.BoardSquare i_BoardSquare)
        {
            List <Move> output          = new List <Move>();
            Location    currentLocation = i_BoardSquare.Coordinates;
            int         colIndex        = currentLocation.ColIndex;
            int         rowIndex        = currentLocation.RowIndex;

            switch (i_BoardSquare.GetShape)
            {
            case eShape.White:
                // Checks available right upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.Black) ||
                             (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex + 2, m_Board.Size) &&
                            (m_Board.getBoardSquare(rowIndex - 2, colIndex + 2).GetShape == eShape.Blank))
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.Black) || (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex - 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex - 2), true));
                        }
                    }
                }

                break;

            case eShape.WhiteKing:
                // Checks available right upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.Black) || (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex + 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex - 2, colIndex + 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.Black) || (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex - 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex - 2), true));
                        }
                    }
                }

                // Checks available right downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.Black) || (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex + 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex + 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.Black) || (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.BlackKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex - 2), true));
                        }
                    }
                }

                break;

            case eShape.Black:
                // Checks available right downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex + 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex + 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex - 2), true));
                        }
                    }
                }

                break;

            case eShape.BlackKing:
                // Checks available right upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex - 1, colIndex + 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex + 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex - 2, colIndex + 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left upwards move
                if (CheckBoundaries(rowIndex - 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex - 1, colIndex - 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex - 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex - 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex - 2, colIndex - 2), true));
                        }
                    }
                }

                // Checks available right downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex + 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex + 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex + 1, colIndex + 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex + 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex + 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex + 2), true));
                        }
                    }
                }

                // Checks available left downwards move
                if (CheckBoundaries(rowIndex + 1, colIndex - 1, m_Board.Size))
                {
                    if (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.Blank)
                    {
                        output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 1, colIndex - 1), false));
                    }
                    else if ((m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.White) || (m_Board.getBoardSquare(rowIndex + 1, colIndex - 1).GetShape == eShape.WhiteKing))
                    {
                        if (CheckBoundaries(rowIndex + 2, colIndex - 2, m_Board.Size) && m_Board.getBoardSquare(rowIndex + 2, colIndex - 2).GetShape == eShape.Blank)
                        {
                            output.Add(new Move(m_Board.getBoardSquare(rowIndex, colIndex), m_Board.getBoardSquare(rowIndex + 2, colIndex - 2), true));
                        }
                    }
                }

                break;
            }

            return(output);
        }
コード例 #5
0
 internal Move(Board.BoardSquare i_Origin, Board.BoardSquare i_Dest, bool i_IsEatMove)
 {
     m_IsEatMove = i_IsEatMove;
     m_Origin    = i_Origin;
     m_Dest      = i_Dest;
 }