Exemple #1
0
def handle_correctable_case(p0: Perception, p1: Perception, cl: Classifier,
                            population: ClassifiersList):
    new_cl = Classifier.build_corrected(cl, p0, p1)
    existing = [cl for cl in population if cl == new_cl]

    if len(existing) == 0:
        population.append(new_cl)
Exemple #2
0
    def test_should_construct_correct_classifier(self, cfg):
        cl = Classifier(condition="000#", effect="000#", quality=0.2, cfg=cfg)
        p0 = Perception("0000")
        p1 = Perception("0001")
        assert cl.does_match(p0)

        new_cl = Classifier.build_corrected(cl, p0, p1)

        assert new_cl is not cl
        assert new_cl.condition is not cl.condition
        assert new_cl.effect is not cl.effect
        assert new_cl.condition == Condition("0000")
        assert new_cl.action == cl.action
        assert new_cl.effect == Effect("0001")
        assert new_cl.q == 0.5
        assert new_cl.does_match(p0)