Code viewer for Mind: Cloned Cloned AI VS AI Mode

// Cloned by test2 on 7 Mar 2018 from Mind "Cloned AI VS AI Mode" by Test Account  
// Please leave this clone trail here.
 
function randomPickFromTwo(r,t){return randomBoolean()?r:t}function randomPickFromArray(r){return rand=r[Math.floor(Math.random()*r.length)]}const B_DAMAGE_HUNTING=0,B_HEALTH_HUNTING=1,B_OPPONENT_HUNTING=2,B_FIGHTING=3,F_VERY_HIGH=20,F_HIGH=15,F_MEDIUM=10,F_LOW=5,F_VERY_LOW=0,F_VERY_VERY_LOW=-5,F_LOWEST=-20,F_INVALID=-100;function Mind(){function r(r,t,i,n){var _;switch(r.lineOfSight[t][i]){case n.topPriority:_=F_VERY_HIGH;break;case n.secondPriority:_=F_HIGH;break;case n.thirdPriority:_=F_MEDIUM;break;case n.fourthPriority:_=F_LOW;break;case n.fifthPriority:_=F_VERY_LOW;break;case GRID_OPPONENT_OCCUPIED&&!0===n.avoidOpponent:_=F_LOWEST;break;case GRID_WALL:_=F_INVALID}return _}function t(t,i,n,_){var o,e,a,I=F_INVALID,P=t.i+i,O=t.j+n;if(t.lineOfSight[P][O]==GRID_WALL)return I;for(;t.lineOfSight[P][O]!=GRID_WALL&&t.lineOfSight[P][O]!=GRID_OPPONENT_OCCUPIED;){if(o=r(t,P,O,_),0!=i?(e=r(t,P,O+1,_),a=r(t,P,O-1,_)):(e=r(t,P+1,O,_),a=r(t,P-1,O,_)),o==F_LOWEST)return F_LOWEST;if(o>I&&(I=o),e==F_LOWEST)return F_LOWEST;if(e>I&&(I=e),a==F_LOWEST)return F_LOWEST;a>I&&(I=a),P+=i,O+=n}return(o=r(t,P,O,_))==F_LOWEST?F_LOWEST:(o>I&&(I=o),P=t.i+i,O=t.j+n,I!=F_LOW&&I!=F_VERY_LOW||t.oldI!=P||t.oldJ!=O?I:F_VERY_VERY_LOW)}function i(r,i){var n=function(r){var t={behaviour:r,topPriority:null,secondPriority:null,thirdPriority:null,fourthPriority:null,fifthPriority:null,avoidOpponent:null};switch(r){case B_DAMAGE_HUNTING:t.topPriority=GRID_DAMAGE_PICKUP,t.secondPriority=GRID_HEALTH_PICKUP,t.thirdPriority=GRID_PORTAL,t.fourthPriority=GRID_BLANK,t.avoidOpponent=!0;break;case B_HEALTH_HUNTING:t.topPriority=GRID_HEALTH_PICKUP,t.secondPriority=GRID_PORTAL,t.thirdPriority=GRID_BLANK,t.fourthPriority=GRID_DAMAGE_PICKUP,t.avoidOpponent=!0;break;case B_OPPONENT_HUNTING:t.topPriority=GRID_OPPONENT_OCCUPIED,t.secondPriority=GRID_DAMAGE_PICKUP,t.thirdPriority=GRID_HEALTH_PICKUP,t.fourthPriority=GRID_PORTAL,t.fifthPriority=GRID_BLANK,t.avoidOpponent=!1}return t}(i),_=t(r,0,-1,n),o=t(r,0,1,n),e=t(r,-1,0,n),a=t(r,1,0,n),I=Math.max(_,o,e,a);if(I==F_LOWEST)return ACTION_STAYSTILL;var P=[];return _==I&&P.push(ACTION_UP),o==I&&P.push(ACTION_DOWN),e==I&&P.push(ACTION_LEFT),a==I&&P.push(ACTION_RIGHT),randomPickFromArray(P)}function n(r){var t=function(r){return r.health<=25&&!1===r.trapped?B_HEALTH_HUNTING:r.attackDamage<=1&&r.health>25&&!1===r.trapped?B_DAMAGE_HUNTING:r.attackDamage>1&&r.health>25&&!1===r.opponentInRange?B_OPPONENT_HUNTING:!0===r.trapped||1==r.opponentInRange&&r.attackDamage>1&&r.health>25?B_FIGHTING:void 0}(r);return t==B_FIGHTING?ACTION_ATTACK:i(r,t)}this.newRun=function(){},this.endRun=function(){},this.getAction=function(r){return{agentAction:n(r.agentMap),enemyAction:n(r.enemyMap)}}}