import random import time from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() while True: if not cleaner.check_surface(): cleaner.clean_surface() choice = random.randint(0, 20) if choice == 0: result = cleaner.rotate(RotateDirection.RIGHT) elif choice == 1: cleaner.rotate(RotateDirection.LEFT) while cleaner.check_passability() and choice > 2: choice -= 1 cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.get_battery_level() < 50: cleaner.return_dock() cleaner.send_debug_message("VC: RETURN DOCK") while cleaner.get_battery_level() < 50: time.sleep(60) cleaner.send_debug_message("VC: CHARGING - battery: {}".format( cleaner.get_battery_level()))
cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() print("Discovered things: ".format(cleaner.discover_things())) if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() print("Trying to rotate left - success : {}".format( cleaner.rotate(RotateDirection.LEFT))) cleaner.print_env() if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else:
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.move(MoveDirection.FORWARD) while True: cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.send_debug_message("Battery level = {}".format(cleaner.get_battery_level()))
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.rotate(RotateDirection.RIGHT) while True: cleaner.move(MoveDirection.FORWARD)