import chess
import math

def h_shannon(board: chess.Board, color: chess.Color):
    piece_values = {
        chess.PAWN: 1,
        chess.KNIGHT: 3,
        chess.BISHOP: 3,
        chess.ROOK: 5,
        chess.QUEEN: 9,
        chess.KING: 0
    }
    acc = 0

    outcome = board.outcome()
    if board.is_checkmate() and outcome is not None:
        winner = outcome.winner
        return math.inf if winner is not None and winner == color else -math.inf

    if board.is_game_over():
        return 0

    for square in board.piece_map():
        piece = board.piece_at(square)

        if piece is not None:
            n = 1 if piece.color == color else -1
            acc += n * piece_values[piece.piece_type]

    return acc
