Code viewer for Mind: ExperimentalMind0

// Cloned by Co on 6 Nov 2018 from Mind "New Mind" by Co 
// Please leave this clone trail here.
 
 
function Mind() 
{ 
	
	this.newRun = function()                  
	{
	};


	this.getAction = function ( state )		 
	{ 
	 // return ( 3 ,2,1,2,1,2,3);
	  
	};

		 
	this.endRun = function()                 
	{
	};


}

function Mind() 
{ 

	this.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_RIGHT,ACTION_LEFT)));
		 
		 
		 //enemy lower than agent, closer than 5
		 if ( ej < aj && aj-ej <5 && ei<ai) 	return ( AB.randomPick ( ACTION_UP,	AB.randomPick(ACTION_RIGHT) ));
		 if ( ej < aj && aj-ej <5 && ei>ai) 	return ( AB.randomPick ( ACTION_UP,	AB.randomPick(ACTION_LEFT) ));
	
		 //enemy higher than agent, closer than 5
		 if ( ej > aj && ej -aj <5 ) 	return ( AB.randomPick ( ACTION_DOWN,	AB.randomPick(ACTION_UP,ACTION_RIGHT,ACTION_LEFT) ));
		
		 
		 
		 
		
		 //enemy left of agent, closer than 5
		 if ( ei < ai && ai-ei<5 ) 	return ( AB.randomPick (ACTION_RIGHT,	AB.randomPick(ACTION_UP,ACTION_DOWN) ));
		 //enemy right of agent, closer than 5
		 if ( ei > ai && ei-ai<5) 	return ( AB.randomPick ( ACTION_LEFT,	AB.randomPick(ACTION_UP,ACTION_DOWN) ));
		
		
		 
		 if (aj > 16 && aj - ej <4 )	return ( AB.randomPick (ACTION_UP,	AB.randomPick(ACTION_RIGHT,ACTION_LEFT )));
		 if (aj < 4  && aj - ej <4 )	return ( AB.randomPick (ACTION_DOWN,	AB.randomPick(ACTION_RIGHT,ACTION_LEFT )));
      
        return (AB.randomIntAtoB(0,4))

         
 		
	};

}