def test_crashing_into_right_wall(): patient = Road(1, Car(3, 1), []) successors = list(patient.successors(RIGHT)) assert len(successors) == 1 s, p = successors[0] assert p == 1.0 assert s.to_key() != patient.to_key() assert s.to_key() == (-1, 0, frozenset()) assert s.to_s() == ' ' * 7 + '\n' + ' ' * 7
def test_car_has_crashed(col): patient = Road(4, Car(col, 1), []) assert patient.has_crashed() assert patient.has_crashed(Car(col, 1)) assert not patient.has_crashed(Car(0, 1)) assert patient.to_key() == (-1, 0, frozenset()) for action in ACTIONS: successors, probs = zip(*patient.successors(action)) assert [s.to_key() for s in successors] == [(-1, 0, frozenset())] assert sum(probs) == pytest.approx(1.0)