The Bullfighters

mutation 170

// ----------------------------------------------------------------------------- // ~ The Bullfighters ~ // @sevenfive // ----------------------------------------------------------------------------- //BITCOIN ADDRESS: 1FvmW8rbNuiqFEvoQJTiv4W6DAXYeUjdk1 //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO//TODO//TODO//TODO//TODO //TODO: SYSTEMATIC ANALYSIS OF EVERY BULLFIGHTERS DEATH. DETERMINE MOST FREQUENT CAUSE OF DEATH. //TODO: IMPLEMENT BORDER EXIT POINT AVOIDANCE METHOD FOR ENDGAME CODE //TODO: INVESTIGATE INCREASED PICADOR AGGRESSION FURTHER //TODO: RETRY FOCUSING PICADORS EXCLUSIVELY ON QUEEN? //TODO: DO A DIFF OF ALL RECENT VERSIONS, MAKE SURE ALL DEFINITE IMPROVEMENTS ARE ACTUALLY IN THE SAME VERSION var pendgame = false; ai.step = function(o) { //CONSTANTS TIME = 0.25; if (o.me.queen) {TIME = 0.4;} SPLINTERTIME = 5; OY = 10; GREED = 10; ENEMYCLUSTER = 0.3; DEBUGMODE = false; SOFT = 0; //ABBREVIATIONS var ol = o.lib; var olv = o.lib.vec; var ola = o.lib.ang; var os = o.ships; var og = o.game; var here = o.me.pos; var torque = 0; var thrust = 0; var label = ""; if (o.me.queen) { label += "Matador"; } else { label += "Picador"; } var endgame = true; for (var i = 0; i < os.length; i++) { if (os[i].alive & !os[i].queen) { endgame = false; } } if (!o.me.queen) {endgame = false;} if (endgame) { label = "¡Indulto!";} if (og.moon_field < 50) {endgame = true;} if (endgame | og.moon_field < 70) {pendgame = true;} var force = o.game.center; //MOONS for (var i = 0; i < o.moons.length; i++) { var offset = olv.diff(here,o.moons[i].pos); var distance = olv.len(offset) - o.moons[i].radius; var speed = ol.physics.speedToward(olv.diff(o.moons[i].vel,o.me.vel),o.moons[i].pos,here); var moondanger = 1000; if (o.me.queen) {moondanger = 1500;} var danger = moondanger/Math.pow(noneg(distance - TIME*speed),2); var away = olv.normalized(offset); force = olv.sum(force,olv.times(away,danger)); } //EDGE COLLISION BASED { var exitpoint = here; exitpoint = olv.sum(exitpoint,olv.times(o.me.vel,0.1)); while (olv.len(exitpoint) < og.moon_field | olv.len(exitpoint) < og.moon_field - 20 & o.me.queen) { exitpoint = olv.sum(exitpoint,olv.times(o.me.vel,0.1)); } var offset = olv.diff(here,exitpoint); var distance = olv.len(offset); var speed = ol.physics.speedToward(o.me.vel,exitpoint,here); //used to be 20, power 1 var edge1 = 80; var qtime = 1; if (o.me.queen) {edge1 = 160; qtime = 1;} i var danger = edge1/Math.pow(noneg(distance-TIME*qtime*speed),1); var away = olv.normalized(offset); force = olv.sum(force,olv.times(away,danger)); } //EDGE NAIVE { var offset = olv.times(here,-1); var distance = og.moon_field - olv.len(offset); var edge2 = 5; if ((og.time > SPLINTERTIME | o.me.area_frac < 0.5 ) & o.me.queen) {edge2 = 35;} //not sure if this really does anything... var danger = edge2/distance; var away = olv.normalized(offset); force = olv.sum(force,olv.times(away,danger)); } //FRIENDLIES var friends = og.center; for (var i = 0; i < os.length; i++) { if (os[i].friendly | !os[i].alive) { var offset = olv.diff(here,os[i].pos); var distance = olv.len(offset); var speed = ol.physics.speedToward(olv.diff(os[i].vel,o.me.vel),os[i].pos,here); var frend = 10; if (og.time > SPLINTERTIME & o.me.queen) {frend = 30;} var danger = frend/Math.pow(noneg(distance-TIME*speed),2); var away = olv.normalized(offset); friends = olv.sum(friends,olv.times(away,danger)); } } force = olv.sum(force,friends); //ENEMIES var enemies = og.center; var closest = 999; var closestship = o.me for (var i = 0; i < os.length; i++) { if (!os[i].friendly & os[i].alive) { //un-aggressive variant -- hoping my drones will take care of my queen's harassers if (os[i].dist < closest | os[i].dist/8 < closest & os[i].queen & !o.me.queen) { closest = os[i].dist; closestship = os[i]; } } } var speed = -80/olv.len(o.me.vel); if (o.me.queen) { speed *= 0; } var aim = closestship.pos; if (closestship.queen) { aim = olv.sum(aim,olv.times(closestship.vel,0)); } enemies = olv.times(olv.normalized(olv.diff(here,aim)),speed); force = olv.sum(force,enemies); //QUEEN DEFENSE if (o.me.queen) { var def = og.center; var worst = 0; var worstship = o.me; for (var i = 0; i < os.length; i++) { if (!os[i].friendly & os[i].alive & !os[i].queen) { //seems like queens these days don't attack... and frequently, the enemy queen is resposible for la reina's fatal over-fleeing var dist = os[i].dist; var speed = ol.physics.speedToward(olv.diff(os[i].vel,o.me.vel),os[i].pos,here); var danger = 25 /noneg(dist/2-TIME*speed+10); if (danger > worst) { worst = danger; worstship = os[i]; } } } var offset = olv.diff(here,worstship.pos); var away = olv.normalized(offset); def = olv.times(away,worst); if (worstship.dist - TIME*ol.physics.speedToward(olv.diff(worstship.vel,o.me.vel),worstship.pos,here) < 15) { label = "¡Olé!"; var def1 = rot90(o,def); var def2 = rot270(o,def); if (lugarscore(o,olv.sum(here,def1)) > lugarscore(o,olv.sum(here,def2))) { def = def1; } else { def = def2; } } force = olv.sum(force,def); } //QUEEN SOFT DEFENSE var soft = og.center; if (o.me.queen) { for (var i = 0; i < os.length; i++) { if (!os[i].friendly | !os[i].alive) { var distance = os[i].dist; var away = olv.normalized(olv.diff(here,os[i].pos)); soft = olv.sum(soft,olv.times(away,SOFT/distance)); } } } force = olv.sum(force,soft); force = olv.times(force,40000); var target; target = olv.sum(here,force); //make picadores se matan -- useful for testing la reina's dodging abilities if (!o.me.queen & DEBUGMODE) {target = og.center;} //SPLINTERING if (og.time < SPLINTERTIME & o.me.area_frac > 0.5 & !(o.me.queen & label == "¡Olé!")) { //branching based on a debug label? wow, i really am lazy var ourqueen = o.me; for (var i = 0; i < os.length; i++) { if (os[i].friendly & os[i].queen) { ourqueen = os[i]; } } if (o.me.pos[0] > 0) { target = olv.fromPolar([175*0.9,0]); } else { target = olv.fromPolar([175*0.9,Math.PI]); } var dvel = olv.times(olv.diff(target,here),2); var ddvel = olv.diff(dvel,o.me.vel); target = olv.sum(here,ddvel); label = "La Paseílla"; } if (closest < OY & !o.me.queen) { target = closestship.pos; label = "¡Olé!"; //too lazy to make a function for this... } suggested = ol.targeting.simpleTarget(o.me,target); if (o.me.queen & pendgame) {return step2(o);} return { torque: suggested.torque, thrust: suggested.thrust, label: label }; }; rot90 = function(o,vector) { var angle = o.lib.vec.ang(vector); var length = o.lib.vec.len(vector); return o.lib.vec.fromPolar([length,o.lib.ang.rescale(Math.PI/1.6 + angle)]); } rot270 = function(o,vector) { var angle = o.lib.vec.ang(vector); var length = o.lib.vec.len(vector); return o.lib.vec.fromPolar([length,o.lib.ang.rescale(-1*Math.PI/1.6 + angle)]); } noneg = function(x) { if (x < 1) { return 1; } else { return x; } } //allows one of two maxed-out values (ie negative ones) to override the other noneg2 = function(x,y) { if (x < y) { return 1; } else { return x; } } mind = function(a,v,p) { return (v*v)*(1/2 - 1/a) + p; } //if near 0, panic and apply A mind2 = function(a,v,p,t) { return (v*v)*(1/2 - 1/a) + p - v*t; } lugarscore = function(o,lugar) { var closest = 999; for (var i = 0; i < o.moons.length; i++) { var dist = o.moons[i].dist - o.moons[i].radius; if (dist < closest) { closest = dist; } } var borderdist = (o.game.moon_field - o.lib.vec.len(lugar)) - 30; if (borderdist < closest) { closest = borderdist; } return closest; } //IDEA: Apply unstoppable moon-force to border, ie treat border as inside-out moon? //THE PLAN: //SALVAGE QUEEN BEHAVIOR FROM SLOWS //WHICH ACTUALLY HAD A FAIRLY DECENT ENDGAME QUEEN var ANGLETOLERANCE = 1; var LOOKAHEAD = 0.35; var MOON = 7; var BORDER = 10; var FRIEND = 1; var FOE = -1; var QUEEN = -2; var ENEMYCLUSTERFACTOR = 0; var LOVE = -5; var LOVERADIUS = 20; step2 = function(o) { var myang = o.me.rot; var mypos = o.me.pos var torque = 0; var thrust = 0; var desiredAng = 0; //if about to collide, orient correctly var closestdist = 999; var closestship; for (var j = 0; j < o.ships.length; j++) { if (o.ships[j].dist < closestdist) { closestdist = o.ships[j].dist; closestship = o.ships[j]; } } if (false) { desiredAng = closestship.dir; ANGLETOLERANCE = 0.5 } else { var maxthrust = 1; //CONSTANT MODIFIERS FOR SUPER DUPER SPESHUL SITUAZIONEN if (o.me.queen) { FOE = 2; BORDER = 120; QUEEN = -0.25; ENEMYCLUSTERFACTOR = 0.1; MOON = 50; maxthrust = o.me.area_frac; LOVERADIUS = 10; } if (o.game.moon_field < 50 & o.me.queen) { QUEEN = -50; } var dc = extrapolate(o,o.me,LOOKAHEAD); var bestscore = 999; for (var i = 0; i < 360; i++) { var angle = (i/360)*2*Math.PI - Math.PI; var thisvec = o.lib.vec.sum(dc,o.lib.vec.fromPolar([0.01,angle])); var thisscore = 0; //START SCORING BLOCK //AVOID MOONS var moonscore = 0; for (var j = 0; j < o.moons.length; j++) { moonscore += MOON / (o.lib.vec.dist(thisvec,extrapolate(o,o.moons[j],LOOKAHEAD)) - o.moons[j].radius); } thisscore += moonscore; //AVOID BORDER thisscore += BORDER / (o.game.moon_field - o.lib.vec.dist(thisvec,o.game.center)); //LOVE THYSELF thisscore += Math.max(LOVE / o.lib.vec.dist(thisvec,o.me.pos), LOVE / LOVERADIUS); //AVOID FRIENDS var enemy = 0; var friend = 0; for (var j = 0; j < o.ships.length; j++) { var distance = o.lib.vec.dist(thisvec,extrapolate(o,o.ships[j],LOOKAHEAD)) if (o.ships[j].friendly) { if (false & !o.me.queen & !o.ships[j].queen & o.ships[j].area_frac > 0.75 & o.me.area_frac > 0.75) {distance *= -1;} friend = maxmin(FRIEND / distance,friend) ; } else { if (o.ships[j].queen) { enemy = maxmin(QUEEN / distance,enemy); } else { enemy = maxmin((FOE/(2*o.me.area_frac)) / distance,enemy) + ENEMYCLUSTERFACTOR*enemy; } } } thisscore += enemy; thisscore += friend; if (thisscore < bestscore) { bestscore = thisscore; desiredAng = angle; } } } var diff = o.lib.ang.diff(desiredAng,myang); torque = Math.max(-1,Math.min(1,10*diff-o.me.a_vel)); if (Math.abs(diff) < ANGLETOLERANCE) { thrust = 1; } if (o.lib.vec.len(o.me.vel) > 75) { maxthrust *= 0.5; } return { torque: torque, thrust: thrust*maxthrust, label : "¡Indulto!" }; }; extrapolate = function(o,obj,lookahead) { return o.lib.vec.sum(obj.pos,o.lib.vec.times(obj.vel,lookahead)); } maxmin = function(a,b) { if (Math.abs(a) > Math.abs(b) ) { return a; } else { return b; } } location_score = function(o,testingloc) { var score = 0; var moons = o.moons.length; for (i = 0; i < moons ; i++) { score += 1 / o.lib.vec.len(o.lib.vec.diff(o.me.pos,o.moons[i].pos)); } return score; } normalize = function(angle) { angle = angle%(2*Math.PI); if (angle > Math.PI) { angle -= 2*Math.PI; } return angle; }

recent battles, mutation 170

mutation 170 has not fought.

discuss The Bullfighters

comments powered by Disqus