コード例 #1
0
    def generate(self):
        if random.random() > 0.5:
            map = Map([
                Obstacle([136, 552], 192, 448),
                Obstacle([1072, 672], 336, 176)
            ], [[random.randint(80, 180), 264]],
                      [[random.randint(300, 550),
                        random.randint(500, 700)],
                       [random.randint(650, 850),
                        random.randint(500, 700)],
                       [random.randint(930, 1230),
                        random.randint(300, 500)]])
        else:
            map = Map([
                Obstacle([1144, 552], 192, 448),
                Obstacle([208, 672], 336, 176)
            ], [[random.randint(1000, 1200), 264]],
                      [[random.randint(750, 950),
                        random.randint(500, 700)],
                       [random.randint(400, 650),
                        random.randint(500, 700)],
                       [random.randint(50, 350),
                        random.randint(300, 500)]])

        return map
コード例 #2
0
    def generate(self):
        rndm = random.random()
        if rndm > 0.5:
            map = Map(
                [Obstacle([400, 570], 80, 380),
                 Obstacle([880, 650], 80, 300)],
                [[random.randint(100, 200), 400],
                 [random.randint(200, 300), 700]],
                [[random.randint(500, 700),
                  random.randint(350, 700)],
                 [random.randint(1000, 1100),
                  random.randint(350, 700)], [880,
                                              random.randint(150, 300)]])
        else:
            map = Map(
                [Obstacle([880, 570], 80, 380),
                 Obstacle([400, 650], 80, 300)],
                [[random.randint(1100, 1200), 400],
                 [random.randint(980, 1080), 700]],
                [[random.randint(500, 700),
                  random.randint(350, 700)],
                 [random.randint(100, 200),
                  random.randint(350, 700)], [400,
                                              random.randint(150, 300)]])

        return map
コード例 #3
0
 def get_obstacle_body(self):
     return [
         Obstacle(self.pos, 12, self.circle_radius * 2),
         Obstacle(self.pos, self.circle_radius * 2, 12),
         Obstacle(self.pos, 33, self.circle_radius * 2 - 8),
         Obstacle(self.pos, self.circle_radius * 2 - 8, 33),
         Obstacle(self.pos, 56, 56)
     ]
コード例 #4
0
    def generate(self):
        map = Map([Obstacle([400, 520], 80, 360), Obstacle([880, 520], 80, 360),
                   Obstacle([640, 360], 400, 40)],
                  [[random.randint(100, 300), 700], [random.randint(900, 1100), 700]],
                  [[random.randint(480, 800), random.randint(600, 700)],
                   [random.randint(500, 780), random.randint(200, 300)]])

        return map
コード例 #5
0
ファイル: Split.py プロジェクト: nunolau/GeoFriends2-v2
    def generate(self):
        map = Map([Obstacle([400, 590], 80, 220), Obstacle([880, 590], 80, 220),
                   Obstacle([200, 500], 400, 40), Obstacle([1080, 500], 400, 40)],
                  [[random.randint(500, 700), 600], [random.randint(500, 700), 700]],
                  [[random.randint(100, 300), random.randint(600, 700)] if random.random() > 0.5 else
                   [random.randint(980, 1180), random.randint(600, 700)],
                   [random.randint(100, 300), random.randint(200, 400)] if random.random() > 0.5 else
                   [random.randint(980, 1180), random.randint(200, 400)]])

        return map
コード例 #6
0
    def generate(self):
        if random.random() > 0.5:
            map = Map([Obstacle([480, 328], 960, 32)], [[136, 264]],
                      [[136, 100], [1100, 272]])
        else:
            map = Map([Obstacle([800, 328], 960, 32)], [[1150, 264]],
                      [[1150, 100], [180, 272]])

        map.is_terminal = lambda positions: any(
            [pos[1] > 700 for pos in positions]) or len(map.rewards) == 0

        return map
コード例 #7
0
    def __init__(self, obstacles, starting_positions, rewards):
        # all maps should be based on 1280x800 screen, as per original Geometry Friends

        # standard map limits
        self.obstacles = [Obstacle([640, 780], 1280, 40), Obstacle([640, 20], 1280, 40),
                          Obstacle([20, 400], 40, 800), Obstacle([1260, 400], 40, 800)]
        self.obstacles.extend(obstacles)

        # each map should only spawn as many agents as starting positions are available
        self.starting_positions = starting_positions

        # each map should have 3 rewards maximum, for consistency
        self.rewards = rewards
コード例 #8
0
    def generate(self):
        if random.random() > 0.5:
            obstacles = [Obstacle([480, 328], 960, 32)]
        else:
            obstacles = [Obstacle([800, 328], 960, 32)]

        #check if player position is not colliding with any obstacle
        while True:
            colliding = False
            initial_playerx = random.randint(80, 1200)
            initial_playery = random.randint(80, 720)
            for obs in obstacles:
                if (collision(initial_playerx, initial_playery, 40,
                              obs.center_x - obs.half_width,
                              obs.center_y - obs.half_height,
                              obs.half_width * 2, obs.half_height * 2)[0]):
                    colliding = True
            if colliding:
                continue
            else:
                break

        # #Do the same for the reward and also check if its not already colliding with player
        while True:
            colliding = False
            initial_rewardx = random.randint(65, 1215)
            initial_rewardy = random.randint(65, 735)
            distance = math.sqrt(((initial_playerx - initial_rewardx)**2) +
                                 ((initial_playery - initial_rewardy)**2))
            if (distance <= 65):
                continue

            for obs in obstacles:
                if (collision(initial_rewardx, initial_rewardy, 25,
                              obs.center_x - obs.half_width,
                              obs.center_y - obs.half_height,
                              obs.half_width * 2, obs.half_height * 2)[0]):
                    colliding = True
            if colliding:
                continue
            else:
                break

        map = Map(obstacles, [initial_playerx, initial_playery],
                  [[initial_rewardx, initial_rewardy]])

        return map
