def main(): if len(sys.argv) < 2: raise Exception("missing file") p = Parser(sys.argv[1]) ground_size = p.get_ground_size() ground = Ground(ground_size[0], ground_size[1]) robot_first_pos = p.get_robot_first_pos() robot = WalkerRobot(robot_first_pos[0], robot_first_pos[1], robot_first_pos[2], ground) commands = p.get_command() for command in commands: if command[0] == 'T': robot.teleport(command[1], command[2]) elif command[0] == 'M': robot.move() elif command[0] == 'L' or command[0] == 'R': robot.turn(command[0]) print 'final pos:', robot.x, robot.y, robot.curr_direction
def test_walker_bot_teleport_to_wrong_place(): g = Ground(10,10) bot = WalkerRobot("E", 1, 1,g) with pytest.raises(Exception): bot.teleport(1000,10000)
def test_walker_bot_teleport(): g = Ground(10,10) bot = WalkerRobot("E",1,1,g) bot.teleport(4,4) assert bot.x == 4 assert bot.y == 4