Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I reached over 110000 points by below code. We may can reach 50000 by average. Basic strategy is that player turns lately as possible so that enemy can't catch with a distance in a bit. However, this strategy has extremely weak point, that is if yellow feed remains in the center of screen, player can't reach forever.

I'm not so interested in this game already. But I think this can improve to close perfect, which player can infinitely escape from enemy, by considering "Offense" aspect, like player's invincible mode and enemy's escape mode.

function bot() { dir = enemy.x > player.x ? 1 : -1; const Xp = player.x; const Xe = enemy.x; const pvx = player.vx; const escaping = (Xp < Xe && pvx < 0) || (Xp > Xe && pvx > 0); const escD = Xp < Xe ? Xp : 100 - Xp; const Vp = player.vx * 0.5 * difficulty; const evx = enemy.eyeVx !== 0 ? enemy.eyeVx : (player.x > enemy.x ? 1 : -1) * (powerTicks > 0 ? -1 : 1); const Ve = evx * (powerTicks > 0 ? 0.25 : enemy.eyeVx !== 0 ? 0.75 : 0.55) * difficulty; const VRatio = abs(Ve / Vp) === 0.5 ? 1.1 : abs(Ve / Vp); console.log(VRatio); const minD = (VRatio - 1) * escD + 3 * (VRatio + 1) + difficulty; const D = abs(Xp - Xe); if (!escaping && D <= minD) { document.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowUp" })); document.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" })); } } setInterval(bot, 10);



Oh my gosh. How you all paste codes normally? lol




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: