[FilterScript] Vehicle Spawner using binary search
#1

*This isn't really a Filterscript, more just a snippet, feel free to move if I accidentally put this in the wrong section*

Some vehicles spawners i've seen do linear searchers to find the desired vehicle, but that can involve doing 200+ comparisons through the vehicle list before finding the desired vehicle, and though it doesn't effect performance much, I thought i'd still try and make a more efficient vehicle spawner. This idea is most likely done before, but I searched and I couldn't find anything, so thought i'd post this. This binary search vehicle spawner should reduce the amount of comparisons down to around 10-20, or much less ofc.

The first version i released was a bit buggy, but I have updated it since then and it seems to work much better now, since i decided to use recursion to fix a few things. If you notice any bugs, please let me know here!

Note: Some vehicles may be missing from the vehicle list supplied, this is because of a few reasons: Either they didn't work well with the binary searcher, or i felt they didnt need adding like the tram/train.

http://pastebin.com/GvEdYFJV

Please rep if you find this useful
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)