Closed doganjr closed 4 years ago
Hi, glad to know that it is running as intended. This seems to be an issue related to #1, Unfortunately I don’t have a mac so I couldn’t test it out. Were you able to get the video recording working by any chance?
For example, try going to experiment folder and run python ppo.py --capture-video
After some dependencies have been installed and run "python3 ppo.py --capture-video" I got some error like that:
(base) doganjr:experiments doganjr$ python3 ppo.py --capture-video
/Users/doganjr/microrts/maps/10x10/basesWorkers10x10.xml
[Lai.rewardfunction.RewardFunctionInterface;@1b68ddbd
/Users/doganjr/microrts/maps/10x10/basesWorkers10x10.xml
[Lai.rewardfunction.RewardFunctionInterface;@59e5ddf
/Users/doganjr/microrts/maps/10x10/basesWorkers10x10.xml
[Lai.rewardfunction.RewardFunctionInterface;@536aaa8d
/Users/doganjr/microrts/maps/10x10/basesWorkers10x10.xml
[Lai.rewardfunction.RewardFunctionInterface;@e320068
Unknown encoder 'libx264'
Traceback (most recent call last):
File "ppo.py", line 292, in
Hmmm that seems to suggest the rendering is not working at all. What’s your jdk/jre version? May be the default one does not come with the graphical packages. See https://stackoverflow.com/questions/32862344/what-is-the-difference-between-openjdk-7-jre-headless-and-openjdk-7-jrejdk
Another thing that you can look into is to see whether you can build microrts by following instructions here https://github.com/santiontanon/microrts/blob/master/README.md
By running hello_world.py, above is what I get. It can be seen that states can be observed without any problem. Unlike the demo.gif you provided nothing pops up. :/
I have installed the newest versions of JDK and JRE but unfortunately, nothing has changed.
Could you try running
import gym
import gym_microrts
import time
try:
env = gym.make("MicrortsGlobalAgentRandomEnemy10x10FrameSkip9-v0")
env.action_space.seed(0)
env.reset()
for i in range(10000):
print(env.render(mode="rgb_array"))
time.sleep(0.2)
obs = env.step(env.action_space.sample())
if env.step(env.action_space.sample())[2]:
print("done")
break
#env.close()
except Exception as e:
print(e)
print(e.stacktrace())
and see if the RGB pixels can be retrieved?
Btw your error above has Unknown encoder 'libx264'
, which can be fixed (see https://stackoverflow.com/questions/9764740/unknown-encoder-libx264)
I have run the script and get the output that you had on your console. But still no rendering. Here is one interesting fact, even I change the environment(gym.make(change)) it always prints out to console following: "/Users/doganjr/microrts/maps/4x4/baseTwoWorkersMaxResources4x4.xml [Lai.rewardfunction.RewardFunctionInterface;@2f410acf" Is it expected or do you think I have installed the wrapper somehow unproperly?
That is expected.
Get Outlook for iOShttps://aka.ms/o0ukef
From: Dogan Can Cicek notifications@github.com Sent: Thursday, July 9, 2020 2:57:50 AM To: vwxyzjn/gym-microrts gym-microrts@noreply.github.com Cc: Costa Huang costa.huang@outlook.com; Comment comment@noreply.github.com Subject: Re: [vwxyzjn/gym-microrts] environment works well but not rendering (#3)
I have run the script and get the output that you had on your console. But still no rendering. Here is one interesting fact, even I change the environment(gym.make(change)) it always prints out to console following: "/Users/doganjr/microrts/maps/4x4/baseTwoWorkersMaxResources4x4.xml [Lai.rewardfunction.RewardFunctionInterface;@2f410acf" Is it expected or do you think I have installed the wrapper somehow unproperly?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/vwxyzjn/gym-microrts/issues/3#issuecomment-655939622, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABKMJE356ZIDZAVYALTOBVTR2VS65ANCNFSM4OU3NLTA.
Hello, I have followed instructions from https://github.com/santiontanon/microrts/blob/master/README.md and when I run FrontEnd.java environment popped up without a problem, I also have created a .jar file by following instructions and run it without a problem, too. But when I try to run the latest version of microrts.jar from console it gives an error as follows:
(base) doganjr:microrts doganjr$ java -cp microrts.jar rts.MicroRTS
Exception in thread "main" java.io.FileNotFoundException: resources/config.properties (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:212)
at java.base/java.io.FileInputStream.
After I have added imshow and show, I am able to catch Game State Visualizer from your demo.gif but it is still not observable. Maybe the problem is mainly about matplotlib part of the wrapper but I am not completely sure.
Try the following as a work around, which should give you a recorded video in the video
folder.
import gym
import gym_microrts
import time
from gym.wrappers import TimeLimit, Monitor
try:
env = gym.make("MicrortsGlobalAgentRandomEnemy10x10FrameSkip9-v0")
env = Monitor(env, f'videos')
env.action_space.seed(0)
env.reset()
for i in range(10000):
time.sleep(0.2)
obs = env.step(env.action_space.sample())
next_obs, reward, done, info = env.step(env.action_space.sample())
if done:
print("done")
break
#env.close()
except Exception as e:
print(e)
print(e.stacktrace())
With respect to the game visualizer, try the following command
cd ~/microrts
java -classpath microrts.jar tests.PlayGameWithMouseTest
and see if the game visualizer pops up. If so, it would appear to be a jPype problem. It is quite difficult for me to help with this bug since I do not have a mac unfortunately :(.
For a lack of response, closing this issue for now.
Very well implemented wrapper but I cannot render the environment when I run hello_world.py, it does not produce any errors, environment returns observations. I am running the wrapper on macOS and It renders openai gym environments when I call render() in the loop.