from bot.strategy import next_move, VALID_MOVES, minmax_strategy, _minmax


def test_strategy1():
    #pylint: disable=C0301
    last_move = "00000000000000000000000007f96aa816c1f244cbc6ef114bb2b023ba54a2eb000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000020000000000000000000000001251659F5A4897bBebeB949E6Df22697d43C42dC000000000000000000000000A317E78f9F62Bc4959D0682F30043B9C0797C74F00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044364c5bb00000000000000000000000000000000000000000000000000000002d79883d2000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020"
    move = next_move(last_move)
    assert move in VALID_MOVES


def test_minmax_strategy_crosses_wins():
    #pylint: disable=C0301
    last_move = '00000000000000000000000007f96aa816c1f244cbc6ef114bb2b023ba54a2eb000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000020000000000000000000000001251659F5A4897bBebeB949E6Df22697d43C42dC000000000000000000000000A317E78f9F62Bc4959D0682F30043B9C0797C74F0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d79883d2000000000000000000000000000000000000000000000000000000044364c5bb000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000120'
    move = minmax_strategy(last_move, True)
    assert move == 4


def test_minmax_strategy_noughts_wins():
    noughts = 288
    crosses = 25

    move = _minmax(noughts, crosses, False, False, 0)[1]
    assert move == 4


def test_minmax_strategy_empty_board():
    noughts = 0
    crosses = 0

    move = _minmax(noughts, crosses, True, True, 0)[1]
    assert move == 1


def test_minmax_strategy_block_noughts():
    noughts = 9
    crosses = 272

    move = _minmax(noughts, crosses, True, True, 0)[1]
    assert move == 64


def test_minmax_strategy_block_crosses():
    noughts = 272
    crosses = 9

    move = _minmax(noughts, crosses, False, False, 0)[1]
    assert move == 64


def test_minmax_strategy_block_crosses2():
    noughts = 9
    crosses = 336

    move = _minmax(noughts, crosses, False, False, 0)[1]
    assert move == 2


def test_minmax_strategy_go_for_draw():
    noughts = 137
    crosses = 368

    move = _minmax(noughts, crosses, False, False, 0)[1]
    assert move == 4


def test_minmax_strategy_win_downstream():
    noughts = 17
    crosses = 132

    move = _minmax(noughts, crosses, True, True, 0)[1]
    assert move == 256
