コード例 #1
0
ファイル: test_model.py プロジェクト: slavi010/polyhash-2020
def robot_faire_prochain_mouvement_test():
    grille = Grille(10, 10)
    point_montage = PointMontage(5, 5)
    point_montage_bis = PointMontage(6, 6)
    grille.add_point_montage(point_montage)
    grille.add_point_montage(point_montage_bis)

    etape = Etape(5, 6)
    tache = Tache(15, 0)
    tache.add_etape(etape)

    robot = Robot()
    robot.point_montage = point_montage
    robot.add_tache(tache, grille)
    robot.mouvements.append(Mouvement.HAUT)
    robot.mouvements.append(Mouvement.DROITE)
    grille.robots.append(robot)

    # tout va bien
    robot.faire_prochain_mouvement(grille)
    assert len(grille.cases[6][5]) == 1 and isinstance(grille.cases[6][5][0],
                                                       Bras)
    assert len(robot.bras) == 1
    assert len(robot.mouvements) == 1

    assert grille.points == 15
    assert not len(robot.taches)

    # collision avec point de montage bis
    try:
        robot.faire_prochain_mouvement(grille)
    except ConnectionError:
        pass
    else:
        assert False
コード例 #2
0
ファイル: test_model.py プロジェクト: slavi010/polyhash-2020
def robot_get_plus_proche_tache_test():
    grille = Grille(10, 10)
    point_montage = PointMontage(5, 5)
    etape_1 = Etape(5, 6)
    etape_2 = Etape(5, 7)
    tache = Tache(15, 0)
    tache.add_etape(etape_1)
    tache.add_etape(etape_2)
    grille.add_tache(tache)
    robot = Robot()
    robot.point_montage = point_montage
    robot.add_tache(robot.get_plus_proche_tache(grille), grille)
    assert not robot.get_plus_proche_tache(grille)
コード例 #3
0
ファイル: test_model.py プロジェクト: slavi010/polyhash-2020
def robot_add_tache_test():
    grille = Grille(10, 10)
    point_montage = PointMontage(5, 5)
    etape_1 = Etape(5, 6)
    etape_2 = Etape(5, 7)
    tache = Tache(15, 0)
    tache.add_etape(etape_1)
    tache.add_etape(etape_2)
    grille.add_tache(tache)
    robot = Robot()
    robot.point_montage = point_montage
    robot.add_tache(tache, grille)

    assert len(robot.taches)
    assert not len(grille.taches)
コード例 #4
0
ファイル: test_model.py プロジェクト: slavi010/polyhash-2020
def grille_start_simulation_test():
    grille = Grille(10, 10)
    grille.step_simulation = 2
    point_montage = PointMontage(5, 5)
    point_montage_bis = PointMontage(6, 6)
    grille.add_point_montage(point_montage)
    grille.add_point_montage(point_montage_bis)

    etape_1 = Etape(5, 6)
    etape_2 = Etape(5, 7)
    tache = Tache(15, 0)
    tache.add_etape(etape_1)
    tache.add_etape(etape_2)
    grille.add_tache(tache)

    robot = Robot()
    robot.point_montage = point_montage
    robot.add_tache(tache, grille)
    robot.mouvements.append(Mouvement.HAUT)
    robot.mouvements.append(Mouvement.HAUT)
    grille.robots.append(robot)

    grille.start_simulation()
    print(grille.points)