AntiMirrorSystem

Robo Home | Changes | Preferences | AllPages

What is it?

The system used in Musashi to respond to MirrorMovement bots.

The idea.

There are a lot of possible approaches to that, but the one discused here is that: "if they wan't to follow me, be my guest...", my wife is trying to convince me to call it "Vem-Nenem", let's see (but u know the GirlPower)...

Bots using it.
• Musashi (obviously)
• Okami
• Marshmallow - Well, it uses an AntiMirrorGun even if it might not be like this system. It's one of the VirtualGuns and always fires at the future mirrorPoint (somewhat sloppily defined). When the virtual stats says it should be used it is used. Of course, later versions of M have broken VG arrays so it might not show that it can potentially trash mirrorers.

Known MirrorBots?. (help to fill...)

Why a system?

I have call it AntiMirrorSystem just because it can't fit in a Object Orientated Model any AntiMirrorTargeting by itself. The anti-mirror system concept that was used in Musashi's code relies in a tripod: Detecting, Moving & Aiming.

The tripod (Detecting, Moving & Aiming)

Detecting:
That is probably the most important and sensible part of the system, if it's not well planned and implemented u might loose points against the non-mirror bots instead of only gaining points against the mirrors.
In Musashi this was thinked aiming bots that mirror using the center of the field as reference (at least for the present). What i've done is quite simple:

• Calculate a vector that goes from me to the center (mirrorVector).
• Multiply the module of mirrorVector by 2.
• Get the end point of mirrorVector (mirrorPoint).
• Calculate the distance of the enemy to mirrorPoint (mirrorDist).
• Store the last 60 (empiric) mirrorDist values and calculate the average (mirrorAvg).
• If that value is lesser than mirrorSlack (set to 30, empiric again) then i presume that i found a MirrorBot?, and then switch to anti-mirror system.
• It can't detect PrairieWolf's mirror moving, that is not based on the center of the field.
• It fails a lot to detect OldManXP's mirror, witch i describe as a "loosen" mirror.
• Detects classical mirrors almost perfectly.
• It doesn't detects mistakenly(?) non-mirrors bots, and as such, it doesn't affect the "normal" behaviour of my bots.
That could obviously had beeing done without the vector issue, but since i have already a Vector class inside my bot... Another advantadge, i think, of using vectors is that it can easely adapted to detecting bots that doesn't mirror using the field center.

