Page 1 of 1

Global stats at end of game

Posted: Tue Sep 25, 2018 12:03 pm
by iBrandad
Is it possible to get a percentage stats of how many players chose certain choices in your game? Like a Telltale game sort of deal. At the end of my game I wanna have a stats screen that says like "you and 54% of players did this" you know what I mean?

Re: Global stats at end of game

Posted: Tue Sep 25, 2018 12:30 pm
by drKlauz
You can either add $choices_done["choice_431_a"]=True to menu choice or rework choice screen so it updated automatically. Then periodically sync choices_done with your server stats.

Re: Global stats at end of game

Posted: Tue Sep 25, 2018 2:24 pm
by drKlauz
Copy from PM, in case anyone will have similar need it in future.

You need some dictionary in which you store choices player have made.
Such dictionary must be created at start label, so it can track current game.
When player select option you update dictionary.
Then periodically or at game end, you send this dictionary to server where you combine it with other players data.
At game end you request average data from server and compare it with current game choices dictionary and show player results.

Code: Select all

menu:
  "What should I do first?"
  "Fly!":
    $game_choices["fly_or_fireball"]=True # or 1 or "Fly"
    "I'm flying."
  "Fireballs!":
    $game_choices["fly_or_fireball"]=False # or 2 or "Fireballs"
    "I have fireballs."
I wouldn't recommend sending every choice made to server, as it could distort statistics, better send only after game is finished, right before or along with request for global statistics.
Plus you may include to sent data some game id, generated at start of game random number, so you don't include same game statistics multiple times if player reloaded.
Tricky part will be communicating with server without lagging game.
For server i recommend https://pythonanywhere.com - it's free and simple to use.

Re: Global stats at end of game

Posted: Wed Dec 04, 2019 4:56 am
by Roxie
This might be an old thread, but thought it might be worth mentioning for future searches:
viewtopic.php?f=4&t=39864#p424833