Need help with SuperBot
Posted: Wed Jun 30, 2010 12:26 pm
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:
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
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