コード例 #9
0
ファイル: Pyramid.py プロジェクト: nunolau/GeoFriends2-v2
    def generate(self):
        map = Map([Obstacle([640, 660], 400, 200)], [[150, 700]],
                  [[random.randint(100, 300),
                    random.randint(500, 700)],
                   [random.randint(440, 840),
                    random.randint(300, 500)],
                   [random.randint(980, 1180),
                    random.randint(500, 700)]])

        return map
コード例 #10
0
    def generate(self):
        rndm = random.random()
        if rndm > 0.67:
            map = Map(
                [Obstacle([400, 620], 80, 280),
                 Obstacle([880, 620], 80, 280)], [[200, 700]],
                [[random.randint(500, 700),
                  random.randint(350, 700)] if random.random() > 0.5 else
                 [random.randint(900, 1100),
                  random.randint(350, 700)], [400,
                                              random.randint(150, 400)],
                 [800, random.randint(150, 400)]])
        elif rndm > 0.33:
            map = Map(
                [Obstacle([400, 620], 80, 280),
                 Obstacle([880, 620], 80, 280)], [[600, 700]],
                [[random.randint(100, 300),
                  random.randint(350, 700)] if random.random() > 0.5 else
                 [random.randint(900, 1100),
                  random.randint(350, 700)], [400,
                                              random.randint(150, 400)],
                 [800, random.randint(150, 400)]])
        else:
            map = Map(
                [Obstacle([400, 620], 80, 280),
                 Obstacle([880, 620], 80, 280)], [[1080, 700]],
                [[random.randint(500, 700),
                  random.randint(350, 700)] if random.random() > 0.5 else
                 [random.randint(100, 300),
                  random.randint(350, 700)], [400,
                                              random.randint(150, 400)],
                 [800, random.randint(150, 400)]])

        return map
コード例 #11
0
ファイル: TwoFloors.py プロジェクト: nunolau/GeoFriends2-v2
    def generate(self):
        rndm = random.random()
        if rndm > 0.5:
            map = Map([Obstacle([200, 500], 320, 40), Obstacle([840, 500], 800, 40),
                       Obstacle([440, 260], 800, 40), Obstacle([1080, 260], 320, 40)],
                      [[200, 160] if random.random() > 0.5 else [1080, 160]],
                      [[1000, 100] if random.random() > 0.5 else [200, 100],
                       [1000, 380] if random.random() > 0.5 else [200, 380],
                       [1000, 600] if random.random() > 0.5 else [200, 600]])
        else:
            map = Map([Obstacle([200, 260], 320, 40), Obstacle([840, 260], 800, 40),
                       Obstacle([440, 500], 800, 40), Obstacle([1080, 500], 320, 40)],
                      [[200, 160] if random.random() > 0.5 else [1080, 160]],
                      [[1000, 100] if random.random() > 0.5 else [200, 100],
                       [1000, 380] if random.random() > 0.5 else [200, 380],
                       [1000, 600] if random.random() > 0.5 else [200, 600]])

        map.is_terminal = lambda positions: (any([pos[1] > 660 for pos in positions]) and len(map.rewards) > 0 and
                                             map.rewards[-1][1] < 500) or len(map.rewards) == 0

        return map
コード例 #12
0
ファイル: Floors.py プロジェクト: nunolau/GeoFriends2-v2
    def generate(self):
        rndm = random.random()
        if rndm > 0.67:
            map = Map(
                [Obstacle([320, 500], 560, 40),
                 Obstacle([960, 500], 560, 40)],
                [[200, 450] if random.random() > 0.5 else [1080, 450]],
                [[
                    random.randint(100, 600)
                    if random.random() > 0.5 else random.randint(700, 1100),
                    random.randint(300, 450)
                ],
                 [
                     random.randint(700, 1100)
                     if random.random() > 0.5 else random.randint(100, 600),
                     random.randint(600, 720)
                 ]])
            map.is_terminal = lambda positions: (
                any([pos[1] > 660 for pos in positions]) and len(map.rewards) >
                0 and map.rewards[-1][1] < 500) or len(map.rewards) == 0
        elif rndm > 0.33:
            map = Map(
                [Obstacle([320, 500], 560, 40),
                 Obstacle([960, 500], 560, 40)],
                [[200, 450] if random.random() > 0.5 else [1080, 450]],
                [[random.randint(100, 600),
                  random.randint(300, 450)],
                 [random.randint(700, 1100),
                  random.randint(300, 450)]])
            map.is_terminal = lambda positions: any(
                [pos[1] > 660 for pos in positions]) or len(map.rewards) == 0
        else:
            map = Map(
                [Obstacle([320, 500], 560, 40),
                 Obstacle([960, 500], 560, 40)],
                [[200, 450] if random.random() > 0.5 else [1080, 450]],
                [[random.randint(700, 1100),
                  random.randint(600, 750)]])

        return map
コード例 #13
0
 def get_obstacle_body(self):
     return [Obstacle(self.pos, self.rect_w, self.rect_h)]