# Talk:Laser Targeting

## From old wiki's Laser Targeting page

How would you randomly select among the most usual obesrvations? I've been struggling with that for quite a while now and I can't think up an algorithm apart from just selectin one of the, say, three most common observations. But I would want it to work more like Random.nextGaussian(). Not a normal distribution of course but a distribution based on the size of each observation segment. -- PEZ

A way to select a random point based on the observed distribution is to create a kind of histogram, count the total number of observations, select a random number in the range and advance trought the histogram till you reach it. Another way is to put then in an array and select just one (because the most common repeat more frequently, the selection would be OK). -- Albert

Ah, yes, if you keep the histogram at a reasonable resolution that would work well. I will try that. -- PEZ

BTW. Marshmallow uses LaserTargeting for its statistical gun (though it's called "sector aim" in the code). The difference is that it checks every tick after a bullet is fired if it has either hit (see Marshmallow/CodeSnippets for that code) or missed and only then checks the "laser beams". This makes it more accurate since few enemy bots allow you to estimate a very accurate BulletTravelTime. -- PEZ

Good idea. I guess you could also easily convert it to get a Wave-like system. -- tobe

Well, I think it is very like Wave (as far as I have understood that concept). -- PEZ

What's the difference between this and pattern matching? :-/ -- Tango

Do you mean the difference between PatternMatching and LaserTargeting? If so the difference lies in that

• PatternMatching looks for a movement pattern in the past that looks like the most recent one and from there it replays the movement of the bot to figure out its destination.
• While LaserTargeting simply records how many times each lateral angle sector is used and then uses this information to aim (fireing at often used sectors more often than others). Marshmallow divides the angle space between -40 and +40 degrees into 11 sectors.

Another way to look at the difference is that LaserTargeting makes an advanced bot as TheArtOfWar an easy target since it's ShrapnelDodging system very often brings it to the sectors around -16 and +16 degrees from its original location. While PatternMatching (at least Marshmallows simple implementation) doesn't work very well since the same dodging system creates a too wide spectre of movement patterns. -- PEZ

Ok, it seems i misread something somewhere... :-/ -- Tango

Well, ?iley seems to be able to combine these two systems so the question is very relevant. -- PEZ

FloodHT (my work in progress) is currently attempting to use this for pattern analysis as well, which is a good idea, assuming your opponent is moving primarily relative to you (i.e. - excellent against my CircleBot, not as useful against SpinBot) -- Kawigi

Ok, I havent really understood the basis of this, it seems to be a combination of GuessFactorTargeting and some angular stuff. Is this just one of the descriptions of the early GF, or is it more? -- Jokester

Or is it less? I think it would be better to describe it as a stepping-stone to waves, but the idea of what should be done with them is distinct from GuessFactorTargeting. -- Kawigi

Is it? I would say Marshmallow had the exact same idea as GuessFactorTargeting about what to do with them. It's definately less that GF targeting though. Technically both LaserTargeting and GF targeting could be implemented using Waves, VirtualBullets, a simple estimate of BulletTravelTime or some other thing.(Marshmallow used waves, that's clear to me now). Conceptually LaserTargeting is GF targeting without the brilliant insight that you should regard the relative (to current situation) angular/lateral movement of your enemy rather than the raw angle difference. This

1. doubles (and then some, see point 3 below) the amount of data you need
2. doubles the learning time
3. and if you don't segment on lateral direction you get a significant decrease in accuracy (GF targeting doesn't need segmenting on lateral direction)

Or using alternative wording; Using LaserTargeting over GuessFactorTargeting is stupid if you understand both concepts.

-- PEZ