Code viewer for Mind: Complex Mind (clone by Rak...

// Cloned by Rakesh Reddy Soma on 26 Nov 2020 from Mind "Complex Mind (clone by Rakesh Reddy Soma)" by Rakesh Reddy Soma 
// Please leave this clone trail here.
 
AB.mind.getAction=function(a){var c=a[0],D=a[1],G=a[2],I=a[3],R=[],i=0,h=0,p=0,M=0,u=0;if(I<D){if(!occupied(G,I+1)){i=Math.abs(G-c)+Math.abs(I+1-D);R.push(i)}if(!occupied(G-1,I)){h=Math.abs(G-1-c)+Math.abs(I-D);R.push(h)}if(!occupied(G+1,I)){p=Math.abs(G+1-c)+Math.abs(I-D);R.push(p)}(s=Math.min.apply(Math,R))==i&&(occupied(G,I+1)||(M+=1,G=G,I+=1)),s==h&&0==M&&(occupied(G-1,I)||(u+=1,G-=1,I=I)),s==p&&0==u&&0==M&&(occupied(G+1,I)||(G+=1,I=I)),GRID[G][I+1]!=GRID_MAZE&&GRID[G][I+1]!=GRID_WALL||GRID[G-1][I]!=GRID_MAZE&&GRID[G-1][I]!=GRID_WALL||GRID[G+1][I]!=GRID_MAZE&&GRID[G+1][I]!=GRID_WALL||(G=G,I-=1)}if(I>D){if(!occupied(G,I-1)){i=Math.abs(G-c)+Math.abs(I-1-D);R.push(i)}if(!occupied(G+1,I)){h=Math.abs(G+1-c)+Math.abs(I-D);R.push(h)}if(!occupied(G-1,I)){p=Math.abs(G-1-c)+Math.abs(I-D);R.push(p)}(s=Math.min.apply(Math,R))==i&&(occupied(G,I-1)||(M+=1,G=G,I-=1)),s==h&&0==M&&(occupied(G+1,I)||(u+=1,G+=1,I=I)),s==p&&0==M&&0==u&&(occupied(G-1,I)||(G-=1,I=I)),GRID[G][I-1]!=GRID_MAZE&&GRID[G][I-1]!=GRID_WALL||GRID[G-1][I]!=GRID_MAZE&&GRID[G-1][I]!=GRID_WALL||GRID[G+1][I]!=GRID_MAZE&&GRID[G+1][I]!=GRID_WALL||(G=G,I+=1)}if(G<c){if(!occupied(G+1,I)){i=Math.abs(G+1-c)+Math.abs(I-D);R.push(i)}if(!occupied(G,I-1)){h=Math.abs(G-c)+Math.abs(I-1-D);R.push(h)}if(!occupied(G,I+1)){p=Math.abs(G-c)+Math.abs(I+1-D);R.push(p)}(s=Math.min.apply(Math,R))==i&&(occupied(G+1,I)||(M+=1,G+=1,I=I)),s==h&&0==M&&(occupied(G,I-1)||(u+=1,G=G,I-=1)),s==p&&0==u&&0==M&&(occupied(G,I+1)||(G=G,I+=1)),GRID[G][I+1]!=GRID_MAZE&&GRID[G][I+1]!=GRID_WALL||GRID[G][I-1]!=GRID_MAZE&&GRID[G][I-1]!=GRID_WALL||GRID[G+1][I]!=GRID_MAZE&&GRID[G+1][I]!=GRID_WALL||(G-=1,I=I)}if(G>c){if(!occupied(G-1,I)){i=Math.abs(G-1-c)+Math.abs(I-D);R.push(i)}if(!occupied(G,I+1)){h=Math.abs(G-c)+Math.abs(I+1-D);R.push(h)}if(!occupied(G,I-1)){p=Math.abs(G-c)+Math.abs(I-1-D);R.push(p)}var s;(s=Math.min.apply(Math,R))==i&&(occupied(G-1,I)||(M+=1,G-=1,I=I)),s==h&&0==M&&(occupied(G,I+1)||(u+=1,G=G,I+=1)),s==p&&0==M&&0==u&&(occupied(G,I-1)||(G=G,I-=1)),GRID[G][I+1]!=GRID_MAZE&&GRID[G][I+1]!=GRID_WALL||GRID[G][I-1]!=GRID_MAZE&&GRID[G][I-1]!=GRID_WALL||GRID[G-1][I]!=GRID_MAZE&&GRID[G-1][I]!=GRID_WALL||(G+=1,I=I)}};