Code viewer for Mind: Simple Mind










// =================================================================================================
// Sample Mind for more complex starter WWM 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 randomPick ( a, b )
{
 if ( randomBoolean() ) 
  return a;
 else
  return b;
}


function Mind() { 

var counter = 0;

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


	this.newRun = function()
	{
	};

	this.endRun = function()
	{
	};



	this.getAction = function ( x )		// x is an array of the top ring on each rod;
	{ 
	/*
		var action = new Array(2);
		if(counter == 0)
		{
			counter++;
			if(x[0] < x[1] || x[1] === 0)
			{
				action [0] = 0;
				action [1] = 1;
				
				return(action);
			}
			if(x[1] < x[0] || x[0] === 0)
			{
				action [0] = 1;
				action [1] = 0;
				return(action);
			}
			
		}
		if(counter == 1)
		{
			counter++;
			if(x[0] < x[2] || x[2] === 0)
			{
				action [0] = 0;
				action [1] = 2;
				return(action);
				
			}
			if(x[2] < x[0] || x[0] === 0)
			{
				action [0] = 2;
				action [1] = 0;
				return(action);
			}
		}
		if(counter == 2)
		{	
			counter = 0;
			if(x[1] < x[2] || x[2] === 0)
			{
				action [0] = 1;
				action [1] = 2;
				
				return(action);
			}
			if(x[2] < x[1] || x[1] === 0)
			{
				action [0] = 2;
				action [1] = 1;
				return(action);
			}
		}*/
	};



}