コード例 #1
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
コード例 #2
0
def test_piz_sf():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert res.point_in_zone((11, 10))
    assert not res.point_in_zone((60, 10))
コード例 #3
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))
コード例 #4
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))
コード例 #5
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)
コード例 #6
0
def test_force_mur():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    for_mur = res.force_mur(res.list_person[0])
    assert for_mur[0] == 2000.0
    assert fabs(for_mur[1] - (-13.47589)) < 0.00001
コード例 #7
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]
コード例 #8
0
def test_force_obs():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    for_obs = res.force_obs(res.list_person[1], res.map.zone_obstacale[0])
    assert for_obs[0] == 0
    assert fabs(for_obs[1] - (-164.17000)) < 0.00001
コード例 #9
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
コード例 #10
0
def test_cal_a():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.calcul_a()
    assert fabs(res.list_person[0].a[0] - (58.10474)) < 0.00001
    assert fabs(res.list_person[0].a[1] - (-8.76766)) < 0.00001
コード例 #11
0
def test_amv_sf():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.addMapValue(res.thmap, 22, 10)
    assert res.thmap[22][10] == 1
    assert res.thmap[2][2] == 0
コード例 #12
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)]
コード例 #13
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)
コード例 #14
0
def test_maj_sf():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.maj()
    assert fabs(res.list_person[1].v[0] - (0.09988)) < 0.00001
    assert fabs(res.list_person[1].v[1] - (-0.01131)) < 0.00001
    assert fabs(res.list_person[1].position[0] - (6.00062)) < 0.00001
    assert fabs(res.list_person[1].position[1] - (2.99993)) < 0.00001
コード例 #15
0
def test_move():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    res.calcul_a()
    res.move()
    assert fabs(res.list_person[0].v[0] - (0.29052)) < 0.00001
    assert fabs(res.list_person[0].v[1] - (-0.04384)) < 0.00001
    assert fabs(res.list_person[0].position[0] - (1.50182)) < 0.00001
    assert fabs(res.list_person[0].position[1] - (15.49973)) < 0.00001
コード例 #16
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)]
コード例 #17
0
def test_map():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/test.txt')
    res = map.map(length_width, wall, sorties, obstacles, incendies)
    assert res.length == 50
    assert res.width == 30
    assert res.wall == [[(0, 49)], [(0, 29)], [(0, 49)], [(0, 3), (7, 29)]]
    assert res.sorties == [(0, 6), (0, 5), (0, 4)]
    assert res.incendies == [(10, 10)]
    assert res.zone_obstacale == [((5, 4), (8, 5))]
    assert (0, 29) in res.list_obstacle
    assert (6, 5) in res.list_obstacle
コード例 #18
0
def test_foule_mfs():
    length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt(
        'pytest/MFS_ex copy.txt')
    res = foule_sf.Foule(people, length_width, wall, sorties, obstacles,
                         incendies)
    assert res.map.length == 27
    assert res.map.width == 17
    assert res.map.wall == [[(0, 26)], [(0, 3), (5, 16)], [(0, 26)], [(0, 16)]]
    assert res.map.sorties == [(26, 4)]
    assert res.map.incendies == []
    assert res.map.zone_obstacale == [((5, 4), (8, 5))]
    assert (0, 15) in res.map.list_obstacle
    assert (6, 4) in res.map.list_obstacle
    assert len(res.list_person) == 2
    assert res.list_person[0].id == 1
    assert res.list_person[0].position == (1.5, 15.5)
コード例 #19
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
コード例 #20
0
def test_lire_txt():
    res = fon.lire_txt('pytest/test.txt')
    assert res == [(50, 30),
                   [[(0, 49)], [(0, 29)], [(0, 49)], [(0, 3), (7, 29)]],
                   [(0, 6), (0, 5), (0, 4)], [[(5, 5), (8, 4)]], [(10, 10)],
                   [(8, 2), (10, 6)]]