def test_reverse_box_on_storage():
    state = State(*list(level_reverse_box_on_storage.values()))
    previous_states = state.prev_states()
    previous_states = {state.__str__() for state in previous_states}
    assert previous_states == {'#####\n#   #\n#  $#\n# p #\n#####\n',
                               '#####\n#   #\n#p $#\n#   #\n#####\n',
                               '#####\n# p #\n#  $#\n#   #\n#####\n',
                               '#####\n#   #\n#pBS#\n#   #\n#####\n'}
def test_reverse_box():
    state = State(*list(level_reverse_box.values()))
    previous_states = state.prev_states()
    previous_states = {state.__str__() for state in previous_states}
    assert previous_states == {'#####\n# p #\n#  B#\n#  S#\n#####\n',
                               '#####\n#   #\n#p B#\n#  S#\n#####\n',
                               '#####\n#   #\n#pB #\n#  S#\n#####\n',
                               '#####\n#   #\n#  B#\n# pS#\n#####\n'}
def test_level_ok_prints_right():
    state = State(*list(level_ok.values()))
    out = state.__str__()
    lev = '######\n#p   #\n# $  #\n#  BS#\n# BS #\n######\n'

    assert lev == out
Beispiel #4
0
level_easiest = {
    'width':
    8,
    'height':
    8,
    'player': (1, 1),
    'boxes': [(2, 3)],
    'storages': [(2, 6)],
    'walls':
    set([(0, i) for i in range(8)] + [(7, i) for i in range(8)] +
        [(i, 0) for i in range(8)] + [(i, 7) for i in range(8)])
}

start_state = State(*list(level_easiest.values()))
print(start_state.__str__())
ForwardSolvers.deep_q_learning(start_state, 1000, 15, (.25, .05), .95)

level_easy = {
    'width':
    8,
    'height':
    8,
    'player': (1, 1),
    'boxes': [(2, 2)],
    'storages': [(2, 3)],
    'walls':
    set([(0, i) for i in range(8)] + [(7, i) for i in range(8)] +
        [(i, 0) for i in range(8)] + [(i, 7) for i in range(8)])
}