The World Wide Mind server

Host your Worlds and Minds here.

Home      Introduction      Worlds      Authoring      Contact

Login:   Password:  

Register      Forgot password


How to write a World


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

  1. Write and debug your World offline.
  2. Debug it with a sample Mind offline.
  3. When ready, upload your World to be hosted online.
  4. Upload your sample Mind too, to test it works online.
  5. Now that your World is online, other people can write Minds for it.

Customise these instructions

Pick a name for your World: and a name for your test Mind:

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

  1. Java
    1. Make sure you have the Java Development Kit (JDK) installed.

  2. World-Wide-Mind generic files
    1. 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

  1. Decide if your World will generate images or not. Pick SkeletonWorld.java or ImageWorld.java as your model.
  2. Rename it to the name you picked for your World: AWorld.java
  3. Change the class name:

    public class AWorld extends AbstractWorld

  4. Edit the World code to implement your problem. Hopefully the World code makes it clear how to do this.
  5. 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 *;

  6. 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

  1. Rename SkeletonMind.java to the name you picked for your test Mind: AMind.java
  2. Change the class name:

    public class AMind implements Mind

  3. Edit the Mind code to send appropriate actions to the World.
  4. Compile the Mind:

    javac -cp "*" AMind.java

  5. Build the Mind JAR file:

    jar cf0 AMind.jar AMind.class


4. Run the Mind in the World offline

  1. 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
    

  2. 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
    

  3. 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

  1. Upload AWorld.jar through the Upload World form.
  2. 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.
  3. 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
  4. Your index.html file may link to multiple supporting files. It should link to the skeleton Mind.
  5. 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.
  6. Others can now write Minds for your World.
  7. 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

  1. Upload AMind.jar through the Upload Mind form.
  2. 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 ); 
} 



Developed by The World-Wide-Mind project.
Powered by PHP and SQLite on openSUSE Linux. Movies by FFmpeg. XML by Xerces.
Free icon from Hellas Multimedia. Purchased icons from Icons-Land.
Creative Commons globe and earth images from Flickr.