Perceptual melee radar
The highlighted comment was created in this revision.
I tried building a perceptual bot a while ago. The hardest problem I found was how to make a melee radar without storing any data and without accessing getScannedRobotEvents().
A second radar event in the same tick overrides the first and the bot keeps changing targets. Didn´t find how to overcome this problem yet.
Not sure if this is what you are looking for, but you can use clearAllEvents() within the onScannedRobot(..) function. This clears all remaining scan events.
The problem is the last radar event overrides the others. With clearAllEvents() the first radar event overrides the others. In practice, both make perceptual bots change targets every tick in melee, and the performance is awful.
I was looking for something to lock onto the same target for many scans.
Hmm. Not sure if this is within the rules but you can try to combine a gunlock radar with distance. Lets say you set your radar to turn 4*360degree and the distance check to 200 if you have no target increase the distance by 200 if you turned 360degree and so on until radar is 0 or you have found a target within the distance. If you find a target within the distance you lock it with the getGunHeat() or until it leaves the current distance. Hmm, just a quick thought and not well indicated by me, but you should get the idear :).
With perceptual bots you have to fit all the logic inside a single scan event. So, "if you have no target" is quite hard to calculate, if not impossible, since you need to combine data from many scan events together.
The problem lies in scanning multiple bots in a single tick, resulting in many scan events, being triggered not in the order you want. Watch BotCatcher in melee and you will understand what is the problem I´m trying to solve.
Maybe I´ll try something like a width lock. The thinner the scan arc, the more likely the radar will scan the same bot, and only that bot, each tick.