JS viewer

Syntax-highlighted view of JS of Mind: Cloned P5 raw Mind





// Cloned by test  on 13 Aug 2018 from Mind "P5 raw Mind" by Starter user 
// Please leave this clone trail here.
 



// ==== Starter Mind ===============================================================================================
// (c) Ancient Brain Ltd. All rights reserved.
// This code is only for use on the Ancient Brain site.
// This code may be freely copied and edited by anyone on the Ancient Brain site.
// This code may not be copied, re-published or used on any other website.
// To include a run of this code on another website, see the "Embed code" links provided on the Ancient Brain site.
// ==================================================================================================================



// =================================================================================================
// Sample Mind for P5 raw World  
// =================================================================================================
 

// no need to pass state as argument 
// since the info we need are global variables anyway 


function Mind() 
{ 

	this.getAction = function()		 
	{ 
			// move object towards target  
			
			if ( AB.randomBoolean() )				// randomly choose to track target x or y each step 
			{
				if ( x < tx ) 	return ACTION_RIGHT;
				else  			return ACTION_LEFT;	  
			}
			else 
			{
				if ( y < ty ) 	return ACTION_DOWN;
				else 			return ACTION_UP;	  
			}
	};

}