The Bullfighters

mutation 44

// ----------------------------------------------------------------------------- // ~ The Klutzes ~ // @sevenfive // ----------------------------------------------------------------------------- ai.step = function(o) { //CONSTANTS TIME = 0.25; if (o.me.queen) {TIME = 0.4;} SPLINTERTIME = 5; OY = 10; GREED = 10; ENEMYCLUSTER = 0.3; //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;} 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 danger = 1000/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 = 20; var qtime = 1; if (o.me.queen) {edge1 = 160; qtime = 1;} if (o.me.queen & endgame) {qtime = 2;} 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;} 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 frend = 10; if (og.time > SPLINTERTIME & o.me.queen) {frend = 30;} var danger = frend/Math.pow(distance,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) { if (os[i].dist < closest | os[i].dist/2 < closest & os[i].queen & !o.me.queen) { closest = os[i].dist; closestship = os[i]; } } } var speed = -20/olv.len(o.me.vel); if (og.moon_field < 50) { speed *= 1; } if (o.me.queen) { speed *= 0; //10/Math.pow(closest,1); } 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) { 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-TIME*speed+10); if (endgame) {danger *= 0.5;} 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 (false & lugarscore(o,olv.sum(here,def) > Math.max(lugarscore(o,olv.sum(here,def1),lugarscore(o,olv.sum(here,def2)))))) { def = def; } else { if (lugarscore(o,olv.sum(here,def1)) > lugarscore(o,olv.sum(here,def2))) { def = def1; } else { def = def2; } } } force = olv.sum(force,def); } 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) {target = og.center;} //SPLINTERING if (og.time < SPLINTERTIME & o.me.area_frac > 0.5) { 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 | closest < 10 & og.moon_field < 50) { target = closestship.pos; label = "¡Olé!"; } suggested = ol.targeting.simpleTarget(o.me,target); 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/2 + 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/2 + angle)]); } noneg = function(x) { if (x < 1) { return 1; } else { return x; } } 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)); if (borderdist < closest) { closest = borderdist; } return closest; } //IDEA: Apply unstoppable moon-force to border, ie treat border as inside-out moon? /* // ----------------------------------------------------------------------------- // ~ The Klutzes ~ // @sevenfive // ----------------------------------------------------------------------------- ai.step = function(o) { //CONSTANTS TIME = 0.25; if (o.me.queen) {TIME = 0.4;} SPLINTERTIME = 5; //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 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 danger = 1000/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 = 20; var qtime = 1; if (o.me.queen) {edge1 = 160; qtime = 1;} 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;} 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) { var offset = olv.diff(here,os[i].pos); var distance = olv.len(offset); var frend = 10; if (og.time > SPLINTERTIME & o.me.queen) {frend = 30;} var danger = frend/Math.pow(distance,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].invincible) { if (os[i].dist < closest | os[i].dist/2 < closest & os[i].queen & !o.me.queen) { closest = os[i].dist; closestship = os[i]; } } } var speed = -20/olv.len(o.me.vel); if (og.moon_field < 50) { speed *= 2; } if (o.me.queen & og.moon_field > 50) { speed *= 0; //10/Math.pow(closest,1); } var queenpos = here; for (var i = 0; i < os.length; i++) { if (os[i].friendly & os[i].queen) { queenpos = os[i].pos } } enemies = olv.times(olv.normalized(olv.diff(here,closestship.pos)),speed); var iamsmallest = true; for (var i = 0; i < os.length; i++) { if (olv.len(olv.diff(os[i].pos,queenpos)) <= olv.len(olv.diff(here,queenpos)) & os[i].friendly & !os[i].queen) { iamsmallest = false; } } var smallestlabel = ""; //nobody steps up after a few seconds... if (false & iamsmallest & !o.me.queen) { smallestlabel = ":)"; var dpoint = olv.sum(queenpos,olv.times(olv.normalized(olv.diff(here,queenpos)),50)); var dvel = olv.diff(here,dpoint); var defq = olv.times(dvel,speed); force = olv.sum(force,defq); } else { 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].invicible) { var dist = os[i].dist; var speed = ol.physics.speedToward(olv.diff(os[i].vel,o.me.vel),os[i].pos,here); var danger = 10/noneg(dist-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) < 20) { var def1 = rot90(o,def); var def2 = rot270(o,def); if (olv.len(olv.sum(here,def1)) < olv.len(olv.sum(here,def2))) { def = def1; } else { def = def2; } } force = olv.sum(force,def); } force = olv.times(force,40000); var target; target = olv.sum(here,force); //SPLINTERING if (og.time < SPLINTERTIME & o.me.area_frac > 0.5) { 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); } if (closest < 10 & !o.me.queen) { target = closestship.pos; } suggested = ol.targeting.simpleTarget(o.me,target); return { torque: suggested.torque, thrust: suggested.thrust, label: smallestlabel }; }; 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/2 + 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/2 + angle)]); } noneg = function(x) { if (x < 1) { return 1; } else { return x; } } //THE JUNKYARD /* var querida = ola.diff(o.me.rot,olv.ang(force)); var qdiff = o.lib.ang.diff(querida,o.me.rot); torque = Math.max(-1,Math.min(1,10*qdiff-o.me.a_vel)); if (Math.abs(qdiff) < 1.2) { thrust = 1; } */

recent battles, mutation 44

Result Against When Recording
The Klutzes mutation 452 1549 days ago 11.52 sec
The Bullfighters mutation 92 1550 days ago 35.755 sec
The Klutzes mutation 452 1550 days ago 23.35 sec
The Tests mutation 254 1550 days ago 31.21 sec
The coffeebeans mutation 146 1550 days ago 10.71 sec
The Fluid dynamics mutation 23 1550 days ago 37.01 sec
The Circle Zone mutation 124 1551 days ago 17.025 sec
The Circle Zone mutation 124 1551 days ago 51.47 sec
The Enemy Gate is Down mutation 20 1551 days ago 50.87 sec
The Bullfighters mutation 49 1551 days ago 22.245 sec

discuss The Bullfighters

comments powered by Disqus