blota.beta3 - released

Author Topic: blota.beta3 - released  (Read 42046 times)

Right, I wrote a bubble sort algorithm just now, turns out integrating it into the current system would be more work than it's worth, so I will re-script the newServerGui, and I'm tempted to redesign with the feedback in mind. Thank you for your patience.
Using an O(n^2) algorithm, are you a complete amateur? Back to key stage 1 maths for you!

Using an O(n^2) algorithm, are you a complete amateur? Back to key stage 1 maths for you!
Except for that it's pretty rare for n to be above 200. 200^2=40000 iterations, so probably not a major problem unless you're doing something really expensive.

Back to key stage 1 maths for you!
butbut
he has a PhD in physics

Except for that it's pretty rare for n to be above 200. 200^2=40000 iterations, so probably not a major problem unless you're doing something really expensive.

Code: [Select]
new SimSet(b);
for(%i=0;%i<40000;%i++) {
  %a = new ScriptObject() { c = %i; };
  b.add(%a);
  echo(%a.c);
}
Takes almost six seconds for me. I wouldn't call that acceptable performance, and I can't honestly see someone implementing a bubble sort that does less than that in an iteration.
So worst case scenario, your game stops entirely for six seconds while it sorts servers. If you're sorting by ping you'd have to wait until all servers get their ping back (and occasionally you get one that responds after like 25 seconds) or sort every time you get a ping back (not feasible)

Code: [Select]
new SimSet(b);
for(%i=0;%i<40000;%i++) {
  %a = new ScriptObject() { c = %i; };
  b.add(%a);
  echo(%a.c);
}
Takes almost six seconds for me. I wouldn't call that acceptable performance, and I can't honestly see someone implementing a bubble sort that does less than that in an iteration.
So worst case scenario, your game stops entirely for six seconds while it sorts servers. If you're sorting by ping you'd have to wait until all servers get their ping back (and occasionally you get one that responds after like 25 seconds) or sort every time you get a ping back (not feasible)
Fair enough, you have a point.

Code: [Select]
function HeapSort()
{
for(%i = $x / 2 - 1; %i >= 0; %i--)
siftDown(%i, $x);

for(%i = $x - 1; %i >= 1; %i-- )
{
%temp = $a[0];
$a[0] = $a[%i];
$a[%i] = %temp;
siftDown(0, %i-1);
}
}

function siftDown(%root, %bottom)
{
%done = false;

while(%root * 2 <= %bottom && !%done)
{
if(%root * 2 == %bottom)
%maxChild = %root * 2;
else if($a[%root * 2] > $a[%root * 2 + 1])
%maxChild = %root * 2;
else
%maxChild = %root * 2 + 1;

if($a[%root] < $a[%maxChild])
{
%temp = $a[%root];
$a[%root] = $a[%maxChild];
$a[%maxChild] = %temp;
%root = %maxChild;
}
else
%done = true;
}
}
There's heapsort. Basically the fastest sorting method you can use.
Replace $a with whatever array you need to sort, and $x with the length of the array.

If that doesn't run fast enough for you, konk yourself in the head a couple of times.

No sorting method is going to be fast in torquescript. Look at ways you can leverage sorting within the engine to do what you want instead.

If you mean the sorting method built into list controls, i was thinking of that too, but that would be a bit hacky to implement.

edit: I also gotta remove this mod temporarily, I can no longer use the main menu because when I deselected "use blota desktop" then all the menu buttons disappeared.
« Last Edit: October 18, 2012, 05:52:57 PM by Ipquarx »

It's hacky sure but it makes for better performance. At the end of the day, the user cares more about how fast it runs and not what the code looks like.

Interesting.
I'd like to test.

edit: I also gotta remove this mod temporarily, I can no longer use the main menu because when I deselected "use blota desktop" then all the menu buttons disappeared.

i've fixed that issue for the next time we update.

in the next update expect sorting, blota.loadingGUI, notifications of when blota. updates through blota.notifs, and some bug fixes.

if you wanna know of that somewhat hacky method:

1. create an invisible list control like the default one (but JUST the list control)
2. use the sort functions on that list
3. read all the rows
4. transfer that information onto the new server list

Can you release that auto name finisher thing by itself?

Can you release that auto name finisher thing by itself?

wow i forgot that was in there

and it's pretty much broken
if i try to start it on its own project it won't get worked on so i'm going to keep it in here

So... server location data...