facebookresearch/ELF

[Questions:] Is it possible to stop a single game[batchsize>1] before it's ended?

DengpanFu opened this issue · 3 comments

For miniRTS game, we can train agents with A3C, then a batch of games will be run in parallel at the same time, e.g. we can set batchsize=128, then a CollectorGroup will contain 128 games' state and infos(according to train_minirts.sh script), and we can get game ids through batch['id'].

in my current project, i need to stop a game early when it meets certain conditions, i also noted that if one of the 128 games in a batch is ended(win/fail or reach the max_ticks), then that game thread will be released and another game will start, and the new game will be added to the CollectorGroup.

I wonder if it is possible to set a terminate flag to a specified game(identified by game id) in Python side, and then the game engine will stop and release the corresponding game? if it's possible, could you please give me some advice? Thanks.

@DengpanFu currently you can send such messages as one of the replies to C++ side. Once C++ side sees the flag, it can terminate the game and restart a new one.

For how to use reply, you can check how the action is going back from Python side to C++ side (in MiniRTS and Atari games).

Thanks for your replies, i'm studying how message flows. Now, i found that there's a flag _terminated and some functions(like SetTermination(), GetTermination() ) use this flag in rts/engine/game_env.h, is this the exact flag i had to deal with in C++ side? Thanks.