Code viewer for Mind: Agent Mind
// Michael Ryan - 59568611
// Slight modification to mind, input now is a list of Mazes - output is an Agent action for each Maze

// Cloned by Michael Ryan on 26 Oct 2019 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 and enemy positions
// 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 


 
	AB.mind.getAction = function ( mazes )		// array of mazes
	{ 
	    actions = [];
	    
	    for (var i = 0; i < mazes.length; i++) 
	    {
	        var ei = mazes[i].enemyPosition.i;
	        var ej = mazes[i].enemyPosition.j;
	        
	        var ai = mazes[i].agentPosition.i;	        
	        var aj = mazes[i].agentPosition.j;
	        
            if ( ej < aj )
            { 
                actions.push( AB.randomPick ( ACTION_UP, AB.randomPick(ACTION_RIGHT,ACTION_LEFT)));
            }
            else if ( ej > aj ) 
            {
                actions.push( AB.randomPick ( ACTION_DOWN,	AB.randomPick(ACTION_RIGHT,ACTION_LEFT)));
            }
            else if ( ei < ai )
            {
                actions.push( AB.randomPick ( ACTION_RIGHT,	AB.randomPick(ACTION_UP,ACTION_DOWN)));
            }
            else if ( ei > ai )
            {
                actions.push( AB.randomPick ( ACTION_LEFT,	AB.randomPick(ACTION_UP,ACTION_DOWN)));
            }
            else 
            {
                actions.push( AB.randomIntAtoB (0,3) );   
            }
	    }
	    
	    return actions;
	};