I don’t know how familiar you are with coding in general, but Python is a scripted language, which means it needs to be run by another process like Windows PowerShell, Linux Bash, or Mac Terminal. The run_match.sh
(or run_match.ps1
for windows) script is actually not Python, it is a bash program that starts the game engine. It is a program that is designed to run on the respective operating system, which is why there is two versions of this file and why you only run a single one for your program. You only call the one that your operating system can run (for Mac run.sh
).
If you look inside the run_match
file you will see that it looks nothing like python, because it isn’t! The commands are things you could type into your Terminal (Mac) or PowerShell (Windows).
Looking at the run_match.sh
there is the last line:
java -jar engine.jar work ${algo1}/run.sh ${algo2}/run.sh
This is what actually starts the local engine where ${algo1)
and ${algo2}
are just variables for the arguments you passed to the program. So if you ran scripts/run.sh algos/cool-algo algos/cooler-algo
then ${algo1)
is algos/cool-algo and ${algo2}
is algos/cooler-algo. In the argument it calls /run.sh
. Then the java engine handles starting the Python programs you have written by starting those run.sh
files.
So finally, we get to the Python! As I said before, Python is scripted, so it has to be run from the Terminal/PowerShell. That is all the run.sh
and run.ps1
file does. It calls your python script that starts your algo, in this case algo_strategy.py
and if you look inside run you will see that file.
The key is that you could simply run any Python program by typing into your Terminal python [PROGRAM].py
. However, if you did this with algo_strategy.py
it would fail (I don’t know if it would crash, but it wouldn’t work) becuase the script requires information from the Java engine to work properly. This is why you call the run_match.sh
instead of just calling Python by itself, the Java engine starts the Python for you.
This is why the command should be scripts/run.sh algos/starter-algo algos/starter-algo
instead of just calling python like what you may see in tutorials online.
This was probably way more than what you were asking for but I hope it was helpful, just ask if you have any other questions about something I said.