Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve "sticky_actions" when executing the game with built-in AIs #42

Closed
alexander3605 opened this issue Jul 11, 2019 · 5 comments

Comments

@alexander3605
Copy link

Hi @zajaczajac
Thank you for the reply on #40 , that worked.

Now, I am trying to extract some information about the players, specifically the sticky_actions.
If I run the command you suggested above MESA_GL_VERSION_OVERRIDE=3.2 MESA_GLSL_VERSION_OVERRIDE=150 python3 -m gfootball.play_game --home_players= --away_players= the game works but no information about the players actions is exposed (not even internally in the source code, from what I can see) since there is no active player in any team.

How can I specify the built-in AI in the --home_team= and --away_team= arguments when I run the game?

@michalzajac-ml
Copy link

Built-in AI (who plays when you specify empty string as a player) does not get "observations" in the usual sense and does not use "actions". So you cannot extract that.
However if you specify any other player, like "bot" (for this you need fix from #40), then you can extract that information.
Does it answer your question?

@alexander3605
Copy link
Author

alexander3605 commented Jul 11, 2019

Ok, I see. Thanks for your reply

What I am trying to do is extract clips from the game, together with a log of the actions that the players are executing (those defined as sticky but also the others).

For what concerns the clips generation I have successfully extracted them by taking the frame from here

frame = self._env.get_frame()

On the other hand, I have seen that by adding sticky=True to the definitions of the CoreActions, strating here

core_action_idle = CoreAction(e_BackendAction.idle, "idle")

I should be able to expose "non-sticky actions" via the observation struct.

What I am wondering now is whether the game played by bots is varied enough or whether it will give often similar games.

@michalzajac-ml
Copy link

Some of the possible actions are sticky, which means that they can be active for some time after execution (e.g. until cancellation) - such an action is for example game_left. See also README. So I guess you don't want to change some actions to being or not being sticky.

What you could do to register actions, is to inject some code to FootballEnv, where is the code to gather the actions and get observations; see here: https://github.com/google-research/football/blob/master/gfootball/env/football_env.py#L122

As for the last question, the game itself is not deterministic in the standard scenarios, so you would get some variation from there; however bots (defined in bot.py) are very simple and deterministic. You can see for yourself by using play_game script with bots players as bot and watching some games.

@michalzajac-ml
Copy link

michalzajac-ml commented Jul 18, 2019

Actually, I should've mentioned one more thing. When you run play_game script, dumps are written after episodes (these are pickled observations, debug info etc).
When you unpickle such a file, for every timestep you have a dictionary d, and in it you can access d['debug']['action'].
By default, dumps are written to tmp/dumps.

@qstanczyk
Copy link
Collaborator

Marking this issues as closed, please reopen if some more clarification / followup is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants