World definition

If you are writing a World, the World class must normally be declared.


World with no Mind

If the World does not use Minds, the structure of the World class is as follows.

 

function World() 
{ 

	// The following function declarations are optional.
 	// If not declared, nothing happens and the run continues. 

	this.newRun = function()                // Things the World will do at the start of a run 
	{
	};

	this.nextStep = function()              // Things the World will do each time step 
	{
	};
	
	this.endRun = function()                // Things the World will do at the end of a run
	{
	};
}


World with a Mind

If the World uses Minds, the structure of the World class is as follows.

 

function World() 
{ 

	// The following function declarations are optional.
 	// If not declared, nothing happens and the run continues. 

	this.newRun = function()                  // Things the World will do at the start of a run 
	{
	};

	
	this.takeAction = function ( action )     // World executes action. Action format defined by World.
	{
	};
	
	
	this.endRun = function()                  // Things the World will do at the end of a run
	{
	};

	
	// The following function declarations are optional.
	// If not declared, return is taken as 0.
	
	this.getState = function()                // Get current state of World. State format defined by World.
	{
	  return ( state );  				 
	};

	
	this.getScore = function()                // Get score achieved by Mind. 
 	{
	 return ( float );		
	};

}




World support for runs logged in

When we run logged in, there are various AB functions that can be used to save data to the server under the userid that is running the World.

To use these AB functions, the World must define the following functions:

 
	
function World() 
{ 

....


// To save data to server:
//   AB.saveData();
// This will call World.saveData() to get the actual data:

	this.saveData = function()             // Return what object to save to the server  
	{
		return ( object );                    
	};
	 
	 
// To restore data from server:	 
//   AB.restoreData(); 
// When this returns, it calls World.restoreData(object) to process the data: 

	this.restoreData = function ( object )     // Process the object that was recovered from server
	{
		// Do something with the object 
	};
 
 
// To query if data exists:
//   AB.queryDataExists();
// When this returns, it calls World.queryDataExists(boolean) to do something with the answer: 

	this.queryDataExists = function ( exists )     // Do something once we find out if data exists 
	{
		if ( exists ) ...
		else ...
	};

 
}

 

The background is a program, showing the JavaScript graphics used on this site.
 
Font:

© Ancient Brain Ltd. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Beta      Bug bounty      Contact      Stats      The name      Terms and conditions