Skip to content

Commit a314cc4

Browse files
authored
Merge pull request #238 from GianiStatie/main
minor updates to godot-env
2 parents 97d850c + 03b8989 commit a314cc4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

godot_rl/core/godot_env.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(
6666
print("No game binary has been provided, please press PLAY in the Godot editor")
6767

6868
self.port = port
69+
self.host_binding = kwargs.get("host_binding", False)
6970
self.connection = self._start_server()
7071
self.num_envs = None
7172
self._handshake()
@@ -304,21 +305,23 @@ def _launch_env(
304305
# --fixed-fps {framerate}
305306
path = convert_macos_path(env_path) if platform == "darwin" else env_path
306307

307-
launch_cmd = f"{path} --port={port} --env_seed={seed}"
308+
launch_cmd = [path]
309+
launch_cmd.append(f"--port={port}")
310+
launch_cmd.append(f"--env_seed={seed}")
308311

309312
if show_window is False:
310-
launch_cmd += " --disable-render-loop --headless"
313+
launch_cmd.append("--disable-render-loop")
314+
launch_cmd.append("--headless")
311315
if framerate is not None:
312-
launch_cmd += f" --fixed-fps {framerate}"
316+
launch_cmd.append(f"--fixed-fps {framerate}")
313317
if action_repeat is not None:
314-
launch_cmd += f" --action_repeat={action_repeat}"
318+
launch_cmd.append(f"--action_repeat={action_repeat}")
315319
if speedup is not None:
316-
launch_cmd += f" --speedup={speedup}"
320+
launch_cmd.append(f"--speedup={speedup}")
317321
if len(kwargs) > 0:
318322
for key, value in kwargs.items():
319-
launch_cmd += f" --{key}={value}"
323+
launch_cmd.append(f"--{key}={value}")
320324

321-
launch_cmd = launch_cmd.split(" ")
322325
self.proc = subprocess.Popen(
323326
launch_cmd,
324327
start_new_session=True,
@@ -334,7 +337,8 @@ def _start_server(self):
334337
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
335338

336339
# Bind the socket to the port, "localhost" was not working on windows VM, had to use the IP
337-
server_address = ("127.0.0.1", self.port)
340+
address = "0.0.0.0" if self.host_binding else "127.0.0.1"
341+
server_address = (address, self.port)
338342
sock.bind(server_address)
339343

340344
# Listen for incoming connections

0 commit comments

Comments
 (0)