Exemple #1
0
 def check_done(self, obs):
     dones = []
     for timestep in obs:
         scores = timestep.observation.score.score_details
         # print('mineral: ', scores.collection_rate_minerals)
         # print('vespene: ', scores.collection_rate_vespene)
         if scores.collection_rate_minerals < 1.0 and \
             scores.collection_rate_vespene < 1.0:
             units = timestep.observation.raw_data.units
             my_units = collect_units_by_alliance(units,
                                                  AllianceType.SELF.value)
             my_bases = collect_units_by_types(my_units, [
                 UNIT_TYPEID.ZERG_HATCHERY.value,
                 UNIT_TYPEID.ZERG_LAIR.value, UNIT_TYPEID.ZERG_HIVE.value
             ])
             my_larvas = collect_units_by_types(
                 my_units, [UNIT_TYPEID.ZERG_LARVA.value])
             my_drones = collect_units_by_types(my_units, [
                 UNIT_TYPEID.ZERG_DRONE.value,
                 UNIT_TYPEID.ZERG_DRONEBURROWED.value
             ])
             my_minerals = timestep.observation.player_common.minerals
             if len(my_bases) == 0 and len(my_drones) == 0 and len(
                     my_larvas) == 0:
                 dones.append(True)
             elif len(my_bases) == 0 and my_minerals < 300:
                 dones.append(True)
             elif len(my_bases) > 0 and len(
                     my_drones) == 0 and my_minerals < 50:
                 dones.append(True)
             else:
                 dones.append(False)
         else:
             dones.append(False)
     return dones
Exemple #2
0
 def check_done(self, obs):
     dones = []
     if len(obs) == 2:
         for timestep in obs:
             units = timestep.observation.raw_data.units
             my_units = collect_units_by_alliance(units,
                                                  AllianceType.SELF.value)
             dones.append(len(my_units) == 0)
     else:
         timestep = obs[0]
         units = timestep.observation.raw_data.units
         my_units = collect_units_by_alliance(units,
                                              AllianceType.SELF.value)
         enemy_units = collect_units_by_alliance(units,
                                                 AllianceType.ENEMY.value)
         lose = len(my_units) == 0
         win = len(enemy_units) == 0
         dones.append(lose)
         dones.append(win)
     return dones
Exemple #3
0
    def compute_dense_reward(self, last_obs, obs):
        if len(obs) == 2:
            return 0
        else:
            last_timestep = last_obs[0]
            timestep = obs[0]
            last_units = last_timestep.observation.raw_data.units
            units = timestep.observation.raw_data.units
            last_my_units = collect_units_by_alliance(last_units,
                                                      AllianceType.SELF.value)
            my_units = collect_units_by_alliance(units,
                                                 AllianceType.SELF.value)
            last_enemy_units = collect_units_by_alliance(
                last_units, AllianceType.ENEMY.value)
            enemy_units = collect_units_by_alliance(units,
                                                    AllianceType.ENEMY.value)

            rwd = 0
            rwd += len(my_units) - len(last_my_units)
            rwd += len(last_enemy_units) - len(enemy_units)
            rwd *= 0.1
            return rwd