Beispiel #1
0
def test_chain(zero_field, kenny):
    field = upi.Field()
    field.init_from_pfen(kenny)
    chain_num, score = field.chain()
    assert np.array_equal(field.field, zero_field)
    assert chain_num == 19
    assert score == 175080
Beispiel #2
0
def test_chain_samecoloronly(zero_field):
    field = upi.Field()
    field.init_from_pfen('rrrrrrrrrrrr/rrrrrrrrrrrr/rrrrrrrrrrrr/rrrrrrrrrrrr/rrrrrrrrrrrr/rrrrrrrrrrrr/')
    chain_num, score = field.chain()
    assert np.array_equal(field.field, zero_field)
    assert chain_num == 1
    assert score == 7200
Beispiel #3
0
def test_chain_ojamaonly():
    field = upi.Field()
    field.init_from_pfen('oooo//////')
    clone = field.field.copy()
    chain_num, score = field.chain()
    assert np.array_equal(field.field, clone)
    assert chain_num == 0
    assert score == 0
Beispiel #4
0
def test_init_from_pfen_continuous(zero_field):
    field = upi.Field()
    pfen = 'ry//////'
    answer = zero_field.copy()
    answer[0, 0] = upi.Puyo.RED
    answer[0, 1] = upi.Puyo.YELLOW
    field.init_from_pfen(pfen)
    assert np.array_equal(field.field, answer)
    pfen = '//////'
    field.init_from_pfen(pfen)
    assert np.array_equal(field.field, zero_field)
Beispiel #5
0
def test_position():
    upi_player = upi.UpiPlayer()
    cmd = ['ryrb//////', '2', '//////', '3', '-1', '4', '250']
    upi_player.position(cmd)
    field = upi.Field()
    field.init_from_pfen(cmd[0])
    assert np.array_equal(upi_player.positions[0].field.field, field.field)
    assert upi_player.positions[0].tumo_index == int(cmd[1])
    field.init_from_pfen(cmd[2])
    assert np.array_equal(upi_player.positions[1].field.field, field.field)
    assert upi_player.positions[1].tumo_index == int(cmd[3])
    assert upi_player.common_info.future_ojama.fixed_ojama == int(cmd[4])
    assert upi_player.common_info.future_ojama.unfixed_ojama == int(cmd[5])
    assert upi_player.common_info.future_ojama.time_until_fall_ojama == int(
        cmd[6])
Beispiel #6
0
def test_pretty(kenny):
    field = upi.Field()
    field.init_from_pfen(kenny)
    pretty_string = field.pretty()
    answer = 'eeypgg\r\n------\r\nybbypb\r\npbypgg\r\nybypgb\r\npgbypb\r\ngbypgb\r\npgbypg\r\npgbypg\r\npyybyb\r\nygbpbb\r\npygbpy\r\npygbpy\r\npygbpy'
    assert pretty_string == answer
Beispiel #7
0
def test_is_death(kenny):
    field = upi.Field()
    field.init_from_pfen('//////')
    assert not field.is_death()
    field.init_from_pfen(kenny)
    assert field.is_death()
Beispiel #8
0
def test_field(zero_field):
    field = upi.Field()
    assert field.X_MAX == 6
    assert field.Y_MAX == 13
    assert np.array_equal(field.field, zero_field)
Beispiel #9
0
def compare_pfen(pfen, answer):
    field = upi.Field()
    field.init_from_pfen(pfen)
    return np.array_equal(field.field, answer)
Beispiel #10
0
def test_floors2():
    field = upi.Field()
    pfen = 'rpyrbppyrrbby/yprbryb/////'
    field.init_from_pfen(pfen)
    floors = field.floors()
    assert floors == [13, 7, 0, 0, 0, 0]
Beispiel #11
0
def test_floors():
    field = upi.Field()
    pfen = 'ry//////'
    field.init_from_pfen(pfen)
    floors = field.floors()
    assert floors == [2, 0, 0, 0, 0, 0]