Esempio n. 1
0
 def it_accepts_blank_input_as_empty_forward_snapshot(self, parser):
     success = parser.convert(
         "  \n   \t  ", tessellation_factory("Sokoban")
     )
     assert success
     assert parser._resulting_solving_mode == 'forward'
     assert parser._resulting_moves == []
Esempio n. 2
0
 def it_ignores_spaces_and_current_position_character(self, parser):
     success = parser.convert(
         "  \n **  \t l ", tessellation_factory("Sokoban")
     )
     assert success
     assert parser._resulting_solving_mode == 'forward'
     assert parser._resulting_moves == [AtomicMove(Direction.LEFT)]
Esempio n. 3
0
 def it_appends_converted_moves_to_parser_resulting_moves(self, parser):
     parser._resulting_moves = []
     parser._convert_token("lurD", tessellation_factory("Sokoban"))
     assert (
         parser._resulting_moves == [
             AtomicMove(Direction.LEFT), AtomicMove(Direction.UP),
             AtomicMove(Direction.RIGHT), AtomicMove(
                 Direction.DOWN, box_moved=True
             )
         ]
     )
Esempio n. 4
0
def trioban_tessellation():
    return tessellation_factory('trioban')
Esempio n. 5
0
def sokoban_tessellation():
    return tessellation_factory('sokoban')
Esempio n. 6
0
 def it_fails_on_jumps_that_contain_pushes(self, parser):
     parser._resulting_moves = []
     parser._convert_token(
         "lurD", tessellation_factory("Sokoban"), is_jump=True
     )
     assert parser._first_encountered_error == SnapshotConversionError.JUMP_CONTAINS_PUSHES
Esempio n. 7
0
 def it_fails_on_moves_illegal_in_context_of_requested_tessellation(
     self, parser
 ):
     parser._convert_token("Nlurd", tessellation_factory("Sokoban"))
     assert parser._first_encountered_error == SnapshotConversionError.NON_VARIANT_CHARACTERS_FOUND
Esempio n. 8
0
 def it_correctly_detects_pusher_selections(self, parser):
     success = parser.convert("{lurd} ", tessellation_factory("Sokoban"))
     assert success
     for atomic_move in parser._resulting_moves:
         assert atomic_move.is_pusher_selection
Esempio n. 9
0
 def it_fails_on_non_matched_sequence_separators(self, parser):
     success = parser.convert("[lurd", tessellation_factory("Sokoban"))
     assert not success
     assert parser._first_encountered_error == SnapshotConversionError.TOKENIZATION_ERROR
Esempio n. 10
0
 def it_fails_on_rle_errors(self, parser):
     success = parser.convert("((4l)", tessellation_factory("Sokoban"))
     assert not success
     assert parser._first_encountered_error == SnapshotConversionError.RLE_DECODING_ERROR
Esempio n. 11
0
 def it_detects_reverse_snapshot_while_ignoring_empty_jumps(
     self, parser
 ):
     success = parser.convert("[]lurd", tessellation_factory("Sokoban"))
     assert success
     assert parser._resulting_solving_mode == 'reverse'
Esempio n. 12
0
 def it_ignores_empty_jump_and_pusher_selection_sequences(self, parser):
     success = parser.convert("[]lurd", tessellation_factory("Sokoban"))
     assert success
     assert len(parser._resulting_moves) == 4
Esempio n. 13
0
 def it_sets_mode_to_reverse_if_jumps_are_found(self, parser):
     success = parser.convert("[lurd] ", tessellation_factory("Sokoban"))
     assert success
     for atomic_move in parser._resulting_moves:
         assert atomic_move.is_jump
Esempio n. 14
0
 def it_fails_on_non_snapshot_characters(self, parser):
     success = parser.convert("ZOMG! ", tessellation_factory("Sokoban"))
     assert not success
     assert parser._first_encountered_error == SnapshotConversionError.NON_SNAPSHOT_CHARACTERS_FOUND