lundi 1 novembre 2021

Remove "randomized" and "input" values from a procedural list

first of all sorry if I make mistakes, english is not my mothertongue.

I recently played the Werewolf game with some friends, in order to ease the Game Master work I wanted to create a simple Python program allowing fast roles randomization. I'm not a professional nor someone with high Python skills, I just understand how algorithms work so I lack vocabulary to shape my ideas, but i managed to create a working code :

import random

Roles = ['a werewolf', 'the werewolf seer', 'the fool', 'the seer', 'the witch', 'the    hunter', 'the priest', 'cupidon', 'the little girl', 'the bodyguard']
List = []
Counter = 0
Players = int(input("How many player are there ? "))

while Counter < Players:

    print("Player", Counter + 1, end=", ")
    Name = (input("What is your name ? "))
    List.append(Name)
    Counter = Counter + 1

for i in range(Players):

    print(random.choice(List), ", You are", random.choice(Roles))

The problem is, roles and names are randomized, so i can't tell my program to exclude just listed values, therefore some names are duplicated as well as some roles. I have 3 questions :

  • How can I refer to input values from a list ?
  • How can I refer to randomized values from a list ?
  • How can I tell my program to remove just listed values (randomized or input) from the list in order to avoid duplicate

Thanks for reading.




Aucun commentaire:

Enregistrer un commentaire