Also, various functions don't access local variables.
As of now, I've edited your functions to use a minmax heap. More specifically, the priority queue. Not done optimizing though.
Edited by Gamer3D, 08 March 2011 - 07:02 AM.
Posted 07 March 2011 - 11:02 PM
Edited by Gamer3D, 08 March 2011 - 07:02 AM.
Posted 08 March 2011 - 10:04 AM
Edited by Davve, 08 March 2011 - 10:41 AM.
Posted 08 March 2011 - 02:41 PM
As you should be able to tell from previous posts, these don't work anywhere near as well as the actual data structures. If Yoyo Games wants this taken down I will glady comply, however I don't believe someone will not buy game maker because he/she can get a crappy buggy version of the actual functions for free.And imagine if the only reason a person buys Game Maker is to use the ds_ functions. But with these scripts, he no longer have to buy it. In these cases, you are basically stealing money from yyg, and they can decide to take legal action against this.
Posted 08 March 2011 - 08:10 PM
As you should be able to tell from previous posts, these don't work anywhere near as well as the actual data structures. If Yoyo Games wants this taken down I will glady comply, however I don't believe someone will not buy game maker because he/she can get a crappy buggy version of the actual functions for free.And imagine if the only reason a person buys Game Maker is to use the ds_ functions. But with these scripts, he no longer have to buy it. In these cases, you are basically stealing money from yyg, and they can decide to take legal action against this.
Edited by Gamer3D, 09 March 2011 - 06:48 PM.
Posted 08 March 2011 - 11:06 PM
Posted 11 March 2011 - 06:57 PM
uhm no they can't take "legal action".. This is silly to even consider!Why do you use instances for this, why not arrays? What if somebody does instance_deactivate_all()?
And imagine if the only reason a person buys Game Maker is to use the ds_ functions. But with these scripts, he no longer have to buy it. In these cases, you are basically stealing money from yyg, and they can decide to take legal action against this.
Posted 22 July 2011 - 10:57 PM
// uds_priority_add(id,val,prio) argument0.Value[argument0.PriorMax]=argument1; argument0.Prior[argument0.PriorMax]=argument2; argument0.PriorMax+=1;added argument0. in front of each PriorMax, since it tried to access PriorMax outside the priority object
// uds_priority_delete_min(id)
if argument0.PriorMax = 0 return noone;
var i,n;
n=0;
for (i=0; i<argument0.PriorMax; i+=1) {
if argument0.Prior[n]>argument0.Prior[i] n=i;
}
i=n;
n=argument0.Value[n];
argument0.PriorMax-=1;
for (i=i; i<argument0.PriorMax; i+=1) {
argument0.Value[i]=argument0.Value[i+1];
argument0.Prior[i]=argument0.Prior[i+1];
}
return n;This one was returning the priority, not the value, so I made n find the row with the smallest priority, then tell the row number to i, then overwrite the n Value, before pushing all rows below that row, 1 row up .. so I just returned n
Posted 26 July 2011 - 07:21 AM
Edited by Gamer3D, 02 June 2012 - 02:19 AM.
Posted 26 July 2011 - 10:22 PM
Posted 27 July 2011 - 01:19 AM
The fault is that GM's priority queues are naively implemented, at O(n), while mine are implemented properly, at O(log n). The more elements in the queue, the better mine will perform than GM's (I haven't checked how many there have to be to tip in my favor yet, but I'm still winning with just 2000 elements)Wait...a GML version of priority queues that is 17x faster than the built-in versions? There has to be something wrong with the bench-marking of it, I just don't see how in the world interpretive beats hardcode. Scanning through quickly revealed that your first set of scripts are commented out anyway, so I'm not sure what that's all about...I'll have to take a look at it more thoroughly to find the fault (and yes, there will be one somewhere).
Posted 27 July 2011 - 11:05 AM
orly? Last time I created a benchmarking program, I actually used separate variables at each phase....this:The fault is that GM's priority queues are naively implemented, at O(n), while mine are implemented properly, at O(log n). The more elements in the queue, the better mine will perform than GM's (I haven't checked how many there have to be to tip in my favor yet, but I'm still winning with just 2000 elements)
FYI, I just put up my extension benchmark, so the first folder of scripts is just for the extension. Use the second folder of scripts.
time = current_time;
repeat 15999
fds_priority_add(pq1, 1, random(1));
time2 = current_time;
time = current_time;
repeat 10000
fds_priority_delete_min(pq1);
time2 = current_time;
room_caption = 'Time for deleting 10000 time using: Scripts: ' + string((time2 - time) / 1000);
time = current_time;
repeat 15999
ds_priority_add(pq1, 1, random(1));
time2 = current_time;
time = current_time;
repeat 10000
ds_priority_delete_min(pq1);
time2 = current_time;
room_caption += ', Built-in: ' + string((time2 - time) / 1000);Posted 27 July 2011 - 06:23 PM
Yes, I was just testing delete_min. My reasons:orly? Last time I created a benchmarking program, I actually used separate variables at each phase....this:
Spoiler
Looks like you used the same variables...the only thing you are measuring is the time of "delete_min" for both sets. Unless you purposely just left the code fully uncommented for your own purposes (testing each phase separately), but "add" and "delete_min" are hardly enough testing for the scripts as a whole.
Yes, yes, this was on the list of things people could do to improve it. I don't remember why I did one array, but by editing it to use three (For size, values, and priorities), you can double the maximum elements. This'll be a back-burner project for me.Plus, it looks like you are using a ONE array for ALL priority queues. This may seem trivial considering not a lot of people are going to be using PQs, but since you are stating that "with enough elements" your scripts will work better, but I'm seeing it more of the fact that "with enough elements," your scripts will not work at all (face it, if someone is using PQs to the extent that you say, then they will easily be needing much much more at some point).
Yeah, you'd think that, but when I recommended this exact same thing (And pointed to my extension as a "Oh hey, you're really, really slow" proof) they ignored it.I commend you for making a minmax heap for PQs...it's a great self-exercise and possibly a kick in the butt for YYG to possibly go that way with them.
Edited by Gamer3D, 02 June 2012 - 02:19 AM.
Posted 06 July 2012 - 02:12 PM
Edited by creativebunch, 06 July 2012 - 02:13 PM.
0 members, 0 guests, 0 anonymous users