def main(): file_name = input("Insert the file name (default: rovers.txt)\n") f = open(file_name,'r') lines = f.read().splitlines() bound = lines[0].split() if(len(bound) != 2): print("Bound error. Please, review the bounds in the file\n") return -3 Rover.set_boundaries(int(bound[0]),int(bound[1])) i = 1 while (i < (len(lines) -1)): rv = lines[i].split() if(len(rv)!=3): print("Rover definition error. Please, review the location of the rover %s in the file\n"%(i)) return -4 r = Rover(int(rv[0]), int(rv[1]),rv[2]) r.execute_commands(lines[i+1]) i = i + 2 r.print_rover() f.close()
r.print_rover() r.new_position('M') r.print_rover() def test_move_back(r): r.print_rover() r.new_position('M') r.print_rover() r.new_position('R') r.print_rover() r.new_position('R') r.print_rover() r.new_position('M') r.print_rover() def test_execute_commands(r): #r.execute_commands('MMMLMMM') r.execute_commands('RLRLRLRLMMMRLRL') r.print_rover() Rover.set_boundaries(5,5) r = Rover(1,1,'E') #test_object(r) #test_rover_motion(r) #test_move_forward(r) #test_turn_lef(r) #test_turn_right(r) #test_move_back(r) test_execute_commands(r)