Latest Posts

Topic: Rating system

einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2019-09-07, 20:37

trimard wrote:

And after reading it I finally realized that "<--" means "=" in algorithms...

That is used in some computer languages (haskell? lambda expressions?). Probably mathematicians loves that sign face-wink.png .

I now see 3 solutions for the implementation but each has it's own problems:
(...)

As I can see, the main problem is about adding new lines to a form where you put player names and results, right?

The general solution for that is:

  • Put somewhere in the HTML a template of the form (here: new line containing necessary data like player name, tribe, team number),
  • When needed ("+" button is pressed), copy this template to a proper place in the HTML code,
  • Change the names of the fields from (example) "player" to "player-X" (where X is a number), so that player-1, player-2, player-3, ... will contains all player names
  • Handle with "-" button (if too many players were added)
  • Handle with all "player-X" names and values in Django view

I know that this is not the only way of doing that, but probably the most straightforward one.

@kapputnik, maybe you have another experience with that and you can share it with us? Maybe there is even easier way to do that?

Admin pages

In the admin page there is a possibility to add inline form (related list), and this functionality is done automatic


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
trimard
Avatar
Topic Opener
Joined: 2009-03-05, 22:40
Posts: 230
Ranking
Widelands-Forum-Junkie
Location: Paris
Posted at: 2019-09-07, 20:49

Probably mathematicians loves that sign face-wink.png .

The most cryptic the better for them right? Not so far from medicine on that aspect :P.

Put somewhere in the HTML a template of the form (here: new line containing necessary data like player name, tribe, team number), When needed ("+" button is pressed), copy this template to a proper place in the HTML code, Change the names of the fields from (example) "player" to "player-X" (where X is a number), so that player-1, player-2, player-3, ... will contains all player names Handle with "-" button (if too many players were added) Handle with all "player-X" names and values in Django view

yup exact procedure I used. Except for some reason, django doesn't show the "player-x" names, only the first one which I didn't create automatically. Somehow the list appearing in the request is linked to the template?? I have the exact same html input for each lines (except names and id).

I can't find anybody else with the same exact problem. I think people don't use django to make their own form...

In the admin page there is a possibility to add inline form (related list), and this functionality is done automatic

Ok, +1 for admin page, but I still need to override the html from what I understand to do that. Did I read wrong?


Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2019-09-07, 21:51

trimard wrote:

yup exact procedure I used. Except for some reason, django doesn't show the "player-x" names, only the first one which I didn't create automatically. Somehow the list appearing in the request is linked to the template?? I have the exact same html input for each lines (except names and id).

Django forms were designed for admin pages and form views (as I remember). Using them in customized views can be hard. Probably easier is creating whole form from scratch.

But don't listen to me face-wink.png I might be completely wrong face-grin.png .

My guess is that designed form with form class is handling only input that is defined in the class itself. To cover all other cases (custom lines) you need to override methods responsible for reading data from GET / POST request.

I can't find anybody else with the same exact problem. I think people don't use django to make their own form...

+1

Ok, +1 for admin page, but I still need to override the html from what I understand to do that. Did I read wrong?

Yes, but in general you don't have to use only one page for all data! You can use multiple forms, one for each functionality. And as I understand, only one form is needed as basics: form where you can register game and its results. Also another admin page - list view is needed to review all the games, but it doesn't need to be a form, just buttons "edit" and "add new row".


einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
trimard
Avatar
Topic Opener
Joined: 2009-03-05, 22:40
Posts: 230
Ranking
Widelands-Forum-Junkie
Location: Paris
Posted at: 2019-09-08, 16:47

Probably easier is creating whole form from scratch.

Well that's what I did then, and I found a way to fix my problem. I create 8 players and just hide 6 of them. Then I just hide/show and remove the value when "removing".

From a backup point of view, I just check if value is empty of not before adding the player :).

But don't listen to me face-wink.png I might be completely wrong face-grin.png .

We'll hope you're not face-tongue.png

I'll use the other part of your post if I decide to do it the pure django way. But a big factor to use that technique I forgot to mention is that I might use the same template and backend for the submission of games by players face-shock.png

Now I focus on refacto, and then we could start the alpha tests, a few questions about that btw:

  • I created a "create test data btn" should I keep it, and if yes, should I isolate the fonctions that creates it on another file than view?

  • view is becoming quite a long file. Should I separate the functions used in arbiter page and the ranking page?

  • Don't know whaat to do for a function

is that cleaner to have:

def type_to_int(word):
    word = word.lower()
    if word == 'autocrat':
        return 1
    if word == 'wood gnome':
        return 2
    if word == 'collectors':
        return 3
    if word == 'empire':
        return 1
    if word == 'barbarian':
        return 2
    if word == 'atlantean':
        return 3
    if word == 'frisian':
        return 4

def int_to_string(tribe):
    if tribe == 1:
        return 'empire'
   if tribe == 2:
        return 'barbarian'
    if tribe == 3:
        return 'atlantean'
    if tribe == 4:
        return 'frisian'

or an array with these value and a function that call them?

Rest of the work to do in the next few weeks:

  • add tie games

  • player game submission

  • support of 2vs2 and more players

  • bug fix!!

Edited: 2019-09-08, 19:10

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2019-09-08, 17:08

Is there a specific reason that you need the int representation? This will break as soon as we add the amazons.


Busy indexing nil values

Top Quote
trimard
Avatar
Topic Opener
Joined: 2009-03-05, 22:40
Posts: 230
Ranking
Widelands-Forum-Junkie
Location: Paris
Posted at: 2019-09-08, 17:21

Mhhhh, true actually we could just use strings, but in the end I think we would need a tribe table anyway. At some point we will want to have a score per tribe, so why not reference to the tribe table?

We could manage the tribes, and add them as we want directly on the arbiter page?

edit: no, no need for tribe management on the arbiter page, the admin interface will be far enough for such use

Edited: 2019-09-08, 17:23

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2019-09-08, 17:37

A tribe table sounds good.


Busy indexing nil values

Top Quote
einstein13
Avatar
Joined: 2013-07-29, 00:01
Posts: 1118
Ranking
One Elder of Players
Location: Poland
Posted at: 2019-09-08, 20:09

Tribe table is one option, another is to use model for adding valid player-game match:

class player_to_game_model_or_whatever(models.Model):

    TRIBE_CHOICES = ((1, "Barbarians"), (2, "Empire"), (3, "Atlanteans"), (4, "Frisians"))

    (...) # player=FK to user OR string; game=FK to game record; team number
    tribe = models.IntegerField(choices=TRIBE_CHOICES)

    (...)
    def map_tribe_to_int(self, tribe_string):
        (...)
        return ...

But this method will require code change when amazons / egyptians / any new tribe would be added.

So as GunChleoc said, probably the best method is to add another table with tribes for mapping purpose. But remember to add somewhere initial data filling. I know that data migrations weren't created for such purpose, but it is clean and probably the easiest way to do so.

Edited: 2019-09-08, 20:12

einstein13
calculations & maps packages: http://wuatek.no-ip.org/~rak/widelands/
backup website files: http://kartezjusz.ddns.net/upload/widelands/

Top Quote
trimard
Avatar
Topic Opener
Joined: 2009-03-05, 22:40
Posts: 230
Ranking
Widelands-Forum-Junkie
Location: Paris
Posted at: 2019-09-08, 23:23

Might try a model. And btw shouldn't we have kind of everything in tables?

  • season (game from date a to date b)
  • number of game per round taken into account (rating period) ==> would allow test directly by the admin, no need to touch code

  • tribes

  • maps

  • type of game

that is, we will, also at some point want data on those: So is this map balanced for tribe x? Is this type of game favoring a certain tribe? Is this type of game creating too many tie? etc

If we do that, we will have to store them so that people looking at those value don't ask for too much load from the server. (we could refind these data by looking at all the games each time)

There is no rush though.


Top Quote
trimard
Avatar
Topic Opener
Joined: 2009-03-05, 22:40
Posts: 230
Ranking
Widelands-Forum-Junkie
Location: Paris
Posted at: 2019-09-08, 23:55

Oh yeah this is starting to look like a real experiment! Here are the data after different configurations:

Test 1 (currently displayed in "call for game")

  • base standard deviation: 300
  • base score: 1500
  • base volatility: 0.06
  • tau: 0.2
  • number of game calculated each time: 10
  • max iteration on step 5: 15

Same as last + max iteration on step5 :2

Same as last + tau: 1.0

Same as last + number of game per round: 2

Seems some parameter are more sensible than other. well what data you guys would want to test too to understand better the hang of it?


Top Quote