Python Forum
Randomizer script to provide options based on user and priority
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomizer script to provide options based on user and priority
#10
With Catalog only, weighted and random are the same because all games have the same number of votes.

You can also do dad, thing 1 and catalog to pick a game that is more likely on your lists, but still have the possibility of picking a game that is not.

With a slight modification you can see the voting:
    @classmethod
    def cast_ballots(cls, gamers):
        """Collect votes from gamers"""
        ballots = []
        for gamer in gamers:
            ballots += cls.Gamers[gamer].votes()

        print("Weighted choices for", ", ".join(gamers))
        for game in collections.Counter(ballots).most_common()[:5]:
            print(f"{game[0]:10} {100*game[1] / len(ballots):>6.2f}%")

        return ballots
Output:
Weighted choices for Mom, Dad, Thing 1, Thing 2 Uno 24.53% Monopoly 15.09% Life 13.21% Skippo 13.21% COD 9.43%
Reply


Messages In This Thread
RE: Randomizer script to provide options based on user and priority - by deanhystad - Mar-11-2022, 05:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  argparser not showing all options bigal 1 228 May-22-2024, 02:54 AM
Last Post: deanhystad
  output provide the filename along with the input file processed. arjunaram 1 998 Apr-13-2023, 08:15 PM
Last Post: menator01
  Priority Queue with update functionality PythonNewbee 4 2,130 Dec-29-2022, 12:13 PM
Last Post: Yoriz
  Exit function from nested function based on user input Turtle 5 3,059 Oct-10-2021, 12:55 AM
Last Post: Turtle
  Automatic user/password entry on prompt by bash script PBOX_XS4_2001 3 2,895 May-18-2021, 06:42 PM
Last Post: Skaperen
  Creating a calculation based on user entry blakefindlay 2 2,087 Jan-26-2021, 06:21 PM
Last Post: blakefindlay
  [SOLVED] Requiring help running an old Python script (non Python savvy user) Miletkir 13 5,646 Jan-16-2021, 10:20 PM
Last Post: Miletkir
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 3,021 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  Help with options raiden 1 1,993 Aug-30-2019, 12:57 AM
Last Post: scidam
  Avoid hard-coded folderPath in the code (let users provide it) SunOffice024 6 5,479 Sep-08-2018, 06:41 PM
Last Post: SunOffice024

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020