Esempio n. 1
0
 /// <summary>
 /// Enumerates all the possible moves for a player
 /// </summary>
 /// <param name="ePlayerColor">             Color doing the the move</param>
 /// <param name="posInfo">                  Structure to fill with pieces information</param>
 public void ComputePiecesCoverage(PlayerColorE ePlayerColor, out PosInfoS posInfo)
 {
     EnumMoveList(ePlayerColor, false, out posInfo);
 }
Esempio n. 2
0
        /// <summary>
        /// Enumerates all the possible moves for a player
        /// </summary>
        /// <param name="ePlayerColor">             Color doing the the move</param>
        /// <param name="bMoveList">                true to returns a MoveList</param>
        /// <param name="posInfo">                  Structure to fill with pieces information</param>
        /// <returns>
        /// List of possible moves or null
        /// </returns>
        public List<MovePosS> EnumMoveList(PlayerColorE ePlayerColor, bool bMoveList, out PosInfoS posInfo)
        {
            PieceE          ePiece;
            List<MovePosS>  arrMovePos;
            bool            bBlackToMove;

            m_posInfo.m_iAttackedPieces   = 0;
            m_posInfo.m_iPiecesDefending  = 0;
            arrMovePos                    = (bMoveList) ? new List<MovePosS>(256) : null;
            bBlackToMove                  = (ePlayerColor == PlayerColorE.Black);
            for (int iIndex = 0; iIndex < 64; iIndex++) {
                ePiece = m_pBoard[iIndex];
                if (ePiece != PieceE.None && ((ePiece & PieceE.Black) != 0) == bBlackToMove) {
                    switch(ePiece & PieceE.PieceMask) {
                    case PieceE.Pawn:
                        EnumPawnMove(ePlayerColor, iIndex, arrMovePos);
                        break;
                    case PieceE.Knight:
                        EnumFromArray(ePlayerColor, iIndex, s_ppiCaseMoveKnight[iIndex], arrMovePos);
                        break;
                    case PieceE.Bishop:
                        EnumFromArray(ePlayerColor, iIndex, s_pppiCaseMoveDiagonal[iIndex], arrMovePos);
                        break;
                    case PieceE.Rook:
                        EnumFromArray(ePlayerColor, iIndex, s_pppiCaseMoveLine[iIndex], arrMovePos);
                        break;
                    case PieceE.Queen:
                        EnumFromArray(ePlayerColor, iIndex, s_pppiCaseMoveDiagLine[iIndex], arrMovePos);
                        break;
                    case PieceE.King:
                        EnumFromArray(ePlayerColor, iIndex, s_ppiCaseMoveKing[iIndex], arrMovePos);
                        break;
                    }
                }
            }
            EnumCastleMove(ePlayerColor, arrMovePos);
            EnumEnPassant(ePlayerColor, arrMovePos);
            posInfo = m_posInfo;
            return(arrMovePos);
        }
Esempio n. 3
0
        /// <summary>
        /// Evaluates a board. The number of point is greater than 0 if white is in advantage, less than 0 if black is.
        /// </summary>
        /// <param name="searchMode">       Search mode</param>
        /// <param name="ePlayerToPlay">    Color of the player to play</param>
        /// <param name="iDepth">           Depth of the search</param>
        /// <param name="iMoveCountDelta">  White move count - Black move count</param>
        /// <param name="posInfoWhite">     Information about pieces attack</param>
        /// <param name="posInfoBlack">     Information about pieces attack</param>
        /// <returns>
        /// Number of points for the current board
        /// </returns>
        public int Points(SearchEngine.SearchMode searchMode, PlayerColorE ePlayerToPlay, int iDepth, int iMoveCountDelta, PosInfoS posInfoWhite, PosInfoS posInfoBlack)
        {
            int                 iRetVal;
            IBoardEvaluation    boardEval;
            PosInfoS            posInfoTmp;

            if (ePlayerToPlay == PlayerColorE.White) {
                boardEval   = searchMode.m_boardEvaluationWhite;
                posInfoTmp  = posInfoWhite;
            } else {
                boardEval                       = searchMode.m_boardEvaluationBlack;
                posInfoTmp.m_iAttackedPieces    = -posInfoBlack.m_iAttackedPieces;
                posInfoTmp.m_iPiecesDefending   = -posInfoBlack.m_iPiecesDefending;
            }
            iRetVal   = boardEval.Points(m_pBoard, m_piPiecesCount, posInfoTmp, m_iWhiteKingPos, m_iBlackKingPos, m_bWhiteCastle, m_bBlackCastle, iMoveCountDelta);
            return(iRetVal);
        }