-
Notifications
You must be signed in to change notification settings - Fork 48
How to test
This page explains
- Quick set up with/without an IDE.
- How to run a sample Python or Java client with / without an IDE.
- How to run your Python or Java client with / without an IDE.
- Legal arguments / Advanced setting.
- Special guidelines for some Windows users.
More Q&A can be found here.
- Please read carefully the following guidelines, otherwise it may not work.
- Please do NOT move the client folder out of the
gvgai
, otherwise you will need to edit the sh/bat files which will make the work more complicate. Moving the client source code to another directory is possible but not recommended, as the path to the server source code, to the games, to the sprites will need to be changed. - NO additional work will be required if you follow the guidelines.
- NO need to run the server manually. If you launch the Java or Python client following the guidelines, the server will be compiled and run automatically.
- Windows, osx and unix are supported. The corresponding sh/bat will be run automatically. But if you are really using Windows, wish you good luck...we've observed some isolated problems for some Windows users (some Windows users have not met any problem at all). All observed cases have been presented at the bottom of this page.
If you want to run the given sample random Python agent, all you need to do is to
- Go to the folder where the oneclickRunFromPythonClient.sh and oneclickRunFromPythonClient.bat locate (should be
gvgai/blob/master/clients/GVGAI-PythonClient/src
). - Run oneclickRunFromPythonClient.sh or oneclickRunFromPythonClient.bat.
If you want to run your own Python agent:
- Make sure that your agent is named as
Agent.py
and located in a package with same name as your account on GVGAI and located in the source folder. For instance, the sample agent is defined inGVGAI-PythonClient/src/sampleRandom/Agent.py
. - Go to the folder where the oneclickRunFromPythonClient.sh and oneclickRunFromPythonClient.bat locate (should be
gvgai/clients/GVGAI-PythonClient/src
). - In oneclickRunFromPythonClient.sh or oneclickRunFromPythonClient.bat, in the Python run command line, add the option
-agentName ${yourAgentPackage}
. E.g.,python TestLearningClient.py -agentName sampleRandom.Agent
. - Run oneclickRunFromPythonClient.sh or oneclickRunFromPythonClient.bat.
If you want to run the given sample random Java agent, all you need to do is to
- Go to the folder where the oneclickRunFromJavaClient.sh and oneclickRunFromJavaClient.bat locate (should be
gvgai/clients/GVGAI-JavaClient/src
). - Run oneclickRunFromJavaClient.sh or oneclickRunFromJavaClient.bat.
If you want to run your own Java agent:
- Make sure that your agent is named as
Agent.java
and located in a package with same name as your account on GVGAI and located in the source folder. - Go to the folder where the oneclickRunFromJavaClient.sh and oneclickRunFromJavaClient.bat locate (should be
gvgai/blob/master/clients/GVGAI-JavaClient/src
). - In oneclickRunFromJavaClient.sh or oneclickRunFromJavaClient.bat, in the Java run command line, add the option
-agentName ${yourAgentPackage}
. E.g.,java -classpath ${build_folder} TestLearningClient -agentName sampleRandom.Agent
. - Run oneclickRunFromJavaClient.sh or oneclickRunFromJavaClient.bat.
-
Import the project: Launch the IDE, import the project GVGAI-JavaClient. Attention: Please import the client not the
gvgai
. -
Set your own Java agent If you want to use your own agent, you can change the name of agent in TestLearningClient.java. Otherwise, the sample random agent sampleRandom/Agent.java will be used.
-
Run TestLearningClient.java in
gvgai/GVGAI-JavaClient/src/
. It will compile the server, build the communication and launch the program. The output of the client will be shown on the console, while the output of the server will be logged in the logs/ folder: output_server_redirect.txt for stdout, output_server_redirect_err.txt for stderr.
-
Import the project: Launch the IDE, import the project GVGAI-PythonClient. Attention: Please import the client not the
gvgai
. -
Set your own Python agent If you want to use your own agent, you can pass the name of agent as a parameter to TestLearningClient.py in
gvgai/clients/GVGAI-PythonClient/src
. Otherwise, the sample random agent sampleRandom/Agent.py will be used. -
Run TestLearningClient.py in
gvgai/clients/GVGAI-PythonClient/src
. It will compile the client, build the communication and launch the program.
If you are using Eclipse, the build folder is not out
but bin
, you need to edit the runServer_nocompile.sh at gvgai/clients/GVGAI-JavaClient/src/utils
or runServer_nocompile_python.sh at gvgai/clients/GVGAI-PythonClient/src/utils
.
You can pass arguments to your client. The legal ones are listed below:
-
-serverDir [PathToServerCode]: Where the source folder of the server code locates. Default:
..\\..\\..
for Windows system or../../..
for osx and unix. -
-shDir [PathToTheScriptToBuildServer]: Where the script to build and run the server locates. Default:
utils
. -
-gameId [IdOfGameToPlay]: The id of the game to play. Default:
0
. -
-agentName [NameOfAgentToRun]: The name of your agent, should be the same to the package name and your GVGAI account username. Default:
sampleAgents.Agent
for Python andagents.random.Agent
for Java. - [-visuals]: Visualisation of game playing on if this is passed. Otherwise, visualisation off.
The above arguments can be passed to the Java or Python main class, otherwise the default values will be used.
The -serverDir [PathToServerCode]
is NO MORE optional!!! It should always be passed to specify the path to the server code. This is due to the different working paths when running the main class using IDE or running the oneclick*sh/bat files. If you did not move the client code out of the gvgai
folder, then the current setting in the scripts should work.
The options can be passed in the sh/bat files as below.
Python client:
In oneclickFromPythonClient.bat or oneclickFromPythonClient.sh
python TestLearningClient.py -serverDir [PathToServerCode] -shDir [PathToTheScriptToBuildServer] -gameId [IdOfGameToPlay] -agentName [NameOfAgentToRun] [-visuals]
Java client:
In oneclickFromJavaClient.sh:
java -classpath ${build_folder} TestLearningClient -serverDir [PathToServerCode] -shDir [PathToTheScriptToBuildServer] -gameId [IdOfGameToPlay] -agentName [NameOfAgentToRun] [-visuals]
In oneclickFromJavaClient.bat:
java -cp %build_folder% TestLearningClient -serverDir [PathToServerCode] -shDir [PathToTheScriptToBuildServer] -gameId [IdOfGameToPlay] -agentName [NameOfAgentToRun] [-visuals]
If you have downloaded the framework, then you can specify the game for testing. Note that in the competition, your agent will play on a set of unknown games and you won't be able to choose the game to play.
All games for testing can be found in TestSingleLearning.java. You can passing the game to oneclickRunFromJavaClient.sh or oneclickRunFromPythonClient.sh using -gameId 0
for the game with index 0. Same for bat files.
Please edit the value of CompetitionParameters.TOTAL_LEARNING_TIME
.
Maybe another process is already running at that port. In Unix, check: lsof -i tcp:<port>
Please check if the default port 8080 is already being used. If yes, please try another one by editing both
SOCKET_PORT
in CompetitionParameters.java and SOCKET_PORT
in CompetitionParameters.java or in CompetitionParameters.py.
If you move the GVGAI-JavaClient
project to another folder, please change the path to the build and source folders in runClient_nocompile.bat
or runClient_nocompile.sh
. Attention: this will affect the location of the output file ClientLog.txt (see GVGAI-JavaClient/src/utils/IO.java
).
If you failed in the first run, please don't lose your confidence.
Please create manually a folder namely logs
. Normally, the logs
folder has been created and added to Git.
You may need to edit gvgai/src/tracks/SingleLearning/runClient_nocompile.bat
to specify the path to the sdk.
-
If you fail with this, please check if the path to
javac
is set, please refer to javac-isnt-working-in-windows-command-prompt. -
If after checking the above one, it still hangs, please try to run it using
oneclickRunFromPythonClient.sh
oroneclickRunFromPythonClient.bat
. It has been observed that in Windows 7 (64bits), theoneclickRunFromPythonClient.bat
works but under Eclipse it does not work properly.
You may also be interested in:
-
GVG Framework
- Tracks Description
- Code Structure
- Creating Controllers
- Creating Multi Player Controllers
- Creating Level Generators
- Running & Testing Level Generators
- Creating Rule Generators
- Running & Testing Rule Generators
-
Forward Model and State Observation
- Advancing and copying the state
- Advancing and copying the state (2 Player)
- Querying the state of the game
- Querying the state of the game (2 Player)
- Information about the state of the Avatar
- Information about the state of the Avatar (2 Player)
- Information about events happened in the game
- Information about other sprites in the game
- Game Description Class
- Constraints
- Game Analyzer Class
- Level Analyzer Class
- Sprite Level Description Class
- Sprite, Termination, and Interaction Data Class
- Level Mapping Class
- Competition Specifications
- VGDL Language