-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a new python game #1204
Comments
That is unexpected. How did you install OpenSpiel? Looks like it was built from source..? (If so, can you point out the commands you used to install + build)? Either way they should be included. Note that they should all start with the Can you post the complete list of games that are shown when you run that command?
Hmm, probably not.. you can do it manually or use the MCTS example linked below. The first thing I recommend is the OpenSpiel tutorial video. This will give you an overview of the API which is critical. Then you can play with your game in the same way as I do in the video (via the Python interpreter), which is quite close to the ConsolePlayTest. There is the python MCTS example which allows you to play from the keyboard. If you run that with both players set to |
First of all, Thank you for the tip about Since my last issue I managed to create and run a template C++ game, but python games are still a work in progress... here are the commands I used:
Where only the following tests fail:
Note: Ignore test In terms of the missing games, here's the complete list of games you asked for:
I've noticed something similar in colab, when after installing openspiel, if I import only Additional details:
|
Ok perfect, thanks for all the info, I think I understand what is going on. First: The Second: you cannot load a Python game from a C++ binary, which is what you're trying to do above. When running a C++ binary stand-alone, the Python games do not show up. The Python games only show up when you You should now set your PYTHONPATH (step 5 here) so your Python interpreter knows where to find OpenSpiel, and then start python and try this:
You should see the python games. A similar example as the C++ one above is available in Python: If, then, you see the other games but not your Python game, it's likely because you have to add it to the init file here. Hope this helps. Please let us know if you have any other questions. |
Thank you for your replies, and sorry for the inconvenience :( However, I still haven't managed to resolve the issue. In fact, I began following your nice tutorial once again and found the same thing on Colab. Running
records 102 registered games, but when running an additional code block
there are now 109 registered games, with the following having been excluded before:
Since Google Colab is running on a separate kernel, I assume there must be some wider issue I'm missing. Recapthe latest installation-and-build procedure was the following:
locally, I get 101 games when running
When adding Update:
|
Hi @Brunozml, Great. There are simple explanations for all of this. It's not nearly as complicated as it seems, I promise :) The colab version install OpenSpiel v1.4 from PyPI which is back-dated to Nov 16th, 2023. There have been games added since then, so when you build from master you see the new ones (e.g.
Yes, it seems like importing pyspiel is not enough: you need to also
That's right, and this is expected because that example is compiled from a C++ file. I explained in my response from last night:
You will not be able to use a Python game from a C++-compiled binary ( Hope this helps! |
No, unfortunately you really can't load a Python game from a C++ binary right now. Technically it would be possible to support that.. but you'd have to launch a Python interpreter from C++ and run it as a subprocess. It's quite awkward/clunky to do that and it's also be error-prone, so currently we only support loading Python games if you are already running from Python. This is not a big problem because most of the algorithms also have Python versions too. Many of the examples are also available in python here: https://github.com/google-deepmind/open_spiel/tree/master/open_spiel/python/examples |
Dear @lanctot, I have now managed to begin developing and testing my game implementation in python, all thanks to your help. I expect to propose a commit soon! |
it is unclear to me how to translate some of the documentation instructions on Adding a game for python. Specifically, when I try rebuild the example (step 6) by running
build/examples/example --game=my_game.
,I get the following error
Which does not list any of the python games. What am I missing here?
I also long for testing the game interactively as I build it (as in step 8). Can I use
ConolePlayTest
for python games? I haven't achieved so so far.The text was updated successfully, but these errors were encountered: