Page 1 of 1

Need help with SuperBot

PostPosted: Wed Jun 30, 2010 12:26 pm
by Unknown
I can't get the aim code to work right - I know the method works, because I've done it in Flash.
Here's the method from Flash:
  Code:
var guessOfPosition:HPoint;
var t:Number = distanceTo(target) / 10;
const iterations:uint = 5;
for (var i:uint = 0; i < iterations; i++)
{
    guessOfPosition = target.location.duplicate();
    guessOfPosition.translateSetXY(target.motion.xSpeed * t, target.motion.ySpeed * t);
    guessOfPosition.translateSetXY( -motion.xSpeed * t, -motion.ySpeed * t);
    t = location.distanceToPoint(guessOfPosition) / 10;
}
var firingAngle:Number = location.directionToPoint(guessOfPosition);


Basically, I predict where the other ship will be in T amount of time. Then I set T to how long it will take for the projectile to reach that predicted location, and repeat. Each iteration, the position is more accurate. At the end I take the direction from the bot to the last predicted location, and fire in that direction.

The problem with my bot is that I can get in certain spots near it and go a constant velocity without the bot hitting me.

OR, Wat, you could just update your aim function. Please. My bots' aims suck.

Pastebin - SuperBot Beta

Re: Need help with SuperBot

PostPosted: Wed Jun 30, 2010 12:54 pm
by karamazovapy
I have no doubt that works, but it sounds like a relatively heavy way to aim.

Re: Need help with SuperBot

PostPosted: Wed Jun 30, 2010 2:00 pm
by Unknown
Probably. I haven't thought up another method of how to do it though.

Re: Need help with SuperBot

PostPosted: Mon Jul 05, 2010 9:41 pm
by furbuggy
Hero's Distance from Pt. 1 - Hero's Distance from Pt. 2 = Velocity (includes direction and speed). Position of Pt. 2 + Velocity(time) = Position of Pt. 3. Right? So could you just have the Points equal to where the closest enemy ship is every .01 secs? Then have the bot shoot at Pt. 3, and it will always lead the ship by the time rating + .01 sec.

I think that's right, but maybe that's not the best way to aim?

Re: Need help with SuperBot

PostPosted: Tue Jul 13, 2010 11:16 pm
by Unknown
Nope. It takes a look at how long it will take to get the projectile to the predicted position of the enemy, then recalculates the predicted position of the enemy based on that amount of time. Then it repeats. With each cycle, it should get more accurate.

Re: Need help with SuperBot

PostPosted: Mon Jul 19, 2010 6:31 am
by watusimoto
Doesn't the getFiringSolution() method do this exact thing? It works just as the turret's aim function does, taking projectile and target speed into account, doing all the calculations for you.