Skip to content
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

Documentation of Python GGP Player Example in src_py #53

Open
hobson opened this issue Apr 19, 2014 · 3 comments
Open

Documentation of Python GGP Player Example in src_py #53

hobson opened this issue Apr 19, 2014 · 3 comments

Comments

@hobson
Copy link

hobson commented Apr 19, 2014

import org.ggp... statements in src_py fail. Jython or other packages/interpretters besides python 2.7 must be required.

Documentation of the steps involved in compiling/running a python game player would be an awesome addition.

In [1]: %run sample_gamer.py
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    202             else:
    203                 filename = fname
--> 204             __builtin__.execfile(filename, *where)

/home/hobs/src/ggp-base/src_py/sample_gamer.py in <module>()
      5 import random
      6 
----> 7 from org.ggp.base.util.statemachine import MachineState
      8 from org.ggp.base.util.statemachine.implementation.prover import ProverStateMachine
      9 from org.ggp.base.player.gamer.statemachine import StateMachineGamer

ImportError: No module named org.ggp.base.util.statemachine
@samschreiber
Copy link
Member

sample_gamer.py isn't intended to the run on its own.

To use a Python-based player, you should bring up Eclipse, open GGP Base as an ordinary Java project, and run the Java apps (like Server, Player, and Kiosk) as though you were using a Java-based player. Through the magic of a Jython-based translation layer, your Python-based players should be visible as options alongside the Java-based players. When you add new Python-based players you'll have to add a stub class, similar to SamplePythonGamerStub, to let the Jython-based intermediate layer know which Python modules to look for. There's also a "PythonConsole" app which lets you interact with GGP objects (like the state machine, game repository, etc) from Python.

@hobson
Copy link
Author

hobson commented Apr 20, 2014

Excellent. Sounds like a very flexible architecture. Thank you very much.
I'll do that and then see if I can figure out how to do it without eclipse
and then share those steps as well.
On Apr 20, 2014 10:48 AM, "Sam Schreiber" [email protected] wrote:

sample_gamer.py isn't intended to the run on its own.

To use a Python-based player, you should bring up Eclipse, open GGP Base
as an ordinary Java project, and run the Java apps (like Server, Player,
and Kiosk) as though you were using a Java-based player. Through the magic
of a Jython-based translation layer, your Python-based players should be
visible as options alongside the Java-based players. When you add new
Python-based players you'll have to add a stub class, similar to
SamplePythonGamerStub, to let the Jython-based intermediate layer know
which Python modules to look for. There's also a "PythonConsole" app which
lets you interact with GGP objects (like the state machine, game
repository, etc) from Python.

Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-40900422
.

@AlexLandau
Copy link
Member

The newest versions of GGP-Base include Gradle support for running applications without using Eclipse. You can run the aforementioned applications with the following commands (use gradlew.bat instead if on Windows):

./gradlew server
./gradlew player
./gradlew kiosk
./gradlew pythonConsole

Apps run through Gradle will include anything in the src/main/resources folder in the classpath. If you're using the very latest version of the code, you'll need to move any files or folders you added to the src_py (or src_clj) folders to src/main/resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants