Combining ladders across multiple servers

General Stuff about Armagetron, That doesn't belong anywhere else...
User avatar
Lucifer
Project Developer
Posts: 8758
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

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.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6714
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

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.
Image
User avatar
Lucifer
Project Developer
Posts: 8758
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

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.
It's amazing how much of a difference it can make. :) I wrote the pyExtractor originally with a search algorithm like yours, but it was for each word on a webpage. I could smoke a whole cigarette in the time it took to process my homepage. Then I rewrote the datastructure to be a map-like class (Python lets you do these things :) ) and keep it's own internal list of keys that it used instead of manually searching the list and ran it, and by the time I got out of my seat to smoke, the thing had finished. I was blown away by the difference. :) (And quite proud of myself, I made a python class that acted just like a dictionary, and it was the first time I'd done that, and it was really cool. I'd switch to python even for webpages if my job wasn't married to php)

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. :) Python's got a few deficiencies in the sort department, but it beats the hell out of php.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Z-Man
God & Project Admin
Posts: 11757
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

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_ )
User avatar
Lucifer
Project Developer
Posts: 8758
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

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_ )
*THWACK*

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
User avatar
Z-Man
God & Project Admin
Posts: 11757
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

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.
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

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.
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.

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.
Image
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6714
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

Home now... I'll be rewriting it shortly or something...
Image
User avatar
Lucifer
Project Developer
Posts: 8758
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

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.
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. :) Working from home is the other half. I can ask and see if they're still looking for people.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

so you don't even have to show your face in an office. dat be sweet!
Image
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6714
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

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...

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
        )

)
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 :(.
Image
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6714
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

Well... I've got something now. Image.
http://electricpotential.net/armrank/sig.php?name=
updates hourly... I, er, hope it is mathmatically "correct"
Image
User avatar
dlh
Formerly That OS X Guy
Posts: 2035
Joined: Fri Jan 02, 2004 12:05 am
Contact:

Post by dlh »

Nice work tank program, altough my ranking is not as well as I'd like it to be. But then again, I dont play much on tiger's network servers.
ishAdmin
Match Winner
Posts: 625
Joined: Sun Jul 04, 2004 12:11 am
Contact:

Post by ishAdmin »

but I want to know how you win matches without winning rounds? your stats are FREAKIN ME OUT nemo! :)
Image
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6714
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

I'm trying to get as many people interested in this system, so please...
Image
Post Reply