Very incomplete try at using KNN for an updater

Well, after reading all the talk about using KNN in an updater, I wanted to try my hand at it. I took the output from Speljohan’s tool to parse RSBot’s hooks and I took the previous revision of runescape.jar and tried my hand at it. According to the updater, it only doesn’t identify 1 class completely, but the output I was using to see if they were right wasn’t correct itself, so I couldn’t really test them all, but for the classes I did check, they were correct.

I was just wondering if I was using the KNN algorithm correctly, so if anyone would mind downloading this and looking over it, I’d be appreciative.

Download link is at the bottom of the post, if you’re interested in looking at it.

The output I got:

Parsing classes...Done. [877 ms] Calculating field references...Done. [30 ms] Calculating method references...Done. [62 ms] Parsing classes...Done. [388 ms] Calculating field references...Done. [30 ms] Calculating method references...Done. [56 ms] NodeSub: we Model: ka Signlink: ge RSAnimable: oda RSObjectDefLoader: mk DetailInfo: vw RSPlayerComposite: ah RSAnimableNode: lr NodeSubQueue: re RSItemDef: su RSObjectDef: su RSInteractable: vs Cache: jt Render: ha RSObject: tq TileData: s NodeDeque: ada RSPlayer: bs RenderData: ql Node: efa RSCharacter: iw RSItem: dv Reference: fc RSNPCNode: uba MenuItemNode: cs Graphic: maa ServerData: cr RSInterface: sca NodeListCache: se RSNPC: kd Client: client RSObjectComposite: qea SoftReference: iu DetailInfoNode: hb Settings: rm RSItemDefLoader: hp MenuGroupNode: k StatusNodeListLoader: di HashTable: he ChatLine: ki RSNPCDef: ow LDModel: pt RSGroundEntity: cea RSInterfaceNode: mba StatusNodeList: eia RSGroundData: tea RSInteractableDef: c HardReference: Ambiguous RSGroundObject: mfa RSGround: ffa StatusNode: gda Identified 50 out of 51 (98 %)

I understand that I don’t have a lot of metrics in my checks, but I have a few (if I’m even using them correctly rofl)

it looks ok, but instead of having k stuck as one, i suggest you put classes into a list and sort it based on distance, then return the most popular of the first k classes. it will be a lot better in the long run if you support multiple sets of training data

[size=1pt]ps: if you want to optimise it a tiny bit, compare the squared distance[/size]

[quote=“frank_, post:2, topic:388016”]it looks ok, but instead of having k stuck as one, i suggest you put classes into a list and sort it based on distance, then return the most popular of the first k classes. it will be a lot better in the long run if you support multiple sets of training data

[size=1pt]ps: if you want to optimise it a tiny bit, compare the squared distance[/size][/quote]Yea, I had thought about that after I did it – I’ll change it up tomorrow, I’m going to bed now.

[quote=“frank_, post:2, topic:388016”][size=1pt]ps: if you want to optimise it a tiny bit, compare the squared distance[/size][/quote](I found manhattan distance to be just as good)

It’s a good start tbh.

wL and I had discussed this a while ago with me not having the slightest idea that what we were talking about was, in-fact kNN. His updater is quite good. It’s /very/ out of date but it still is some amazing code. I’ll talk to him about putting the source available for some of you here. From our discussions he never wanted his code to be public because of how damaging it could be to the game.

At any rate, my updater from a few years ago is based on kNN. It’s modified a bit but at its core it’s plain old kNN. The k I use is dynamic but the details are not overly relevant right now. What I wanted to point out was that it became clear to me (and wL first) that removal of jagex’s code modifications was fairly necessary. I haven’t seen any clear discussion on this topic with regards to kNN and figured it ought to be mentioned. That said, it’s pretty important to be able to remove as much of their /noise/ from each revision in order for your kNN-based updater to properly identify classes.

deobfuscation is a step that is done before identification really