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 Mind


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. Pick a World to write a Mind for.
  2. Write and debug your Mind offline, with an offline copy of the World.
  3. When ready, upload your Mind to be hosted online.
  4. Now that your Mind is online, other people can run it, and can call it from their Minds.

Customise these instructions

Pick a World to write a Mind for: and a name for your Mind:


Hint: View the list of all Worlds, pick a World, click on "Write Mind", and it will send you back here with the World name filled in.


Command-line

Below we provide the actual command-line that will build a 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)

  3. World-specific files
    1. Download w2m.Tyrrell10.jar into the directory where you put the files above. (This is an offline copy of the World.)
    2. If your browser tries to re-name this to extension .zip just re-name it back to extension .jar
    3. The World description should include a skeleton Mind you can download.

2. Write the Mind

  1. Rename the skeleton Mind to the name you picked for your 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. The World description should explain State and Action format.
  4. Compile the Mind:

    javac -cp "*" AMind.java

    Newer versions of JDK on Windows:
    You may need to use this syntax for a wildcard classpath:
    -cp *;

  5. Build the Mind JAR file:

    jar cf0 AMind.jar AMind.class


3. Run the Mind in the World offline

  1. Run the Mind in the World offline to test it:

    java -cp "*" org.w2mind.toolkit.Main -mind AMind -world w2m.Tyrrell10

    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 w2m.Tyrrell10 -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 w2m.Tyrrell10 -g


4. Upload the Mind

  1. Upload AMind.jar through the Upload Mind form.
  2. Optionally include an index.html file to describe your Mind. This may link to multiple supporting files.
  3. You can (but do not have to) upload the Java source code for your Mind to help explain how it works. Ensure that index.html links to it.
  4. Consider whether your Mind needs any instructions for use, if it is being called by other Minds. For example:

    "If you are writing a MindM to call MyMind, make sure you call MyMind on every step:
    MyMind.getaction(state);
    even if you are going to ignore the result.
    This is to keep MyMind informed of every step of the run to help it build up a better map of the problem."

  5. Your Mind is now on the list of all Minds for this World. It will not be on the scoreboard list of Minds until you run it online.
  6. Click to run the Mind in the World online. It should now be on the scoreboard.
  7. Other people can now run your Mind online, and can call it from their Minds.


Some extra notes


Minds with Memory

Minds may have memory. They may update a data structure on every step:

public class MindWithMemory  
{	 
 int i;			// or any other data structure

 public void newrun()   
 {
	i = 1;		// or any other initialisation of the data structure
 }
	
 public Action getaction ( State s )   	 
 {
	i = i + 1;		// or any other update to the data structure
 }
}

Minds calling other Minds

When responding to getaction(state), Minds may call other Minds, and use their suggested actions (this is the whole point of the World-Wide-Mind):

 public Action getaction ( State s )     
 {
  return ( remotemind.getaction(s) );
 }	 

If your Mind is offline, and the called Mind is on our server, this makes a network call. When you upload your Mind to our server, this automatically becomes a direct method call.

To see how to write a MindM (a Mind that calls other Minds) see the MindM example in the Skeleton World.


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 Action getaction ( State s ) 
{ 
 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.