def test_repr(self): layout = create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None) assert layout._repr_html_() str1 = str( create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None)) assert str1 == """ ######## #.### # # # ######## ######## # ###E0# #1E # ######## """ layout_merge = create_layout(self.layout, food=[(1, 1)], bots=[(1, 2), (1, 2)], enemy=[(1, 1), (1, 1)]) str2 = str(layout_merge) assert str2 == """ ######## #.### # # # ######## ######## #E### # #0 # ######## ######## #E### # #1 # ######## """ # load again assert create_layout(str2) == layout_merge
def test_equal_positions(self): layout_str = """ ######## #0### # # . ...# ######## ######## #1### # # . ...# ######## ######## #E### # # . ...# ######## ######## #E### # # . ...# ######## """ layout = create_layout(layout_str) assert layout.bots == [(1, 1), (1, 1)] assert layout.enemy == [(1, 1), (1, 1)] setup_test_game(layout=layout_str)
def test_solo_bot(self): l = """ ######## #.### # # # ######## ######## # ### # #0E # ######## """ layout = create_layout(l, food=[(1, 1)], bots=[None, None], enemy=None) assert layout._repr_html_() str1 = str(create_layout(l, food=[(1, 1)], bots=[None, None], enemy=None)) assert str1 == """
def test_equal_positions(self): layout_str = """ ######## #0### # # . ...# ######## ######## #1### # # . ...# ######## ######## #E### # # . ...# ######## ######## #E### # # . ...# ######## """ layout = create_layout(layout_str) assert layout.bots == [(1, 1), (1, 1)] assert layout.enemy == [(1, 1), (1, 1)] setup_test_game(layout=layout_str)
def test_solo_bot(self): l = """ ######## #.### # # # ######## ######## # ### # #0E # ######## """ layout = create_layout(l, food=[(1, 1)], bots=[None, None], enemy=None) assert layout._repr_html_() str1 = str( create_layout(l, food=[(1, 1)], bots=[None, None], enemy=None)) assert str1 == """
def test_define_after(self): layout = create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] layout = create_layout(self.layout, food=[(1, 1)], bots=[None, (1, 2)], enemy=None) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] layout = create_layout(self.layout, food=[(1, 1)], bots=[None, (1, 2)], enemy=[(5, 1)]) assert layout.enemy == [(2, 2), (5, 1)] layout = create_layout(self.layout2, food=[(1, 1)], bots=[None, (1, 2)], enemy=[(5, 1), (2, 2)]) assert layout.bots == [None, (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] with pytest.raises(ValueError): # placed bot on walls layout = create_layout(self.layout2, food=[(1, 1)], bots=[(0, 1), (1, 2)], enemy=[(5, 1), (2, 2)]) with pytest.raises(ValueError): # placed bot outside maze layout = create_layout(self.layout2, food=[(1, 1)], bots=[(1, 40), (1, 2)], enemy=[(5, 1), (2, 2)]) with pytest.raises(ValueError): # too many bots layout = create_layout(self.layout2, food=[(1, 1)], bots=[(1, 1), (1, 2), (2, 2)], enemy=[(5, 1), (2, 2)])
def test_repr(self): layout = create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None) assert layout._repr_html_() str1 = str(create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None)) assert str1 == """ ######## #.### # # # ######## ######## # ###E0# #1E # ######## """ layout_merge = create_layout(self.layout, food=[(1, 1)], bots=[(1, 2), (1, 2)], enemy=[(1, 1), (1, 1)]) str2 = str(layout_merge) assert str2 == """ ######## #.### # # # ######## ######## #E### # #0 # ######## ######## #E### # #1 # ######## """ # load again assert create_layout(str2) == layout_merge
def test_define_after(self): layout = create_layout(self.layout, food=[(1, 1)], bots=[None, None], enemy=None) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] layout = create_layout(self.layout, food=[(1, 1)], bots=[None, (1, 2)], enemy=None) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] layout = create_layout(self.layout, food=[(1, 1)], bots=[None, (1, 2)], enemy=[(5, 1)]) assert layout.enemy == [(2, 2), (5, 1)] layout = create_layout(self.layout2, food=[(1, 1)], bots=[None, (1, 2)], enemy=[(5, 1), (2, 2)]) assert layout.bots == [None, (1, 2)] assert layout.enemy == [(5, 1), (2, 2)] with pytest.raises(ValueError): # placed bot on walls layout = create_layout(self.layout2, food=[(1, 1)], bots=[(0, 1), (1, 2)], enemy=[(5, 1), (2, 2)]) with pytest.raises(ValueError): # placed bot outside maze layout = create_layout(self.layout2, food=[(1, 1)], bots=[(1, 40), (1, 2)], enemy=[(5, 1), (2, 2)]) with pytest.raises(ValueError): # too many bots layout = create_layout(self.layout2, food=[(1, 1)], bots=[(1, 1), (1, 2), (2, 2)], enemy=[(5, 1), (2, 2)])
def test_load1(self): layout = create_layout(self.layout) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)]
def test_concat(self): layout = create_layout(self.layout + self.layout2) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)]
def test_load1(self): layout = create_layout(self.layout) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)]
def test_concat(self): layout = create_layout(self.layout + self.layout2) assert layout.bots == [(6, 1), (1, 2)] assert layout.enemy == [(5, 1), (2, 2)]