Exemplo n.º 1
0
 def test_peek_limit(self):
     self.begin_for_testing()
     down(90)
     forward(300)
     self.assertEqual(None, peek())
     up(180)
     forward(700)
Exemplo n.º 2
0
    def test_forward_outside_of_game_boundaries_just_doesnt_attempt_to_lay_blocks__less_than_min_y(
            self):
        self.game.player.tile_pos = Vector(100, 2, 300)
        self.game.player.rotation = 2
        self.begin_for_testing(start_distance_from_player=5)

        down(90)
        forward(10)

        self.assertEqual(
            {
                (100, 2, 305): "gold_block",
                (100, 1, 305): "gold_block",
                (100, 0, 305): "gold_block"
            }, self.game.tiles)
Exemplo n.º 3
0
 def test_some_more_turning(self):
     self.begin_for_testing()
     forward(2)
     right(90)
     forward(2)
     down(90)
     forward(2)
     self.assertEqual(
         {
             (100, 200, 300): "gold_block",
             (100, 200, 301): "gold_block",
             (100, 200, 302): "gold_block",
             (99, 200, 302): "gold_block",
             (98, 200, 302): "gold_block",
             (98, 199, 302): "gold_block",
             (98, 198, 302): ("piston", {
                 "facing": "down"
             })
         }, self.game.tiles)
Exemplo n.º 4
0
    def test_turn_methods_take_valid_degrees(self):
        self.begin_for_testing()

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, right\(abc\) won't work. Degrees must be a number."):
            right('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, left\(abc\) won't work. Degrees must be a number."):
            left('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, up\(abc\) won't work. Degrees must be a number."):
            up('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, down\(abc\) won't work. Degrees must be a number."):
            down('abc')
Exemplo n.º 5
0
    def test_show_that_turtle_wont_turn_right_when_going_down_or_up(self):
        self.begin_for_testing()
        forward(2)
        down(90)
        forward(2)
        right(90)
        forward(2)
        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 301): "gold_block",
                (100, 200, 302): "gold_block",
                (100, 199, 302): "gold_block",

                # turtle should have gone right but it didn't.
                (100, 198, 302): "gold_block",
                (100, 197, 302): "gold_block",
                (100, 196, 302): ("piston", {
                    "facing": "down"
                })
            },
            self.game.tiles)
Exemplo n.º 6
0
    def test_down_90(self):
        self.begin_for_testing()
        forward(1)
        down(90)

        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 301): ("piston", {
                    "facing": "down"
                })
            }, self.game.tiles)

        forward(2)

        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 301): "gold_block",
                (100, 199, 301): "gold_block",
                (100, 198, 301): ("piston", {
                    "facing": "down"
                })
            }, self.game.tiles)
Exemplo n.º 7
0
    def test_basic(self):
        def connect():
            # connect to minecraft server running on localhost, 25565 (default port)
            return mcpi.minecraft.Minecraft.create()

        # mcpi_minecraft.setBlockV2(1, 120, 1, block.STONE.name, variant=block.STONE.VARIANT_ANDESITE.value)
        # mcpi_minecraft.setBlockV2(1, 127, 1, block.STONE.name, block.STONE.VARIANT_ANDESITE)
        # mcpi_minecraft.setBlockV2(1, 130, 1, block.PISTON.name, block.PISTON.FACING_DOWN)

        # mcpi_minecraft.setBlockV2(1, 101, 1, block.DIRT.name)
        # mcpi_minecraft.setBlockV2(1, 102, 1, block.CACTUS.name, block.CACTUS.AGE_15)
        init(connect, "papadapadapa")
        chat("hi")
        # begin()
        # pen_down(block.GOLD_BLOCK)

        # forward()
        # forward()
        # forward()
        # forward()

        # up(90)
        # forward()
        # forward()
        # forward()
        # forward()

        # down(90)
        # right(90)
        # forward()
        # forward()
        # forward()
        # forward()

        # begin()
        # delay(0)
        # up(90)
        # for i in xrange(300):
        #     forward(1)
        # down(180)
        # for i in xrange(300):
        #     forward(1)

        # for i in xrange(10):
        #     for i in xrange(1000):
        #         forward(10)
        #     back(1)
        #     for i in xrange(1000):
        #         forward(10)

        # pen_down(living.COW)

        # for i in xrange(50):
        #         forward()

        # sleep(5)
        # select_living_things(nearby())
        # start_task(living.COW.PANIC)
        # start_task(living.OCELOT.MATE)
        # reset_task(living.OCELOT.FOLLOW_OWNER)
        # start_task(living.OCELOT.OCELOT_ATTACK)
        # start_task(living.OCELOT.LEAP_AT_TARGET)

        # reset_task(living.WOLF.SIT)

        # forward()

        # forward()
        # forward()

        # right(90)
        # forward()
        # forward()

        # up(90)
        # forward()
        # forward()

        # right(90)

        # forward()
        # forward()

        # left(90)

        # forward()
        # forward()

        # left(90)

        # forward()
        # forward()

        # right(90)

        # forward(2)

        # down(90)

        # math bug START

        begin()
        delay(0)
        down(90)
        for _ in xrange(200):
            print forward(1)
Exemplo n.º 8
0
    def test_basic(self):
        def connect():
            # connect to minecraft server running on localhost, 25565 (default port)
            return mcpi.minecraft.Minecraft.create()

        # mcpi_minecraft.setBlockV2(1, 120, 1, block.STONE.name, variant=block.STONE.VARIANT_ANDESITE.value)
        # mcpi_minecraft.setBlockV2(1, 127, 1, block.STONE.name, block.STONE.VARIANT_ANDESITE)
        # mcpi_minecraft.setBlockV2(1, 130, 1, block.PISTON.name, block.PISTON.FACING_DOWN)

        # mcpi_minecraft.setBlockV2(1, 101, 1, block.DIRT.name)
        # mcpi_minecraft.setBlockV2(1, 102, 1, block.CACTUS.name, block.CACTUS.AGE_15)
        init(connect, "papadapadapa")
        chat("hi")
        # begin()
        # pen_down(block.GOLD_BLOCK)

        # forward()
        # forward()
        # forward()
        # forward()

        # up(90)
        # forward()
        # forward()
        # forward()
        # forward()

        # down(90)
        # right(90)
        # forward()
        # forward()
        # forward()
        # forward()

        # begin()
        # delay(0)
        # up(90)
        # for i in xrange(300):
        #     forward(1)
        # down(180)
        # for i in xrange(300):
        #     forward(1)

        # for i in xrange(10):
        #     for i in xrange(1000):
        #         forward(10)
        #     back(1)
        #     for i in xrange(1000):
        #         forward(10)


        # pen_down(living.COW)

        # for i in xrange(50):
        #         forward()

        # sleep(5)
        # select_living_things(nearby())
        # start_task(living.COW.PANIC)
        # start_task(living.OCELOT.MATE)
        # reset_task(living.OCELOT.FOLLOW_OWNER)
        # start_task(living.OCELOT.OCELOT_ATTACK)
        # start_task(living.OCELOT.LEAP_AT_TARGET)

        # reset_task(living.WOLF.SIT)


        # forward()

        # forward()
        # forward()

        # right(90)
        # forward()
        # forward()

        # up(90)
        # forward()
        # forward()

        # right(90)

        # forward()
        # forward()

        # left(90)

        # forward()
        # forward()

        # left(90)

        # forward()
        # forward()

        # right(90)


        # forward(2)

        # down(90)

        # math bug START

        begin()
        delay(0)
        down(90)
        for _ in xrange(200):
            print forward(1)