Is wiki wrong about MEA?

Jump to navigation Jump to search

Is wiki wrong about MEA?

I've been using the asin(Vbot/Vbullet) formula for ages. But in my mind it should be atan(Vbot/Vbulet). Am I right?

It is not a big deal to over estimate MEA with asin. but the over estimate could be as bad as 30% for bullets with fire power equal to 3.

Beaming (talk)04:43, 17 September 2017

asin formula is when your opponent move perpendicular to your head on angle atan formula is when your opponent move perpendicular to your hit angle ;)

However, the first one is greater, therefore the max (of them).

Xor (talk)06:05, 17 September 2017

I am arguing that the asin(Vbot/Vbullet) formula has an assumption in its derivation, which leads to the overestimation of the angle. The easy way to see that use of the asin is wrong is to assume that bullet speed is equal to the bot then asin gives 90 degrees, but you will never hit the bot this way, by symmetry MEA in this case is 45 degrees. Note that atan does it automatically.

Beaming (talk)15:11, 17 September 2017

90 degrees is correct, since you know the bot is restricted to that half of the field, since if it came towards you your bullet could catch up with it. To make it a little more absurd, what if the maximum bullet speed was 7, and bot speed was 8? According to the atan formula, your slow bullets will still hit the bot, even though a real strategy could be for the bot to run away faster than the bullets go. The asin formula is not defined in this case, which makes more sense, since the bot might never get hit (assuming infinite field size of course).

Let's rephrase this: if you were the bot making the movement (not the firer), then what angle would be optimal for you to move at? Well, the one that lets you access the largest MEA, of course. What gives you the largest MEA? Not having a component of your movement going towards the fire location. Think of the x and y components separately, for the atan movement path if the bullet is fired on x axis then by orbiting the fire location you are reducing the x component of your distance to the fire location in the hopes of increasing the y component more. However this tradeoff is not worth it since it makes the bullet hit you sooner, meaning you cannot access the higher MEA.

In the case when the firer is moving and there are multiple bullets in the air each from different locations, it isn't always possible to move perpendicular to the original wave because you are in 2D and can only move perpendicular to one line at a time, and you are trying to dodge multiple bullets. But if you chose to, and didn't run out of space, you could make your MEA right up to the asin(vbot/vbullet), for a single wave at least. And if the enemy gun didn't accept or shoot at these higher angles, you could dodge all of their bullet like this.

Skilgannon (talk)15:52, 17 September 2017

You've made one thing wrong — it's the bot, not you, that selects the escape angle. if the bot move perpendicular to you, and your bullet speed is the same — you will not hit him definitely. Whatever formula you use, the fact of not being able to hit will never change, in this case. Therefore it still can't prove it's wrong.

The only way to prove asin formula is wrong is by giving a formula that is greater than or equal to asin formula all the time (and that formula must satisfy the game physics as well)

Xor (talk)00:08, 18 September 2017

Anyway, if your opponent moves orbital, not perpendicular, asin formula will make higher power bullet shoot at an angle greater than needed, and lower power the less — decrease hit rate. Therefore using max_vel/bullet_speed withou trig may be better in this case (if you don't cape gfs, it will never be an issue)

Xor (talk)00:12, 18 September 2017

Well, the asin gives MEA where M stands for maximum :). Also, there is a hidden assumption that the bullet speed is always faster than a bot (i.e. a bot cannot run away from the bullet) and that the battlefield is infinite.

This asin is probably the oldest formula in my framework. It is dated by 2015 and was used even in an earlier bot. Yesterday, I decided that I am ready to challenge it. Actually, it was part of the effort to calculate the battlefield constrained MEA. I think I finally get it, though it still assumes that a bot can reach max speed instantaneously.

Now I expect my guns to be better especially in melee. I hope they will not shot into a wall when aiming at Diamond hiding in the corner. Hopefully my bot will move up the ladder a bit.

Beaming (talk)01:29, 18 September 2017

The thing is, if the bot moves slightly away then it increases the bullet flight time, allowing the bot to reach a higher MEA than just an orbit or chord.

Personally, in DrussGT I use a precise MEA since it gave better results. But if you have some limitation on whether the bot can exceed the calculated MEA (for example you log them to bins) then the asin is better, otherwise bots could potentially move to angles you can't shoot at.

