minerl
minerl copied to clipboard
Added chat action (and commands) in v1.0.0
This change modifies EnvServer.java
to accept a "chat" commad, and adds chat.py from the dev branch so we have H.ChatAction()
. It also enables commands (cheats).
Implemented because I've been watching the OpenAI agents and sometimes I want to help them out when they get stuck.
To use this, just put
actions['chat'] = 'thing to say'
and for example, modify minerl\herobraine\env_specs\human_controls.py
HumanControlEnvSpec
create_actionables to have
] + [H.CameraAction()] + [H.ChatAction()]
instead of
] + [H.CameraAction()]
on line 70. Note if you are using the VideoPreTraining you'll also need to modify the code in VideoPreTraining agent.py
validate_env
(I just comment it out) and then you'll be able to run commands and chat.
Because this also enables cheats you can do something like
actions['chat'] = '/give @p diamond 3'
To give the agent 3 diamond.
For example, in order to call actions in VideoPreTraining run_agent.py
I just did this hacky thing
if os.path.isfile("command.txt"):
f = open("command.txt", "r")
minerl_action['chat'] = f.read()
f.close()
os.remove("command.txt")
inserted after this
while True:
minerl_action = agent.get_action(obs)
then I can put my command in command.txt and then copy it into the running directory. There's definitely a better way to do this (like hosting a http server) but this works good enough if you just want to be watching AI lets plays.
By the way, if you want to enable peaceful mode to give the agents a easier time, just modify line 2241 of scripts\mcp_patch.diff
, this line:
+ WorldSettings worldSettings = new WorldSettings(worldName, GameType.SURVIVAL, false, Difficulty.HARD, true, new GameRules(), DatapackCodec.VANILLA_CODEC);
to
+ WorldSettings worldSettings = new WorldSettings(worldName, GameType.SURVIVAL, false, Difficulty.PEACEFUL, true, new GameRules(), DatapackCodec.VANILLA_CODEC);
Hello @Phylliida! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Line 7:80: E501 line too long (82 > 79 characters) Line 8:80: E501 line too long (84 > 79 characters) Line 8:85: W291 trailing whitespace Line 9:1: E302 expected 2 blank lines, found 1 Line 13:47: W291 trailing whitespace Line 43:18: W292 no newline at end of file
Comment last updated at 2022-09-10 11:46:29 UTC
Hey! Thanks for this amazing (and quick!) PR :). Great to see people contributing back like this!
I will hold off the merge on this for now: this command would go against the BASALT competition rules, and we do not want to give the wrong impression to participants by providing tools they are not supposed to use the competition. We could have two branches, but that too could be confusing. I am open for suggestions on how to handle this situation, though.
(sidenote, but check out the tests/test_human_interactor.py
:) . This too might be useful for poking agent to the right direction.)
Oh, one more small request: if you could add a minimal "test" script (not actual unit-test, just a file like other tests under tests
which do a minimal interaction loop to demonstrate something), that would be nice :)