myt1996 / gym-fightingice Goto Github PK
View Code? Open in Web Editor NEWOfficial gym API for game FightingICE.
Official gym API for game FightingICE.
Hi FightingICE team!
I'm trying to set the argument "--disable-window" to accelerate my training process but the program stuck eventually.
In Ubuntu 18.04.5, the program stuck about 100s~400s rounds.
py4j, port_for==0.10.4, gym, opencv-python
(I noticed that there is py4j package in FTG4.50/python folder and its version is 0.10.4, so I assume to use 0.10.4 instead of the latest version. However, then I update the package to 0.10.9.2, it still stuck.)example.py:
import gym
import gym_fightingice
env = gym.make("FightingiceDataNoFrameskip-v0", java_env_path="correct/path/to/FTG4.50", opponent="DiceAI")
while True:
obs = env.reset()
done = False
while not done:
action = env.action_space.sample()
observation, reward, done, info = env.step(action=action)
Inside fightingice_env_data_noframeskip.py:
114: self.java_env = subprocess.Popen(["java", "-cp", self.start_up_str, "Main", "--port", str(self.port), "--py4j", "--fastmode",
115: "--grey-bg", "--inverted-player", "1", "--mute", "--limithp", "400", "400", "--disable-window"])
Java version:
Command: java -version
:
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
Python version:
Command: python --version
:
Python 3.6.11
I use print to check where the program stuck, and "obs received" never print at the end of the error message below:
# ... inside reset() function in class gym_fightingice.envs.FightingiceEnv_Data_NoFrameskip
190: self.pipe.send("reset")
191: self.round_num += 1
192: print("about to recv obs")
193: obs = self.pipe.recv() # <--- Gets stuck here
194: print("obs received")
195: return obs
<class 'numpy.ndarray'>
send round end to <multiprocessing.connection.Connection object at 0x7f02c970cb38>
round: 424 2021-03-08 16:38:35.505011
0
125
2409
Mar 08, 2021 4:38:35 PM gamescene.Play update
INFO: Game over
Exception in thread "main" py4j.Py4JException: Error while sending a command.
at py4j.CallbackClient.sendCommand(CallbackClient.java:357)
at py4j.CallbackClient.sendCommand(CallbackClient.java:316)
at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:103)
at com.sun.proxy.$Proxy0.close(Unknown Source)
at aiinterface.AIController.gameEnd(AIController.java:224)
at manager.InputManager.closeAI(InputManager.java:245)
at gamescene.Play.close(Play.java:384)
at manager.GameManager.update(GameManager.java:57)
at manager.DisplayManager.gameLoop(DisplayManager.java:166)
at manager.DisplayManager.start(DisplayManager.java:53)
at Main.main(Main.java:22)
Caused by: py4j.Py4JNetworkException
at py4j.CallbackConnection.sendCommand(CallbackConnection.java:138)
at py4j.CallbackClient.sendCommand(CallbackClient.java:344)
... 10 more
Start java env in . and port 24807
ERROR:root:Exception while sending command.
Traceback (most recent call last):
File "/home/user/Apps/miniconda3/envs/drl/lib/python3.6/site-packages/py4j/java_gateway.py", line 1035, in send_command
raise Py4JNetworkError("Answer from Java side is empty")
py4j.protocol.Py4JNetworkError: Answer from Java side is empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/Apps/miniconda3/envs/drl/lib/python3.6/site-packages/py4j/java_gateway.py", line 883, in send_command
response = connection.send_command(command)
File "/home/user/Apps/miniconda3/envs/drl/lib/python3.6/site-packages/py4j/java_gateway.py", line 1040, in send_command
"Error while receiving", e, proto.ERROR_ON_RECEIVE)
py4j.protocol.Py4JNetworkError: Error while receiving
Please IGNORE the Exception above because of restart java game
Mar 08, 2021 4:38:39 PM manager.InputManager <init>
INFO: Create instance: manager.InputManager
Mar 08, 2021 4:38:39 PM manager.DisplayManager initialize
INFO: Disable window mode
Mar 08, 2021 4:38:39 PM manager.GraphicManager <init>
INFO: Create instance: manager.GraphicManager
Mar 08, 2021 4:38:39 PM loader.ResourceLoader <init>
INFO: Create instance: loader.ResourceLoader
Python
about to recv obs
Mar 08, 2021 4:38:41 PM gamescene.Launcher update
INFO: Transition to PLAY
Mar 08, 2021 4:38:41 PM util.LogWriter <init>
INFO: Create instance: util.LogWriter
Mar 08, 2021 4:38:41 PM aiinterface.AIController run
INFO: Start to run
Mar 08, 2021 4:38:41 PM aiinterface.AIController run
INFO: Start to run
Thank you all for your help!!
Hello FightingICE team!
I am getting a problem trying to reset()
any of the FightingIce*
environments. That is, any of the following:
['FightingiceDataNoFrameskip-v0', 'FightingiceDataFrameskip-v0', 'FightingiceDisplayNoFrameskip-v0', 'FightingiceDisplayFrameskip-v0']
I describe the issue below, together with an initial debugging analysis.
I have (unfortunately) replicated this issue in two different machines, one running ArchLinux and the other running Mint 19 (Ubuntu based).
Setup:
py4j, port_for, gym, opencv-python
FTG4.40
from Ritsumei's websiteReproducing the issue:
The following 4 lines of python code cause the issue to arise
import gym_fightingice
import gym
env = gym.make('FightingiceDataNoFrameskip-v0',
java_env_path='correct/path/to/FTG4.40')
env.reset()
The call to env.reset()
never returns. The window displaying the Java running game is stuck at "Now loading..." (picture below).
The issue seems to be cause by the fact that function gym_fightingice.envs.FightingiceEnv_Data_NoFrameskip.reset()
gets stuck waiting for an observation from one of the agents:
# ... inside reset() function in class gym_fightingice.envs.FightingiceEnv_Data_NoFrameskip
190: self.pipe.send("reset")
191: self.round_num += 1
192: obs = self.pipe.recv() # <--- Gets stuck here
193: return obs
Line 192 of that function is waiting for the player 1 (stored in self.p1
) to send an observation to the environment via it's pipe (self.p1.pipe.send(...)
) so that the environment can receive it (line 192: self.pipe.recv()
) and return it as the return statement of the reset()
function.
The script hangs in line 192 because player 1, of class gym_fightingice.envs.gym_ai.GymAI
. Player 1 is never initialized (function GymAI.initialize()
) is never called. Furthermore, the GymAI.processing()
function is never called either. It is in this last function that the player processes the "reset"
request from the environment, and then sends the observations over to the environment. This behaviour is defined in lines:
# ... inside processing() function in class gym_fightingice.envs.GymAI
# This function is never called, and hence the environment hangs
79: request = self.pipe.recv()
80: if request == "reset":
81: self.just_inited = False
82: self.obs = self.get_obs()
83: self.pipe.send(self.obs)
Extra information:
My Java version:
Command: java -version
:
Output:
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b05)
OpenJDK 64-Bit Server VM (build 25.222-b05, mixed mode)
My Python version:
Command: python --version
:
Output: Python 3.6.6
Is this a known error? How can I ensure that the required functions are called so that the environment's pipe receives an observation that can return, so that it doesn't hang indefinitely?
Thank you very much for your time and your help. I am more than willing to help on solving this issue and contributing to your codebase!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.