import math


def h(state):
    """
    Admissible heuristic for single-player Chexers:
    In the best case, a piece can get to the edge of the board in 
    exit_dist // 2 jump actions (plus 1 move action when the distance is 
    odd), and then can exit with 1 action. Since all pieces must exit, we
    sum these best case individual distances from each piece.
    """
    hexes = state.piece_hexes
    dist  = state.board.exit_dist
    return sum(math.ceil(dist(qr) / 2) + 1 for qr in hexes)