[Home]HistoricalVelocityRecal

Robo Home | Changes | Preferences | AllPages

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);

--UnderDark

Question, Comments, Contributions:


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

Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited September 2, 2005 14:23 EST by UnderDark (diff)
Search: