コード例 #1
0
ファイル: env.py プロジェクト: VenkatKS/ParallelEnvironment
 def __init__(self, width=10, height=10, num_agents=2):
     super(RandomRewardGridEnv, self).__init__()
     self.map = GridMap(width=10, height=10)
     self.agents = list()
     for i in range(num_agents):
         self.agents.append(Agent(active_map=self.map))
         self.map.registerAgent(self.agents[-1])
     Log.warning("New env created with %d agents" % (len(self.agents)))
コード例 #2
0
 def mul_shard(self, each_shard):
     shard_info = {}
     i_parten = '%s/[0-9]{3}/[0-9]{4,5}$' % self.etcd_root
     if re.search(i_parten, str(each_shard['key'])):
         Log.debug('All shard info %s' % each_shard)
         shard_url = path.join(self.etcd_host, 'v2/keys',
                               str(each_shard['key']).strip('/'))
         info_get = ['merge_rel', 'gm/private_ip']
         try:
             for i in info_get:
                 rst_each = json.loads(
                     requests.get(path.join(shard_url, i)).content)
                 shard_info[i] = rst_each['node']['value']
         except KeyError:
             shard_info.clear()
             Log.warning('No such key %s' % rst_each)
         return shard_info
コード例 #3
0
def warn(str):
    Log.warning(str[:-1])
    sys.stdout.write(str)
    sys.stdout.flush()