Code viewer for Mind: Model Mind (clone by James...

// Cloned by James Humphrys on 26 Sep 2019 from Mind "Model 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.
// ==================================================================================================================




 

	AB.mind.getAction = function ( x )		// x is an array of [ ai, aj, ei, ej ]
	{ 
		var ai = x[0];
		var aj = x[1];
		var ei = x[2];
		var ej = x[3];

		// if strictly move away, will get stuck at wall, so introduce randomness 

		 if ( ej < aj ) 	return ( AB.randomPick ( ACTION_UP,		AB.randomPick ( ACTION_UP, 		AB.randomPick(ACTION_RIGHT,ACTION_LEFT) 	))); 
		 if ( ej > aj ) 	return ( AB.randomPick ( ACTION_DOWN,	AB.randomPick ( ACTION_DOWN, 	AB.randomPick(ACTION_RIGHT,ACTION_LEFT) 	))); 

		 if ( ei < ai ) 	return ( AB.randomPick ( ACTION_RIGHT,	AB.randomPick ( ACTION_RIGHT,	AB.randomPick(ACTION_UP,ACTION_DOWN) 		))); 
		 if ( ei > ai ) 	return ( AB.randomPick ( ACTION_LEFT,	AB.randomPick ( ACTION_LEFT,	AB.randomPick(ACTION_UP,ACTION_DOWN) 		))); 

 		return  ( AB.randomIntAtoB (0,3) );
	};