Code viewer for Mind: Cloned Complex Mind

// Cloned by barkerr2 on 17 Nov 2018 from Mind "Complex 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 more complex starter World  
// =================================================================================================

// World tells us agent position and enemy position
// World does not tell us of existence of walls
// if return invalid move (not empty square) World just ignores it and we miss a turn 



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];
		
// 		var blocks = [(x[0]+1, 1[1]+1), (e[i]+1, e[j]),(e[i]-1, e[j]-1)]; 
		var what = [(x[0]+1, x[1]+1)];
// 		for ( var k = 0; k < 3; k++) 
// 		{
// 		thecube.position.copy ( translate(x[0]+1, x[1]+1) ); 		  	// translate my (i,j) grid coordinates to three.js (x,y,z) coordinates 
		ABWorld.scene.add(thecube);			    
// 		}
		
	
// 	}
		
// 		for ( var m = 0; m < 19; m++)
// 		{
// 		    for ( var k = 0; k < 19; k++)
// 		    {
// 		        if ( GRID[m][k] == GRID_MAZE || GRID[m][k] === GRID_WALL) 
// 		            blocks.push(m, k);
// 		    }
// 		}        
		            
		            
//         const UP = [ACTION_RIGHT,ACTION_LEFT,ACTION_DOWN];
//         const DOWN =[ACTION_RIGHT,ACTION_LEFT,ACTION_UP];
//         const LEFT = [ACTION_UP,ACTION_DOWN,ACTION_RIGHT];
//         const RIGHT = [ACTION_UP,ACTION_DOWN,ACTION_LEFT];
//         const UP_RIGHT = [ACTION_UP,ACTION_RIGHT,ACTION_LEFT,ACTION_DOWN];
//         const UP_LEFT = [];
// 		const DOWN_RIGHT = [ACTION_RIGHT,ACTION_LEFT,ACTION_DOWN];
//         const DOWN_LEFT = [];
// 		 // if strictly move away, will get stuck at wall, so introduce randomness 

// 	    if ( ej < aj ) 
// 	        if ( ei < ai); 
// 	            for ( var k = 0; k < 4; k++) 
//     	            if ( blocks.includes(DOWN[k]) !== True) 
//     	                return (AB(ACTION_DOWN, DOWN[k]));
//     	    if (ei === ai);
//     	        for ( var m = 0; m < 4; m++) 
//     	            if ( blocks.includes(DOWN[m]) !== True) 
//     	                return (AB(ACTION_DOWN, DOWN[m]));

		
// 		if ( ej > aj );
// 		    if ( ei < ai)
//         		for ( var l = 0; l < 4; l++)
//         		    if ( blocks.includes(UP[l]) !== True) 
//         		        return (AB (ACTION_UP, UP[l]));
//             if (ei === ai)
//         		for ( var n = 0; n < 4; n++)
//         		    if ( blocks.includes(UP[n]) !== True) 
//         		        return (AB (ACTION_UP, UP[n]));
        

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

//  		 return  ( AB.randomIntAtoB (0,3) );
 		
 		if ( ei < ai ) 	return ( AB.randomPick ( ACTION_RIGHT,	AB.randomPick3 ( ACTION_LEFT, 	ACTION_UP, ACTION_DOWN ) 		));
		if ( ei > ai ) 	return ( AB.randomPick ( ACTION_LEFT,	AB.randomPick3 ( ACTION_RIGHT, 	ACTION_UP, ACTION_DOWN ) 		)); 

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


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

}