from __future__ import annotations

import pytest

from lost_cities_jax import board_score
from reference import lost_cities_ref as ref
from tests.lost_cities_jax.helpers import hs, num, state_with_columns


@pytest.mark.parametrize(
    ("cards", "expected"),
    [
        ([num(0, 2), num(0, 3), num(0, 7), num(0, 8), num(0, 10)], 10),
        (
            [hs(0, 0), hs(0, 1), num(0, 4), num(0, 5), num(0, 6), num(0, 7), num(0, 8), num(0, 10)],
            80,
        ),
        ([hs(0), num(0, 4), num(0, 6), num(0, 7)], -6),
        ([hs(0)], -40),
        ([], 0),
        ([hs(0, 0), hs(0, 1), hs(0, 2), *[num(0, rank) for rank in range(2, 11)]], 156),
        ([hs(0, 0), hs(0, 1), hs(0, 2), num(0, 2)], -72),
    ],
)
def test_board_score_examples(cards, expected):
    state = state_with_columns([cards, [], [], [], []])
    assert float(board_score(state)[0]) == expected

    ref_state = ref.reset_from_order(list(range(60)))
    ref_state.board[0][0] = list(cards)
    assert ref.board_score(ref_state)[0] == expected
