automatically quit and start a game via GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ben Nicholl

I am creating a soccer game, and I am trying to collect data on the position of the players, opponent players, orientation, etc in order to utilize machine learning to create intelligent opposing players. I would like to be able to have to AI players compete, collect data associated with those players, then have the game restart when event happens, such as a goal being scored. Is there a way to stop and then start a game using GDScript?

:bust_in_silhouette: Reply From: jgodfrey

You can certainly quit from your game via gdscript. That’s as simple as calling:

get_tree().quit()

However, the process can’t really restart itself once it has exited. For that, I’d recommend an external “driver” process that simply restarts the game each time it exits (likely in a simple loop).

The details of how you’d do that will vary based on the underlying OS, but I’d think a simple batch file on Windows or a shell script on a Unix system would suffice.

Do you know how you would open a Godot file from the command line? I’m assuming then I’d just run command b to run the game

Ben Nicholl | 2020-07-10 21:41

NVM, I think I found it

Ben Nicholl | 2020-07-10 21:51

I’m having trouble figuring out exactly how to play the actualyl game from the command line. I can open the project, but there doesn’t seem to be a way to interact with the project once opened

Ben Nicholl | 2020-07-10 22:30