Combining ladders across multiple servers
What's the algorithm its using? Is it just adding the scores together?
On second glance (I just got my piece working for work and am starting to move towards bed....mmmmm....sleeeeeeppppp).
The problem is that your search algorithm is inefficient. It's one of those O(n) algorithms, where the time to execute varies depending on how long the list is.
I'd suggest looking at your data structures. In my aastats class I kept matches, rounds, and ladder as separate arrays (and it hurt me to do so, believe me). I'd suggest doing the same here and using the player name's as the array indexes (map keys, whatever).
ANyway, I know you've got a lot of players in your stat files, and if I were to point at the one thing that would make such a routine take a long time, it's searching the entire array for every single player found in each new file.
Anyway, then you can do whatever math you want with a simple foreach loop on the ladder and calling data from the other arrays as needed. Embed the arrays, I think. It'll be hairy, but the point is to finish by calling php's builtin sort function. Otherwise, you can probably find a good, fast sort function. If you do that you can go ahead and do your simple foreach loop on the ladder, processing each player as you go, create your player objects there and stick them in the final array. Then use your sort function to sort the final array.
On second glance (I just got my piece working for work and am starting to move towards bed....mmmmm....sleeeeeeppppp).
The problem is that your search algorithm is inefficient. It's one of those O(n) algorithms, where the time to execute varies depending on how long the list is.
I'd suggest looking at your data structures. In my aastats class I kept matches, rounds, and ladder as separate arrays (and it hurt me to do so, believe me). I'd suggest doing the same here and using the player name's as the array indexes (map keys, whatever).
ANyway, I know you've got a lot of players in your stat files, and if I were to point at the one thing that would make such a routine take a long time, it's searching the entire array for every single player found in each new file.
Anyway, then you can do whatever math you want with a simple foreach loop on the ladder and calling data from the other arrays as needed. Embed the arrays, I think. It'll be hairy, but the point is to finish by calling php's builtin sort function. Otherwise, you can probably find a good, fast sort function. If you do that you can go ahead and do your simple foreach loop on the ladder, processing each player as you go, create your player objects there and stick them in the final array. Then use your sort function to sort the final array.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6714
- Joined: Thu Dec 18, 2003 7:03 pm
It's amazing how much of a difference it can make.Tank Program wrote:I was afraid of that. That's how I did my web stats page, with seperate arrays for everything then pulling out the data w/for loops... I'll re write it when I get home from school today.
edit: I forgot to mention. I don't write sort functions. If I can't use a builtin sort, I don't need to sort, it's that simple.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
*THWACK*z-man wrote:I'm glad I can get away with this kind of inefficiency in AA itself; the "find localized string for a given identifier" function just runs through all elements, too....
( note to self: _change_ _that_ )
Hey, while we're on the subject (we're not, really), I've got a question.
According to some who have also claimed close relations to you at various points in time (I think the guy's ADHD or something, though), you made armagetron support multiple keybindings to the same moves so that you could make a default keybind config that accomodated left and right-handed players, but that it was never intended to be abused. But what we have now is a bunch of players who have several keys bound to each turn and we use them, so to do a quick 180, instead ofhitting 'left left" we hit, say ",." at the same time and turn around.
What exactly were you intending when you made that possible? (Let's settle this once and for all
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
Allright: I allowed multiple keys to map to the same action because
- Other games do it
- It was easy ( the mapping is key->action and there is no logical reason why it needs to be one-to-one ), disabling it would be harder
- It allows you to control the camera with either the mouse or the keyboard, whatever is more handy at the moment
- It allowed me to set a default configuration that worked on several keyboard layouts because the key that is left of x is always different
- Double binding of turns would be no unfair advantage when cycle_delay is close to its default value, because you can already hit one key faster than that
I must admit that the use of double bindings for faster turns never came to my mind. I would not consider it an abuse, however, at least not any more than using an external camera perspective. A lot of other things would be abusive, then, for example playing with a gamepad and some gamepad-to-keyboard conversion software.
But apparently, since a certain style of server settings where fast 180s are legal and essential and double binding makes it ridiculously easy to achieve those, it may be a good idea to let the server admin decide whether double binds are allowed or not. The enforcement code would obviously have to live on the client and, as already said, would be non-trivial.
- Other games do it
- It was easy ( the mapping is key->action and there is no logical reason why it needs to be one-to-one ), disabling it would be harder
- It allows you to control the camera with either the mouse or the keyboard, whatever is more handy at the moment
- It allowed me to set a default configuration that worked on several keyboard layouts because the key that is left of x is always different
- Double binding of turns would be no unfair advantage when cycle_delay is close to its default value, because you can already hit one key faster than that
I must admit that the use of double bindings for faster turns never came to my mind. I would not consider it an abuse, however, at least not any more than using an external camera perspective. A lot of other things would be abusive, then, for example playing with a gamepad and some gamepad-to-keyboard conversion software.
But apparently, since a certain style of server settings where fast 180s are legal and essential and double binding makes it ridiculously easy to achieve those, it may be a good idea to let the server admin decide whether double binds are allowed or not. The enforcement code would obviously have to live on the client and, as already said, would be non-trivial.
If I have to do a complicated sort, I push the data into a mysql database since it can do extremely complicated sorting when fetching data from it. Otherwise I stick to built in php functions.Lucifer wrote:I forgot to mention. I don't write sort functions. If I can't use a builtin sort, I don't need to sort, it's that simple.Python's got a few deficiencies in the sort department, but it beats the hell out of php.
The way I would do this task is by running through each set of data to pluck out each unique name (different ways to do that, not sure what's the fastest at this point), and then use it to combine the stats together foreach name in a new array. Now you have a big array with all of it. You can then add them together or whatever fancy math you want, and keep it together in the same array, all of indexed by name, and sort whatever you want. etc. etc. That sounds more or less like what luci was saying.
-- but I should also say that this is one readability issue I have with php. looking at arrays and figuring out what I did in the past can sometimes be confusing to me. I tend to keep them one dimensional for this reason, which doesn't always serve the greater good.
And where did you get a job as a php programmer luci? I want one of those. I love php as much as you love python.
And quit smoking. It will kill you in a horrible way.

- Tank Program
- Forum & Project Admin, PhD
- Posts: 6714
- Joined: Thu Dec 18, 2003 7:03 pm
Long story. They were in a big hiring craze, I don't know if they are now. Just working with php is only half the story.ishAdmin wrote: And where did you get a job as a php programmer luci? I want one of those. I love php as much as you love python.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6714
- Joined: Thu Dec 18, 2003 7:03 pm
Well... I'm working on it today. I set it up so all the info went into a name based array and my player came back with some interesting stats. Remember this is just for Tigers Network...Type 2 is won rounds, so as you can see, I'm on 9 servers... But seriously, it's only 4... So... Yeah, I'm not quite sure what to make of this
.
Code: Select all
player Object
(
[name] => Tank Program
[finalscore] => 0
[scores] => Array
(
[0] => 17
[1] => 25.9685
[2] => 1524
[3] => 172
)
[onservers] => Array
(
[0] => 2
[1] => 1
[2] => 9
[3] => 5
)
)
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6714
- Joined: Thu Dec 18, 2003 7:03 pm
Well... I've got something now.
.
http://electricpotential.net/armrank/sig.php?name=
updates hourly... I, er, hope it is mathmatically "correct"
http://electricpotential.net/armrank/sig.php?name=
updates hourly... I, er, hope it is mathmatically "correct"

- Tank Program
- Forum & Project Admin, PhD
- Posts: 6714
- Joined: Thu Dec 18, 2003 7:03 pm