Docs


AB World and Mind

The AB object contains placeholders for the World and Mind:
 

AB.world;                // The World  
AB.mind;                 // The Mind (if any) 

The World and Mind are defined not by the system but by the World or Mind author. You define Worlds and Minds by defining methods for AB.world and AB.mind. Then Minds can run in Worlds.

The author defines some or all of the following functions. These use the AI model behind Ancient Brain. The system checks if you defined them. If not defined, the system either skips them and carries on, or, if a return value is expected, returns 0.


World

 
   
AB.world.newRun = function() { ... };   // World code to execute at start of run
AB.world.endRun = function() { ... };   // World code to execute at end of run

World with no Mind

 

AB.world.nextStep = function() { ... };   // World code to execute each step
	

World with a Mind

 
    
AB.world.getState   = function() { ... };            // Return state of World  
AB.world.takeAction = function ( action ) { ... };   // Execute this action 
AB.world.getScore   = function() { ... };            // Return score achieved by Mind (float)

	// Action format defined by World.
	// State format defined by World.
	

Mind

 
    	
AB.mind.newRun = function() { ... };   // Mind code to execute at start of run
AB.mind.endRun = function() { ... };   // Mind code to execute at end of run

AB.mind.getAction   = function ( state ) { ... };    // Return the action to execute in this state