Difference between revisions of "User:Nat/TargetingProblem"

From Robowiki
Jump to navigation Jump to search
(New page: Can anyone answer my question? I've some targeting system that I create it accidentally and it work well (for those nanobot): <pre> double absBearing, vel; // find average velocity avgV...)
 
(explanation)
Line 30: Line 30:
 
Note: I don't have answer, this is not a joke!<br />
 
Note: I don't have answer, this is not a joke!<br />
 
Note: Please answer on this page, not a discussion page!
 
Note: Please answer on this page, not a discussion page!
 +
 +
----
 +
 +
Well, having <code>Math.sin(e.getDistance())</code> is a huge randomizer, so I'd definitely call this a form of random targeting. As I'm understanding the code, it seems like <code>avgVelocity < 0.00001</code> will only be true if the enemy doesn't move for a while, and in that case vel = 0, so you'll be shooting head-on. Other than that special case, it looks like you're shooting at a random angle between Math.asin(4.5 / bullet speed) and its inverse; I don't think you'll ever hit a bot that just orbits you without ever stopping, though, because the max escape angle is Math.asin(8 / bullet speed). But I'm just giving this a quick look right now, sorry if I misunderstood something. --[[User:Voidious|Voidious]] 17:35, 14 January 2009 (UTC)

Revision as of 19:35, 14 January 2009

Can anyone answer my question?

I've some targeting system that I create it accidentally and it work well (for those nanobot):

double absBearing, vel;

// find average velocity
avgVelocity = (avgVelocity + Math.abs(vel = e.getVelocity())) / 2; // the avgVelocity is preloaded as 4

// Targeting
setTurnGunRightRadians(robocode.util.Utils.normalRelativeAngle(
	(e.getBearingRadians() + getHeadingRadians()) + 
	Math.asin(
		// This is a magical line! at first it look like this:
		// Math.sin(e.getDistance()) * vel
		// but for hit StopNGo movement, I must assume a magic velocity in order to
		// hit it. I also need an average velocity in order to hit SittingDuck!
		Math.sin(e.getDistance()) * ((avgVelocity < 0.00001 || vel > 0.5) ? vel : 4.5 * ((vel > 0) ? 1 : -1))
		/ (20 - 3 * 1.9)
	)
	- getGunHeadingRadians()
));

// 2 is cheaper than 1.9!
setFire(2D);

That code copy almost exactly from one of my robot using it (not yet released). Can anyone answer me how this gun hit so much, or it just one kind of RandomTargeting?

Note: I don't have answer, this is not a joke!
Note: Please answer on this page, not a discussion page!


Well, having Math.sin(e.getDistance()) is a huge randomizer, so I'd definitely call this a form of random targeting. As I'm understanding the code, it seems like avgVelocity < 0.00001 will only be true if the enemy doesn't move for a while, and in that case vel = 0, so you'll be shooting head-on. Other than that special case, it looks like you're shooting at a random angle between Math.asin(4.5 / bullet speed) and its inverse; I don't think you'll ever hit a bot that just orbits you without ever stopping, though, because the max escape angle is Math.asin(8 / bullet speed). But I'm just giving this a quick look right now, sorry if I misunderstood something. --Voidious 17:35, 14 January 2009 (UTC)