コード例 #1
0
    def init(self):
        if self.model.get() == '' or self.txt_nom.get() == '':
            print("Error: no model or fichier")
        else:
            length_width, wall, sorties, obstacles, incendies, people = fonction.lire_txt(
                self.txt_nom.get())
            self.canvas.config(width=GUI.Pic_Ratio * length_width[0],
                               height=GUI.Pic_Ratio * (length_width[1] - 1))
            self.canvas.place(x=350 - GUI.Pic_Ratio * length_width[0] / 2,
                              y=60)

            if self.model.get() == 'AC':
                self.ini = True
                self.foule = foule_ca.Foule(people, length_width, wall,
                                            sorties, obstacles, incendies)
                self.foule.u1 = self.u1.get()
                self.foule.u2 = self.u2.get()
                self.foule.u3 = self.u3.get()
                self.foule.u4 = self.u4.get()
                self.foule.u5 = self.u5.get()

            if self.model.get() == 'MFS':
                self.ini = True
                self.foule = foule_sf.Foule(people, length_width, wall,
                                            sorties, obstacles, incendies)
                self.foule.arg_A = self.arg_a.get()
                self.foule.arg_B = self.arg_b.get()
                self.foule.k = self.k.get()
                self.foule.delta_time = self.dt_time.get()

            self.set_sortie(self.foule)
            self.set_obstacle(self.foule)
            self.set_incendie(self.foule)
            self.show_people(self.foule)
コード例 #2
0
def test_cal_gam():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert res.calcul_gamma((9, 5)) == 2
    assert res.calcul_gamma((15, 5)) == -1
コード例 #3
0
def test_pt_obs():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert not res.point_obstacle((12, 13))
    assert res.point_obstacle((7, 5))
コード例 #4
0
def test_pt_st():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert res.point_stat((8, 2))
    assert not res.point_stat((13, 12))
コード例 #5
0
def test_pcmn():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.list_move_pc = [((9, 2), 1), ((9, 1), 1)]
    assert res.pc_m_n(res.list_person[0]) == [2, 2, 0, 0, 0, 0, 0, 0, 0]
    assert res.pc_m_n(res.list_person[1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]
コード例 #6
0
def test_amv_ca():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.addMapValue(res.thmap, 10, 11)
    assert res.thmap[10][11] == 1
    assert res.thmap[1][1] == 0
コード例 #7
0
def test_maj_ca():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.maj()
    assert res.list_person[0].position == (7, 2)
    assert res.list_person[1].position == (9, 7)
    assert res.list_move_pc == [((8, 2), 6), ((10, 6), 5)]
コード例 #8
0
def test_calcul_ca():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    list = res.calcul()
    assert list[0][0].position == (8, 2)
    assert list[0][1] == (7, 2)
    assert list[1][0].position == (10, 6)
    assert list[1][1] == (9, 7)
コード例 #9
0
def test_voi():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    list = res.voisins(res.list_person[0])
    assert list == [(9, 1), (9, 2), (9, 3), (8, 3), (7, 3), (7, 2), (7, 1),
                    (8, 1)]
    per = foule_ca.Person(3, 9, 5)
    list = res.voisins(per)
    #print(list)
    assert list == [(10, 4), (10, 5), (9, 6), (8, 6), (9, 4)]
コード例 #10
0
def test_foule_ca():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = foule_ca.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert res.map.length == 50
    assert res.map.width == 30
    assert res.map.wall == [[(0, 49)], [(0, 29)], [(0, 49)], [(0, 3), (7, 29)]]
    assert res.map.sorties == [(0, 6), (0, 5), (0, 4)]
    assert res.map.incendies == [(10, 10)]
    assert res.map.zone_obstacale == [((5, 4), (8, 5))]
    assert (0, 29) in res.map.list_obstacle
    assert (6, 5) in res.map.list_obstacle
    assert len(res.list_person) == 2
    assert res.list_person[0].id == 1
    assert res.list_person[0].position == (8, 2)
    assert res.list_person[1].id == 2
    assert res.list_person[1].position == (10, 6)
    assert res.pos_pd[4][1] == 0.2
    assert res.pos_pd[10][6] == 0.1