Moving:
Here resides the soul of the "Vem-Nenem" or "if they wan't to follow me, be my guest..." philosophy.
That is: The mirror bots use your movement against you, so let's use our movement against them. Afterall, u can predict were u are going to, they can't.
The key for accomplish this, is instead of deciding "on-the-fly" where you are going to move next, pre-calculate your positions for the next n ticks and store them somewhere (an ArrayList for example).
Musashi's particular implementation: Since Musashi's movement is based only in inversions of direction, i pre-calculate my next inversions for the next (2*(distance_to_enemy/11)) ticks and store them in an ArrayList.
My problem here, was to garantee that a wall wouldn't be on my way, and then mess out my pre-calculated inversions. I had also, to fix somehow it's trajectory, otherelse the pre-calculated inversions would be useless by themselves.
I had opted for a KISS solution for this: Once the mirror movement is detected, Musashi starts orbiting the center of the field instead of the enemy, and goes to a wall-safe orbit (radius = (int)Math.min(500, Math.min(field.height, field.width) - 100) / 2). This is a particular implementation, other bots would probably fit better other approach, the important here is to have a way to predict your own moving. Another approach would be, for example, start moving in a simple pattern. But if the MirrorBot? have a PM gun you can be vanished. Although that could be a simple and efficient approach if your gun is a PM (by moving in a predictable pattern, you can discard the pre-calculated moving, and you won't even need to link your gun to the moving... That is probably a good approach to a non-MegaBot.).

Aiming:
The easy part: Once you've had started moving in a pre-calculated way, it's only a matter of choosing the fire power, calculating the time that the bullet would take to reach him and "play the film" of your own stored moving applied and mirrored(?). Fire at will! It's like a simple PM without having to choose a sample and with almost 100% of chance in hitting it.

Conclusion and general considerations...

So, as i promissed to PEZ, here it is. Musashi's implementation is yet too crude, it can't reach OldManXP nor PrairieWolf (at least for the present). But bots like NaN that were actually beating Musashi (Musashi's scored ~39% against NaN, now it scores ~80%) now die like flies. I hope that this help other bots with the same problem, and also hope that it serves as an incentive on improving the MirrorBots? themselves(yes, i know that is like a bayonet poking their belly, but it's still a stimulus :). As ABC would say: "O mundo gira, a lusitana roda".

These are the general lines of the idea. You probably will find a better way to doing this, or a better way to fitting it into your bot. If I can give any recomendation, there it goes: do it KISS. Afterall, we aren't talking about beating DT nor Shadow...

Talk-a-lot:

To detect if I'm mirrored I just check if my enemy is within a certain distance of the mirrorPoint. This might make me mistakenly think I'm mirrored at times, but only very momentarily. From my tests this is very accurate on plain center-mirrorers. Of course I also fail on OldManXP which uses velocity a bit to smart. -- PEZ

I have started with that approach too, but taking an average had proved to be much more accurate. I can even detect and beat OldManXP if i adjust the mirrorSlack value to 50. The problem is that i start detecting other non-mirrors too... I strongly recommend u that averaging approach, it can last a little more to detect (depending on the wideness of the averaging), but is a lot more accurate. -- Axe

I like the idea with cicling the center when in anti-mirror mode. Bloody brilliant! -- PEZ

KISSes! (obviously straight ones, on the cheeks). Glad u liked! -- Axe

Do you do anything to take into account the lag of the enemy's movement compared to yours? (ie. the enemy has to see what your doing, and then copy it, meaning it will be at least 1 tick behind, possibly more) Could you not use a PM technique to detect, and basically compare your pattern to your enemy's pattern, and if they are the same, just mirrored, you have a mirror-bot regardless of the mirror-line (you would need to check horizontal, vertical and diagonal mirror-lines separately). The easy way to counter this system is simply to move the mirror-line, a random mirror line (changed every round) would work quite well... -- Tango

It's a very interesting idea. If you use old school heading-change and velocity the ideal mirror pattern will look exactly the same as the original. -- PEZ

Expect heading change would be *-1, surely? -- Tango

Would it? -- PEZ

• Yes. You are mirroring me, I turn right, you are going to turn left, aren't you? -- Tango
• No. I also turn right. Unless you are talking about VertiLeach style mirroring. -- PEZ
• VertiLeach would turn right, a normal mirror would turn left. Imagine this: The mirror line is vertical and in the middle. I am in the middle of the left half, you are in the middle of the right half. I turn right 90 degrees, so i am facing the mirror line. You turn left 90 degrees so you are facing the mirror line too. If you turned right, i would be looking at the back of my reflection, which is impossible in a single mirror. -- Tango
• Think again - if you were in the middle of the top-left quadrant facing up, a normal (non-VertiLeach-style) mirrorer would be in the bottom right quadrant facing down. When you turn right 90 degrees to face right, the mirrorer turns right 90 degrees to face left. VertiLeach, however, would be in the top-right quadrant facing up and then would turn 90 degrees left to face you (of course, in reality, VertiLeach would turn either left or right to attempt to be 300 or so pixels away from you). -- Kawigi
• Come on people... Don't you have a mirror at home? -- Axe
• Not a HumplePieLite? kind of mirror. Do you? =) A VertiLeach kind of mirror we all have I guess. Tango consider a classic PM gun. You don't have to think about what quadrant the enemy lives in at the moment, right? You just play forward its matching heading change and velocity history. -- PEZ
• If you are in the oposite corner, surely that means you are using a diagonal mirrorline, not a vertical one, like I was talking about... -- Tango
• OK, for the record. In my book "normal" mirroring is the diagonal one. VertiLeach was the first of its kind using real world mirroring I think. And it's still alone with it too. Some version of OldMan used it, but not any longer. And I challenge any of you to make a detection system that accurately can identify VertiLeach as a mirrorer. It might prove as hard as with OldManXP which I think is a bit inspired by Verti's mirror fuzzying. -- PEZ
• mathematically spoken, mirroring in this case is point reflection. it is easy to see that point reflections can be constructed with two line reflections (where a line reflection is normal mirroring like VertiLeach does). with one line reflection the direction of rotation will change with two it will be the same as before (draw a triangle with edges A, B and C in clockwise direction, now make a point reflection and the mirrored points A', B' and C' will also be in clockwise direction). so if bot A turns right bot B has to turn right too. -- rozu

About the lag, u r right, very good observation. Indeed i use something to compensate it: the mirrorSlack (see the definition above), witch is precisely the lag.
About using vel & heading change in detection: As i said, there are countless ways on doing it, that is one, no doubts (probably it wouldn't get OldManXP either, but it should work for PrairieWolf). I use vector operations because is what i use in my PM gun (i don't use directly vel & heading for PM, but vector operations on the stored positions). Another reason that I found for using that kind of detection, is based on my particular solution of moving in a wall-safe orbit (see above), it seems more natural to me.
The important thing is to find a way on doing the detection and moving that seems natural to you and fit well in your bot. Regardless of the path that you trail, less is better. So, if you feel more comfortable in not using vectors, the best is not to use it. -- Axe

I also thought many times about how to make a working AntiMirrorSystem and the most effective way to find out if an enemy is mirroring me seems to me a mirror counter: Everytime you scan your opponent check if it mirrors you like:

` boolean mirroring=Point2D.Double.distance(getX(),getY(),getBattleFieldWidth()-e_x,getBattleFieldHeight()-e_y)<16 `
.If it does, add 1 to your mirror-counter if not reset it to 0.Then you just have to check each tick if this mirror counter is higher then a certain value and you can decide if you should use your normal behavior ( movement and gun ) or an AntiMirrorBehavior? that slaughters the mirror bot with a hit rate of 100% :D --deathcon

Deathcon, that is precisely how I implemented my mirror detection in Unnamed (although you have to widen the distance to about 30 for it to be effective). I also have an "anti-mirror counter" to detect if the enemy has stopped mirroring. This gives a buffer at both ends. -- nano

Damn it.I thought i was the first one that had this idea. :((( --deathcon

Robo Home | Changes | Preferences | AllPages