Beispiel #1
0
def test_strategy3():
    move1 = next_move(0, None, ADDRESSES[2])
    move2 = next_move(0, move1, ADDRESSES[2])
    assert move2 == (move1 + 1) % 3

    move3 = next_move(0, move2, ADDRESSES[2])
    assert move3 == (move2 + 1) % 3
Beispiel #2
0
def test_strategy2():
    move = next_move(None, 0, ADDRESSES[1])
    assert move == 0

    move = next_move(move, 0, ADDRESSES[1])
    assert move == 1

    move = next_move(move, 0, ADDRESSES[1])
    assert move == 2
Beispiel #3
0
def test_strategy4(mocker):
    #pylint: disable=C0301
    hex_message1 = '000000000000000000000000A1796Db2b57144a2C21A92AE647B86B9641A47ac00000000000000000000000000000000000000000000000000000000000001c8000000000000000000000000000000000000000000000000000000000000000200000000000000000000000035a2119712091a77B40FaB61ecabc8fBE950eb1600000000000000000000000055de2e479F3D0183D95f5A969bEEB3a147F6004900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000038d7ea4c680002f29e990b57b3c5621748e5dfb3cf7c098f0a3db21c5aa444bb8685f7042a29c'
    move = next_move(None, None, ADDRESSES[3], hex_message=hex_message1)
    assert move == 2

    mocker.patch('requests.post')
    hex_message2 = '000000000000000000000000A1796Db2b57144a2C21A92AE647B86B9641A47ac00000000000000000000000000000000000000000000000000000000000001c8000000000000000000000000000000000000000000000000000000000000000200000000000000000000000035a2119712091a77B40FaB61ecabc8fBE950eb1600000000000000000000000055de2e479F3D0183D95f5A969bEEB3a147F6004900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000038d7ea4c680002f29e990b57b3c5621748e5dfb3cf7c098f0a3db21c5aa444bb8685f7042a29d'
    move = next_move(None, None, ADDRESSES[3], hex_message=hex_message2)
    assert move == 0
Beispiel #4
0
def play_move(hex_message):
    bot_addr = g.bot_addr
    last_opponent_move = wallet.get_last_opponent_move(hex_message, bot_addr)
    last_bot_move = wallet.get_last_bot_move(hex_message, bot_addr)
    move = strategy.next_move(last_bot_move, last_opponent_move, bot_addr, hex_message=hex_message)
    wallet.set_last_bot_move(hex_message, move, bot_addr)
    return coder.update_move(hex_message, move)
Beispiel #5
0
def get_move(hex_message, mover):
    random_move = strategy.next_move(hex_message)
    smart_move = strategy.minmax_strategy(hex_message, mover)

    choice = random.random()
    if choice > 0.6:
        print("Playing random move")
        return random_move
    print("Playing minimax move")
    return smart_move
Beispiel #6
0
def test_strategy1():
    #pylint: disable=C0301
    last_move = "00000000000000000000000007f96aa816c1f244cbc6ef114bb2b023ba54a2eb000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000020000000000000000000000001251659F5A4897bBebeB949E6Df22697d43C42dC000000000000000000000000A317E78f9F62Bc4959D0682F30043B9C0797C74F00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044364c5bb00000000000000000000000000000000000000000000000000000002d79883d2000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000b5e620f4800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020"
    move = next_move(last_move)
    assert move in VALID_MOVES
Beispiel #7
0
def test_strategy1():
    move = next_move(0, 0, ADDRESSES[0])
    assert move == 0

    move = next_move(0, 0, ADDRESSES[0])
    assert move == 0