예제 #1
0
    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
예제 #2
0
파일: test_team.py 프로젝트: ASPP/pelita
    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)
예제 #3
0
파일: test_team.py 프로젝트: ASPP/pelita
    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 == """
예제 #4
0
    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)
예제 #5
0
    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 == """
예제 #6
0
파일: test_team.py 프로젝트: ASPP/pelita
    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)])
예제 #7
0
파일: test_team.py 프로젝트: ASPP/pelita
    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
예제 #8
0
    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)])
예제 #9
0
파일: test_team.py 프로젝트: ASPP/pelita
 def test_load1(self):
     layout = create_layout(self.layout)
     assert layout.bots == [(6, 1), (1, 2)]
     assert layout.enemy == [(5, 1), (2, 2)]
예제 #10
0
파일: test_team.py 프로젝트: ASPP/pelita
 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)]
예제 #11
0
 def test_load1(self):
     layout = create_layout(self.layout)
     assert layout.bots == [(6, 1), (1, 2)]
     assert layout.enemy == [(5, 1), (2, 2)]
예제 #12
0
 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)]