Difference between revisions of "Talk:Historical Velocity Recall"
(→Majorly revised this article: "Recall"!) |
Revision as of 06:09, 21 November 2007
Majorly revised this article
That old page / code example was a bit long for what a simple idea this was, so I made a much simpler page / example and abstracted out the linear targeting part. --Voidious 04:15, 21 November 2007 (UTC)
- Um... is this page supposed to be called Historical Velocity Recall, not Historical Velocity Recal? --
AaronR
04:39, 21 November 2007 (UTC)- Oh, maybe that's it! I was asking the exact same question - what the heck could "Recal" be? Was even talking about it out loud to someone. Yeah, let's rename it... --Voidious 05:08, 21 November 2007 (UTC)
From old wiki's Historical Velocity Recal page
This is a method of targeting I'm developing for BlueMind.
This method basicaly uses CircularTargeting, but instead of using the current enemy's velocity, you keep a log of all of its recorded velocities: and shooting at the "highest" point in the graph.
This is achieved throught the use of a vector and array pair.
Implementation
static Vector velocityMap; double[] vArray = new double[321]; Velocity enemyV = new Velocity(e.getVelocity()); velocityMap.addElement(enemyV); for(int flush=0;flush<321;flush++){ vArray[flush]=0; } Velocity temp = new Velocity(0); double temp2=0; out.println(velocityMap.size()); for(int index=0; index < velocityMap.size(); index++){ temp = (Velocity)velocityMap.get(index); temp2 = (temp.v+8)*20; vArray[(int)temp2]++; } Count target = new Count(); for(int scan=0; scan < 321; scan++){ if(vArray[scan]>target.threshHold){ target.value = (scan/20)-8; target.threshHold=vArray[scan]; } } double power = (2200/Math.pow(e.getDistance(),1.15)); if(power>=getEnergy()){ power = getEnergy()-.1; } if(power>3) power=3; if(power<.1) power=.1; double dist = e.getDistance(); double playerX = getX(); double playerY = getY(); double bearing = (Math.toRadians(getHeading())+e.getBearingRadians())%(2*Math.PI); double enemyX = playerX + (dist * Math.sin(bearing)); double enemyY = playerY + (dist * Math.cos(bearing)); double bulletV = 20 - 3 * power; double enemyH = e.getHeadingRadians(); enemyH += (enemyH-lastH)/(getTime()-lastScanT); double gunH = getGunHeading(); double predictD = e.getDistance(); double predictX = enemyX; double predictY = enemyY; double rawV = target.value; double theta = 0; double time2 = 0; double t=0; double timeTheta = 0; double time0=dist/bulletV; int deltaT = 0; int others = getOthers(); double lastDiff=Double.POSITIVE_INFINITY; for(deltaT=-1000;deltaT<=1000;deltaT++){ t = time0 + deltaT; predictX = enemyX+((rawV*t)*Math.sin(enemyH)); predictY = enemyY+((rawV*t)*Math.cos(enemyH)); if (predictX < 20){ predictX = 20; }else if(predictX > battleFieldWidth-20){ predictX = battleFieldWidth-20; } if (predictY < 20){ predictY = 20; }else if(predictY > battleFieldHeight-20){ predictY = battleFieldHeight-20; } predictD = Point2D.Double.distance(playerX,playerY,predictX,predictY); timeTheta = Utils.absoluteBearing(playerX, playerY, predictX, predictY); timeTheta = Utils.normalizeBearing(timeTheta - gunH); time2 = (predictD / bulletV) + (timeTheta / 20); if(Math.abs(t-time2) <= lastDiff){ theta = Utils.absoluteBearing(playerX, playerY, predictX, predictY); theta = Utils.normalizeBearing(theta-gunH); lastDiff = Math.abs(t-time2); } } turnGunRight(Utils.normalizeBearing(theta)); lastH = enemyH; lastScanT = getTime(); if(getEnergy()>0.2) fire(power);
This sounds very similar to the aiming method that Stampede 1.3.3 currently uses (except it has both a linear and a circular version in a VG array). I have not been able to improve it much further than the gun currently in the RR; however that is probably due to my sloppy implementation rather than a weakness in the concept. I'm curious to see how you fare with this. --wcsv