Java
We currently only support Minds and Worlds written in Java.
We will support other languages in the future.
The instructions below should work on all operating systems.
General strategy
- Write and debug your World offline.
- Debug it with a sample Mind offline.
- When ready, upload your World to be hosted online.
- Upload your sample Mind too, to test it works online.
- Now that your World is online, other people can write Minds for it.
Customise these instructions
Command-line
Below we provide the actual command-line that will build a World and Mind.
Your
Java development environment
may automate these steps.
You may also script it
in many different ways.
1. Gather materials
- Java
- Make sure you have the
Java Development Kit (JDK) installed.
- World-Wide-Mind generic files
- Download
Skeleton.zip and extract it to yield the following files:
- w2m.jar (core World-Wide-Mind functionality)
- xerces.jar (XML parser)
- SkeletonWorld.java (SkeletonWorld, a sample World)
- SkeletonMind.java (SkeletonMind, a sample Mind to test the World)
- ImageWorld.java (ImageWorld, a sample World that generates images)
- ImageMind.java (ImageMind, a sample Mind to test the World)
- images (directory of image files used by ImageWorld)
- MindM.java (MindM, a sample MindM - that is,
a Mind that calls other Minds)
2. Write the World
- Decide if your World will generate images or not.
Pick SkeletonWorld.java
or ImageWorld.java
as your model.
-
Rename it
to the name you picked for your World:
AWorld.java
- Change the class name:
public class AWorld extends AbstractWorld
- Edit the World code to implement your problem.
Hopefully the World code makes it clear how to do this.
- Compile the World:
javac -cp "*" AWorld.java
Newer versions of JDK on Windows:
You may need to use this syntax for a
wildcard classpath:
-cp *;
|
- Build the World JAR file (without images):
jar cf0 AWorld.jar AWorld.class
or with images (the JAR file can include any number of support files):
jar cf0 AWorld.jar AWorld.class images
3. Write a sample Mind to test the World
-
Rename SkeletonMind.java
to the name you picked for your test Mind:
AMind.java
- Change the class name:
public class AMind implements Mind
- Edit the Mind code to send appropriate actions to the World.
- Compile the Mind:
javac -cp "*" AMind.java
- Build the Mind JAR file:
jar cf0 AMind.jar AMind.class
4. Run the Mind in the World offline
- Run the Mind in the World offline
to test the World:
java -cp "*" org.w2mind.toolkit.Main -mind AMind -world AWorld
This will output an XML log of the run in:
runs/runid/runid.xml
- If the World can produce images of each step,
to get a run to generate images use:
java -cp "*" org.w2mind.toolkit.Main -mind AMind -world AWorld -g
This will output images of each step in:
runs/runid/step.jpg
- If you are logged in through ssh (or any other setup where there is no display) run with images as follows:
java -Djava.awt.headless=true -cp "*" org.w2mind.toolkit.Main -mind AMind -world AWorld -g
5. Upload the World
-
Upload AWorld.jar through the
Upload World form.
- Upload an
index.html
file to describe your World.
It should explain the state, action and score format of the World
so others can write Minds for it.
For an example see
SkeletonWorld.
- Upload a sample skeleton Mind, showing how to write a Mind
for this World.
This should show how to parse the state and generate actions.
This may be identical to
AMind.java
- Your
index.html
file
may link to multiple supporting files.
It should link to the skeleton Mind.
- You can (but do not have to) upload the Java source code for your World
to help explain how to use it.
Ensure that
index.html
links to it.
- Others can now write Minds for your World.
- Your
AWorld.jar
file is also now
available for download by others to write their Minds offline.
6. Upload the Mind to test the World online
-
Upload AMind.jar through the
Upload Mind form.
- Click to run the Mind in the World to test it online.
Some extra notes
Writing separate classes
If you write any separate classes, they must be
serializable.
This is achieved as follows:
import java.io.Serializable;
class CLASSNAME implements Serializable
{
...
}
|
Outputting to stdout
You can output debug information to stdout when running offline:
public State takeaction ( Action action )
{
System.out.println ( debug info );
}
|
|