World definition

If you are writing a World, the World class must 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 "logged in" runs

In a "logged in" run the World can save (to the server) data linked to the user running it, and restore data from the server.

If a World wants to do this, it can call various AB "logged in" functions, and it must define some or all of 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