in coinrun/coinrunenv.py [0:0]
def init_args_and_threads(cpu_count=4,
monitor_csv_policy='all',
rand_seed=None):
"""
Perform one-time global init for the CoinRun library. This must be called
before creating an instance of CoinRunVecEnv. You should not
call this multiple times from the same process.
"""
os.environ['COINRUN_RESOURCES_PATH'] = os.path.join(SCRIPT_DIR, 'assets')
is_high_difficulty = Config.HIGH_DIFFICULTY
if rand_seed is None:
rand_seed = random.SystemRandom().randint(0, 1000000000)
# ensure different MPI processes get different seeds (just in case SystemRandom implementation is poor)
mpi_rank, mpi_size = mpi_util.get_local_rank_size(MPI.COMM_WORLD)
rand_seed = rand_seed - rand_seed % mpi_size + mpi_rank
int_args = np.array([int(is_high_difficulty), Config.NUM_LEVELS, int(Config.PAINT_VEL_INFO), Config.USE_DATA_AUGMENTATION, game_versions[Config.GAME_TYPE], Config.SET_SEED, rand_seed]).astype(np.int32)
lib.initialize_args(int_args)
lib.initialize_set_monitor_dir(logger.get_dir().encode('utf-8'), {'off': 0, 'first_env': 1, 'all': 2}[monitor_csv_policy])
global already_inited
if already_inited:
return
lib.init(cpu_count)
already_inited = True