Code viewer for Mind: Human-controlled mind (clo...

// Cloned by James Humphrys on 8 Jan 2020 from Mind "Human-controlled mind" by Liam Nunez 
// Please leave this clone trail here.
 



// =================================================================================================
// Human-controlled mind for "Stay in the box!"
// =================================================================================================




// World tells us the status of each square in the grid, along with the current agent position


 

var currentMove = ACTION_STAYSTILL; //Default move
function keyHandler(e)		
{
    if (e.keyCode == 37)  currentMove = ACTION_LEFT;
    if (e.keyCode == 38)   currentMove = ACTION_DOWN;
    if (e.keyCode == 39)   currentMove = ACTION_RIGHT;
    if (e.keyCode == 40)   currentMove = ACTION_UP;
}

function Mind() { 


//--- public functions / interface / API ----------------------------------------------------------

	this.newRun = function()
	{
	    //Initialize the key handler
	    document.onkeydown = keyHandler;
	};
	this.endRun = function()
	{
	};
	this.getAction = function ( x )		// x is an array of [ GRID (indicate the status of every square in the grid, i.e where the blanks spaces, wall spaces and box spaces are), ai, aj ]
	{ 
	    //Since this is a simple human controlled mind, for our purposes we do not need to use x, but AI controlled minds will need to use it
 		var tmpMove = currentMove;
 		currentMove = ACTION_STAYSTILL;
 		return tmpMove;
 		//Returns whatever the user pressed, if the user pressed nothing, it will return ACTION_STAYSTILL
	};

}