예제 #1
0
        private static List <Search.Position> EvaluateMovesQ(Board examineBoard)
        {
            List <Search.Position> positionList = new List <Search.Position>();

            for (byte index = 0; (int)index < 64; ++index)
            {
                Piece piece1 = examineBoard.Squares[(int)index].Piece;
                if (piece1 != null && piece1.PieceColor == examineBoard.WhoseMove)
                {
                    foreach (byte validMove in piece1.ValidMoves)
                    {
                        if (examineBoard.Squares[(int)validMove].Piece != null)
                        {
                            Search.Position position = new Search.Position();
                            position.SrcPosition = index;
                            position.DstPosition = validMove;
                            if ((int)position.SrcPosition == (int)Search.KillerMove[2, 0].SrcPosition && (int)position.DstPosition == (int)Search.KillerMove[2, 0].DstPosition)
                            {
                                position.Score += 5000;
                                positionList.Add(position);
                            }
                            else
                            {
                                Piece piece2 = examineBoard.Squares[(int)position.DstPosition].Piece;
                                position.Score += (int)piece2.PieceValue;
                                if ((int)piece1.PieceValue < (int)piece2.PieceValue)
                                {
                                    position.Score += (int)piece2.PieceValue - (int)piece1.PieceValue;
                                }
                                position.Score += (int)piece1.PieceActionValue;
                                positionList.Add(position);
                            }
                        }
                    }
                }
            }
            return(positionList);
        }
예제 #2
0
        private static List <Search.Position> EvaluateMoves(Board examineBoard, byte depth)
        {
            List <Search.Position> positionList = new List <Search.Position>();

            for (byte index = 0; (int)index < 64; ++index)
            {
                Piece piece1 = examineBoard.Squares[(int)index].Piece;
                if (piece1 != null && piece1.PieceColor == examineBoard.WhoseMove)
                {
                    foreach (byte validMove in piece1.ValidMoves)
                    {
                        Search.Position position = new Search.Position();
                        position.SrcPosition = index;
                        position.DstPosition = validMove;
                        if ((int)position.SrcPosition == (int)Search.KillerMove[0, (int)depth].SrcPosition && (int)position.DstPosition == (int)Search.KillerMove[0, (int)depth].DstPosition)
                        {
                            position.Score += 5000;
                            positionList.Add(position);
                        }
                        else if ((int)position.SrcPosition == (int)Search.KillerMove[1, (int)depth].SrcPosition && (int)position.DstPosition == (int)Search.KillerMove[1, (int)depth].DstPosition)
                        {
                            position.Score += 5000;
                            positionList.Add(position);
                        }
                        else
                        {
                            Piece piece2 = examineBoard.Squares[(int)position.DstPosition].Piece;
                            if (piece2 != null)
                            {
                                position.Score += (int)piece2.PieceValue;
                                if ((int)piece1.PieceValue < (int)piece2.PieceValue)
                                {
                                    position.Score += (int)piece2.PieceValue - (int)piece1.PieceValue;
                                }
                            }
                            if (!piece1.Moved)
                            {
                                position.Score += 10;
                            }
                            position.Score += (int)piece1.PieceActionValue;
                            if (!examineBoard.WhiteCastled && examineBoard.WhoseMove == ChessPieceColor.White)
                            {
                                if (piece1.PieceType == ChessPieceType.King)
                                {
                                    if ((int)position.DstPosition != 62 && (int)position.DstPosition != 58)
                                    {
                                        position.Score -= 40;
                                    }
                                    else
                                    {
                                        position.Score += 40;
                                    }
                                }
                                if (piece1.PieceType == ChessPieceType.Rook)
                                {
                                    position.Score -= 40;
                                }
                            }
                            if (!examineBoard.BlackCastled && examineBoard.WhoseMove == ChessPieceColor.Black)
                            {
                                if (piece1.PieceType == ChessPieceType.King)
                                {
                                    if ((int)position.DstPosition != 6 && (int)position.DstPosition != 2)
                                    {
                                        position.Score -= 40;
                                    }
                                    else
                                    {
                                        position.Score += 40;
                                    }
                                }
                                if (piece1.PieceType == ChessPieceType.Rook)
                                {
                                    position.Score -= 40;
                                }
                            }
                            positionList.Add(position);
                        }
                    }
                }
            }
            return(positionList);
        }
예제 #3
0
 private static int Sort(Search.Position s2, Search.Position s1)
 {
     return(s1.Score.CompareTo(s2.Score));
 }