Пример #1
0
	def follow(self, robot_obj, grid_obj):
		move = movement(robot_obj, grid_obj)

		if self.wall == 'left':
			if check_ahead and not(check_left):
				move.move()

		elif self.wall == 'right':
			if check_ahead and not(check_right):
				move.move()
Пример #2
0
    def follow(self, robot_obj, grid_obj):
        move = movement(robot_obj, grid_obj)

        if self.wall == 'left':
            if check_ahead and not (check_left):
                move.move()

        elif self.wall == 'right':
            if check_ahead and not (check_right):
                move.move()
Пример #3
0
def move_x(bot, grid):
    y_direction = bot.fy - bot.y_temp
    x_direction = bot.fx - bot.x_temp
    move = movement(bot, grid)
    if x_direction >= 0:
        bot.set_orientation = 'e'
        for i in range(bot.y_temp, bot.fy):
            if check_ahead(bot, grid) == 'end':
                print 'reached the goal'
            elif check_ahead(bot, grid):
                grid.grid[bot.x_temp][bot.y_temp + 1] = 3
                move.move()
                y_direction = bot.fy - bot.y_temp
                x_direction = bot.fx - bot.x_temp
            else:
                if y_direction >= 0:
                    move.turn_right()
                    if check_ahead(bot, grid) == 'end':
                        print 'reached the goal'
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp + 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp
                elif y_direction < 0:
                    move.turn_left()
                    if check_ahead(bot, grid) == 'end':
                        print 'reached the goal'
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp - 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp

    if x_direction < 0:
        bot.set_orientation = 'w'
        for i in range(bot.y_temp, bot.fy):
            if check_ahead(bot, grid) == 'end':
                print 'reached the goal'
            elif check_ahead(bot, grid):
                grid.grid[bot.x_temp][bot.y_temp - 1] = 3
                move.move()
                y_direction = bot.fy - bot.y_temp
                x_direction = bot.fx - bot.x_temp
            else:
                if y_direction >= 0:
                    move.turn_left()
                    if check_ahead(bot, grid) == 'end':
                        print 'reached the goal'
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp + 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp
                elif y_direction < 0:
                    move.turn_right()
                    if check_ahead(bot, grid) == 'end':
                        print 'reached the goal'
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp - 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp
Пример #4
0
def move_x(bot, grid):
    y_direction = bot.fy - bot.y_temp
    x_direction = bot.fx - bot.x_temp
    move = movement(bot, grid)
    if x_direction >= 0:
        bot.set_orientation = "e"
        for i in range(bot.y_temp, bot.fy):
            if check_ahead(bot, grid) == "end":
                print "reached the goal"
            elif check_ahead(bot, grid):
                grid.grid[bot.x_temp][bot.y_temp + 1] = 3
                move.move()
                y_direction = bot.fy - bot.y_temp
                x_direction = bot.fx - bot.x_temp
            else:
                if y_direction >= 0:
                    move.turn_right()
                    if check_ahead(bot, grid) == "end":
                        print "reached the goal"
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp + 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp
                elif y_direction < 0:
                    move.turn_left()
                    if check_ahead(bot, grid) == "end":
                        print "reached the goal"
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp - 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp

    if x_direction < 0:
        bot.set_orientation = "w"
        for i in range(bot.y_temp, bot.fy):
            if check_ahead(bot, grid) == "end":
                print "reached the goal"
            elif check_ahead(bot, grid):
                grid.grid[bot.x_temp][bot.y_temp - 1] = 3
                move.move()
                y_direction = bot.fy - bot.y_temp
                x_direction = bot.fx - bot.x_temp
            else:
                if y_direction >= 0:
                    move.turn_left()
                    if check_ahead(bot, grid) == "end":
                        print "reached the goal"
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp + 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp
                elif y_direction < 0:
                    move.turn_right()
                    if check_ahead(bot, grid) == "end":
                        print "reached the goal"
                    elif check_ahead(bot, grid):
                        grid.grid[bot.x_temp - 1][bot.y_temp] = 3
                        move.move()
                        y_direction = bot.fy - bot.y_temp
                        x_direction = bot.fx - bot.x_temp