KoTH: Highest HP is Eliminated!
Low Profile
function(hp, others, storage) {
var alive = others.filter(bot => bot > 0);
return hp - alive.length
}
Sets its health to be always equal to the number of bots. Any bot that undercuts this one risks eventually hitting zero health.
Jack
Assumes that half of the bots are stupid. So they will kill theirselves or will end up being killed simultaneously with another bot. We just need to make sure to have enough HP to survive it for enough rounds knowing that.
function(hp, others, storage) {
var nrOfBots = others.filter(bot => bot > 0).length;
var hpToTake = 1;
if (hp == 100) {
hpToTake = hp - (Math.round(nrOfBots / 2) + 0.0001);
}
return hpToTake;
}
The Follower
function(hp, others, storage) {
if (!storage.prev){
storage.prev = others.slice();
return hp * (Math.random() * 0.1 + 0.8);
}
let [decSum, decCnt] = others.reduce(([s,n],v2,i) => {
if (v2 <= 0) return [s, n];
return [s * (storage.prev[i]-v2), n + 1];
}, [1,0]);
storage.prev = others.slice();
let avg = decSum ** (1 / decCnt);
while (avg > hp) avg /= 2;
return hp - avg;
}
Uses the geometric mean of the decrements chosen by alive opponents (in the previous turn) to decide its next move. There is no such information at the first turn, so it cuts a very large part of its own HP to be safe.