if ds_global.is_in_front_of_door(ws_global, rs_global): raise ValueError("The robot should NOT be in front of a door") # Check that we get our probabilites back (mostly) count_returned_true = 0 for i in range(0, 1000): if ds_global.sensor_reading(ws_global, rs_global): count_returned_true += 1 prob_count = count_returned_true / 1000 if abs(prob_count - ds_global.prob_see_door_if_no_door) > 0.1: raise ValueError("Probability should be close to {}, is {}".format( ds_global.prob_see_door_if_no_door, prob_count)) print("Testing probabilities for robot in front of door") rs_global.robot_loc = ws_global.place_robot_in_front_of_door() if not ds_global.is_in_front_of_door(ws_global, rs_global): raise ValueError("The robot SHOULD be in front of a door") # Check that we get our probabilities back (mostly) when in front of the door count_returned_true = 0 for i in range(0, 1000): if ds_global.sensor_reading(ws_global, rs_global): count_returned_true += 1 prob_count = count_returned_true / 1000 if abs(prob_count - ds_global.prob_see_door_if_door) > 0.1: raise ValueError("Probability should be close to {}, is {}".format( ds_global.prob_see_door_if_door, prob_count)) print("Passed tests")
if ds.is_in_front_of_door(ws, rs): raise ValueError("The robot should NOT be in front of a door") # Check that we get our probabilites back (mostly) count_returned_true = 0 for i in range(0, 1000): if ds.sensor_reading(ws, rs) == True: count_returned_true += 1 prob_count = count_returned_true / 1000 if abs(prob_count - ds.prob_see_door_if_no_door) > 0.1: raise ValueError("Probability should be close to {}, is {}".format( ds.prob_see_door_if_no_door, prob_count)) print("Testing probabilities for robot in front of door") rs.robot_loc = ws.place_robot_in_front_of_door() if ds.is_in_front_of_door(ws, rs) == False: raise ValueError("The robot SHOULD be in front of a door") # Check that we get our probabilites back (mostly) when in front of the door count_returned_true = 0 for i in range(0, 1000): if ds.sensor_reading(ws, rs) == True: count_returned_true += 1 prob_count = count_returned_true / 1000 if abs(prob_count - ds.prob_see_door_if_door) > 0.1: raise ValueError("Probability should be close to {}, is {}".format( ds.prob_see_door_if_door, prob_count)) print("Passed tests")