예제 #1
0
def MakeStrategy(cars_info, guide_info, endFlag):
    """
    决策函数(get车辆信息,put指示信息)
    :return: None
    """

    # fake data //begin
    path0 = [[88, 38], [113, 38], [138, 38], [163, 38], [188, 38], [213, 38],
             [238, 38], [263, 38], [288, 38], [313, 38]]
    path1 = [[88, 188], [113, 188], [138, 213], [163, 238], [188, 238],
             [213, 238], [238, 238], [263, 238], [288, 213], [313, 188]]
    path2 = [[88, 313], [113, 313], [138, 313], [163, 313], [188, 313],
             [213, 313], [238, 313], [263, 313], [288, 313], [313, 313]]
    path3 = [[88, 438], [113, 413], [138, 388], [163, 363], [188, 363],
             [213, 363], [238, 363], [263, 388], [288, 413], [313, 438]]
    path4 = [[88, 563], [113, 563], [138, 563], [163, 563], [188, 563],
             [213, 563], [238, 563], [263, 563], [288, 563], [313, 563],
             [338, 563], [363, 563], [388, 563], [413, 563], [438, 563],
             [463, 563], [488, 563], [513, 563]]

    guide0 = guide.Guide(path0)
    guide1 = guide.Guide(path1)
    guide2 = guide.Guide(path2)
    guide3 = guide.Guide(path3)
    guide4 = guide.Guide(path4)

    allguide = [guide0, guide1, guide2, guide3,
                guide4]  # list of class [Guide], see guide.py
    # fake data //end

    guide_info.put(allguide)

    t0 = time.time()
    while True:
        # 决策部分 //begin
        # ...
        # and delete fake data
        # 决策部分 //end
        # guide_info.put(allguide)

        if not endFlag.empty():  # 仿真环境结束后退出决策部分
            if endFlag.get() == 1:
                break

        if cars_info.empty():
            time.sleep(0.1)  # 防止该线程一直占用
            continue
        cars = cars_info.get()  # list of class [Car], see car.py

    t1 = time.time()
    print('Game runing time:', t1 - t0, 's')
예제 #2
0
 def restoreModule(self):
     print self.name
     self.moduleGrp = pm.ls(self.name + '_module')[0]
     self.moduleRebuildInfo = json.loads(self.moduleGrp.attr('moduleInfo').get())
     self.guidesList = self.moduleRebuildInfo['guidesList']
     for guideName in self.guidesList:
         restoreGuide = guide.Guide(name=guideName)
         restoreGuide.restoreGuide() 
예제 #3
0
    def simple_guide2():
        stream = io.StringIO("""\
exercise2:
    Name: Test Exercise 2
    Description: Test description 2
""")
        g = guide.Guide()
        g.load_io(stream)
        return g
예제 #4
0
    def __init__(self):
        global GAME_MESSAGES
        self.GAME_MESSAGES = []
        self.alter_en = True
        pygame.init()
        pygame.font.init()
        self.player_img = pygame.image.load(
            'topdown-shooter/PNG/Man Brown/manBrown_stand.png')
        pygame.key.set_repeat(10, 100)
        self.mission_icon = pygame.image.load('basic/PNG/Props/Dot_A.png')
        self.coin_icon = pygame.image.load('coin.png')
        self.weapon_icon = pygame.image.load(
            'topdown-shooter/PNG/weapon_machine.png')
        self.flag_icon = pygame.image.load('basic/PNG/Props/Flag_A.png')
        self.enemies_number = 20
        self.collect_number = 10

        self.sp = pygame.sprite.Group()
        self.guide_gr = pygame.sprite.Group()
        self.collection = pygame.sprite.Group()
        self._sprites = pygame.sprite.Group()
        self.enemy_pos = []
        self.mission_pos = []
        self.missionDone_pos = []

        self.dt = 0
        self.screen_width = 1400
        self.screen_height = 1200
        self.generate_map()
        self.screen = pygame.display.set_mode(
            (self.screen_width, self.screen_height))
        self.clock = pygame.time.Clock()
        self.running = True
        self.wall_sprites = Map.sprite_walls
        self.floor_sprites = Map.sprite_floors
        self.guide = guide.Guide(self)
        self.guide_gr.draw(self.screen)
        self.camera = vision_field.Vision_field(self.hero, Map.map_size())
        #self.gen.prepare_room(self.screen)
        self.game_over = False
        self.dark = pygame.Surface((self.screen_width, self.screen_height))
        self.dark.fill((0, 0, 0))
        self.light = pygame.image.load('light_350_hard.png')
        self.light = pygame.transform.scale(self.light, (700, 700))
        self.light_rect = self.light.get_rect()
예제 #5
0
def test_file(filename, verbose):
    testguide = guide.Guide()
    try:
        testguide.load_file(filename)
        if verbose > 0:
            for ex in sorted(testguide.get_exercise_ids()):
                print("=" * 78)
                exercise = testguide.get_exercise(ex)
                __display_string("{0}: {1}".format(ex, exercise.name))
                __display_string(exercise.desc)
                if verbose == 1:
                    __display_string("Tips: {0}".format(len(exercise.tips)))
                else:
                    for tip in exercise.tips:
                        __display_string("Tip: " + tip)

            print("=" * 78)
        print("File {1}: Parsed {0} exercises OK".format(
            len(testguide.get_exercise_ids()), filename))
    except (exceptions.ParseError) as e:
        print("Parse failure:", str(e))
    except IOError as e:
        print("File error:", str(e))
예제 #6
0
import sys

import guide
import cards

guide = guide.Guide()