FAQ  •  Register  •  Login

Need help with SuperBot

<<

Unknown

User avatar

Posts: 183

Joined: Mon Mar 08, 2010 4:48 pm

Post Wed Jun 30, 2010 12:26 pm

Need help with SuperBot

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

karamazovapy

Posts: 1567

Joined: Tue Feb 23, 2010 7:52 pm

Post Wed Jun 30, 2010 12:54 pm

Re: Need help with SuperBot

I have no doubt that works, but it sounds like a relatively heavy way to aim.
<<

Unknown

User avatar

Posts: 183

Joined: Mon Mar 08, 2010 4:48 pm

Post Wed Jun 30, 2010 2:00 pm

Re: Need help with SuperBot

Probably. I haven't thought up another method of how to do it though.
<<

furbuggy

Posts: 267

Joined: Mon Mar 08, 2010 5:34 pm

Location: Mesa AZ | Ithaca NY

Post Mon Jul 05, 2010 9:41 pm

Re: Need help with SuperBot

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?
BAM! I'm back.
<<

Unknown

User avatar

Posts: 183

Joined: Mon Mar 08, 2010 4:48 pm

Post Tue Jul 13, 2010 11:16 pm

Re: Need help with SuperBot

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.
<<

watusimoto

Site Admin

Posts: 1558

Joined: Tue Feb 23, 2010 7:07 pm

Location: Quartz's mom's house

Post Mon Jul 19, 2010 6:31 am

Re: Need help with SuperBot

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.

Return to Bots

Who is online

Users browsing this forum: No registered users and 13 guests

cron