Skilgannon (talk)11:26, 17 September 2017

Are you using precise MEA to scale? or just to cut. From the version history I think it is the latter, but Understanding DrussGT says former ;)

Xor (talk)11:46, 17 September 2017


Skilgannon (talk)14:01, 17 September 2017
I've just calculated it. If it is correct moving away helps.
            latVel = Math.sin(angle) * 8;
            advVel = -Math.cos(angle) * 8;
            timeToHit = distance / (bulletSpeed + advVel);
            mea = latVel / (distance - (timeToHit * advVel) / 2) * hitTime;
This is the formula. It thinks that the bot is moving at full speed and with brute force search I got these results:
Bullet Power 1:
LatVel: 7.762365810207972 AdvVel: -1.9353751647973414
Bullet Power 2:
LatVel: 7.6504380477042835 AdvVel: -2.338973637781894
Bullet Power 3:
LatVel: 7.468643411977614 AdvVel: -2.8669435963624013
Distance doesn't change anything if it isn't zero.
Dsekercioglu (talk)14:40, 17 September 2017

timeToHit is not taking in account that the bullet moves at some angle too, i.e. we need to use bulletSpeed*cos(MEA). In above we assume that 'a' is angle between line connecting bots and the velocity of the target.

The last line is not precisely correct as well. There should be no factor of 2, and you forgot the atan. It should be

 mea = atan( latVel / (distance - (timeToHit * advVel)) * hitTime );

But the last thing could be simplified a bit if you notice that

latVel = bulletSpeed*sin(MEA)

Moving away is always bad idea from the MEA prospective within robocode physics.

Beaming (talk)15:07, 17 September 2017

Look at the values that he posted for latVel vs advVel, all with the same 8 speed. For a very small reduction in latVel you can get a big increase in advVel. Increased advVel means you get a longer time until the bullet hits, so in that extra time you can add more latVel components, giving you a higher MEA. This is offset somewhat by being further away, so your latVel/distance is slightly smaller so each latVel increases the MEA a bit less. But this is more than compensated by the extra time until the bullet hits.

Skilgannon (talk)16:02, 17 September 2017

Aren't we confusing increase time to hit with increase EA? Longer time to hit has an advantage to decrease bot shadow, but it is not nesesary results in increase of EA.

Continuing our discussion of border cases, if bullet and bot have the same speed. The best strategy is run away from the firing bot. The bullet will never catch up, but the EA is the smallest possible here, i.e. zero.

Beaming (talk)17:06, 17 September 2017

I run my simulations. You guys are correct asin(vBullet/vBot) is the correct formula.

Now back to the drawing board to see where the logic fails me.

Beaming (talk)21:42, 17 September 2017

It is not the correct one. It just has a higher value than the real MEA all the time so it works.

Dsekercioglu (talk)10:42, 18 September 2017

No, traditional MEA is correct, as long as wave speed > robot speed.

I can prove that, but not formally.

If your speed < wave speed, you'll always be hit.

Since you'll always be hit, that's all about where you are hit.

Assume that there is one point you are hit, and that point gives you max escape angle — If you don't go there directly (by a straight line), math says you'll always have a shorter path, which gives you extra time. And you can always use that time to increase your MEA, which contradicts to "that point gives you max escape angle". Therefore MEA must be reached by moving along a straight line.

Since MEA must be reached by following a straight line — All the possible hit location forms something similar to ellipse — however I yet not proved it is an ellipse, but it looks like that, and when wave speed = 2 * robot speed, it is an exact circle (which I have a proof).

Anyway, since it looks like an ellipse, the MEA is always reached when you move perpendicular to the HOT angle.

Xor (talk)12:29, 18 September 2017

Oh' I missed that part. If you are faster than the bullet MEA can't be calculated because it keeps increasing.

Dsekercioglu (talk)14:35, 18 September 2017

No. It is always easier to go by a straight line but for example you've calculated a MEA of Pi radians. Going directly doesn't help because even if we arrived earlier than the orbital one, the wave could hit. I'll make some calculations to be sure that it is true with smaller angles too.

Dsekercioglu (talk)19:15, 18 September 2017