Example #1
0
        static float CalculateValue(Piece pc)
        {
            int value = 0;
            int possibleMovesCount = pc.CheckMoves ().Count;
            int alliesCount = pc.Occupies.Adjacent.Count (square => square.ContainsPiece () && square.ContainedPiece ().Owner == pc.Owner);

            Coords position = pc.Occupies.Pos;
            if (
            (position.x == 4 || position.x == 5) &&
            (position.y == 2 || position.y == 3))
            {
            if (pc.Type == PieceType.ROUND)
            {
                value = 20;
            }
            else
            {
                value = 10;
            }
            }
            else if (pc.Occupies.Adjacent.Find (tile => tile.Type == BoardSquareType.EDGE) != null)
            {
            if (pc.Push.AmIAnchored ())
            {
                value = -5;
            }
            else if (possibleMovesCount == 0 && pc.Push.CheckPushes ().Count == 0)
            {
                value = -50;
            }
            else
            {
                value = -20;
            }
            }
            else
            {
            value = 0;
            }

            value += possibleMovesCount * 1;
            value += alliesCount * 3;

            return value;
        }