Last active
May 20, 2021 16:49
-
-
Save ashwanirathee/f52cfac73b98c6100c5e212f903f1cf7 to your computer and use it in GitHub Desktop.
MineCraft Game in Julia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions to get something running of Malmo | |
# In terminal 1 and a particular environment | |
# 1) Do `pip3 install gym lxml numpy pillow` | |
# 2) Do `git clone https://github.com/Microsoft/malmo.git` | |
# 3) Go to `cd malmo/MalmoEnv` | |
# 4) Do `(echo -n "malmomod.version=" && cat ../VERSION) > ./src/main/resources/version.properties` | |
# 5) Then run this file `julia run.jl` | |
# In terminal 2 | |
# 1) Do `cd malmo/Minecraft` | |
# 2) Do `./launchClient.sh -port 9000 -env` | |
using PyCall | |
using ReinforcementLearning | |
@pyimport malmoenv | |
f = open("missions/mobchase_single_agent.xml", "r") | |
xml = read(f, String) | |
println(xml) | |
env = malmoenv.make() | |
env.init(xml, 9000,server="127.0.0.1",server2="127.0.0.1", port2=9000,role=0,exp_uid="test1", episode=0, resync=0) | |
episodemaxsteps = 0 | |
for i in 1:10 | |
println("reset " * string(i)) | |
obs = env.reset() | |
steps = 0 | |
done = false | |
while done ==false && (episodemaxsteps <= 0 || steps < episodemaxsteps) | |
action = env.action_space.sample() | |
obs, reward, done, info = env.step(action) | |
steps += 1 | |
println("reward: ", string(reward)) | |
# println("done: " , string(done)) | |
println("obs: ", string(obs)) | |
println("info", info) | |
sleep(.05) | |
end | |
end | |
env.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment