CAN YOU import random
def simulate_game():
# Create cast of 20 players
players = [f"Player {i+1}" for i in range(20)]
round_num = 1
while len(players) > 3:
print(f"
--- Round {round_num} ---")
print(f"Remaining players: {players}")
# Pick 3 random nominees
nominees = random.sample(players, 3)
print(f"Nominees: {nominees}")
# Initialize vote counts
votes = {nominee: 0 for nominee in nominees}
# Each non-nominated player votes
for voter in players:
if voter not in nominees:
choice = random.choice(nominees)
votes[choice] += 1
print("Votes:", votes)
# Determine who gets middle amount of votes
sorted_votes = sorted(votes.items(), key=lambda x: x[1])
# Handle ties for middle position
while True:
# Sort again after any tie-breaking
sorted_votes = sorted(votes.items(), key=lambda x: x[1])
if sorted_votes[0][1] < sorted_votes[1][1] < sorted_votes[2][1]:
break
# If tie exists, cast a random extra vote to break it
extra_vote = random.choice(nominees)
votes[extra_vote] += 1
print(f"Tie detected! Extra vote given to {extra_vote}.")
eliminated = sorted_votes[1][0]
print(f"Eliminated: {eliminated}")
players.remove(eliminated)
round_num += 1
# Final 3 players
print("
--- Final Round ---")
print(f"Finalists: {players}")
votes = {p: 0 for p in players}
for voter in players:
# Everyone votes, but not for themselves
choices = [p for p in players if p != voter]
votes[random.choice(choices)] += 1
print("Final Votes:", votes)
sorted_votes = sorted(votes.items(), key=lambda x: x[1])
# Handle ties in final round
while not (sorted_votes[0][1] < sorted_votes[1][1] < sorted_votes[2][1]):
extra_vote = random.choice(players)
choices = [p for p in players if p != extra_vote]
votes[random.choice(choices)] += 1
sorted_votes = sorted(votes.items(), key=lambda x: x[1])
winner = sorted_votes[1][0]
print(f"
WINNER: {winner}")
if __name__ == "__main__":
simulate_game() ME?
Comments
1
<
>
9
With 4 players remaining, all idols have been removed from the game!
20 days ago
Vote Tally: TaylorSwift: 4 Pokepat: 1 10th person voted out of Outcasted... TaylorSwift
20 days ago
FREEEEEEEEEZE
By
myesh,
20 days ago
🧊 FREEZE 🧊
By
xoJack,
20 days ago
CAN YOU import random def simulate_game(): # Create cast of 20 players players = [f"Player {i+1}" for i in range(20)] round_num = 1 while len(players) > 3: print(f" --- Round {round_num} ---") print(f"Remaining players: {players}") # Pick 3 random nominees nominees = random.sample(players, 3) print(f"Nominees: {nominees}") # Initialize vote counts votes = {nominee: 0 for nominee in nominees} # Each non-nominated player votes for voter in players: if voter not in nominees: choice = random.choice(nominees) votes[choice] += 1 print("Votes:", votes) # Determine who gets middle amount of votes sorted_votes = sorted(votes.items(), key=lambda x: x[1]) # Handle ties for middle position while True: # Sort again after any tie-breaking sorted_votes = sorted(votes.items(), key=lambda x: x[1]) if sorted_votes[0][1] < sorted_votes[1][1] < sorted_votes[2][1]: break # If tie exists, cast a random extra vote to break it extra_vote = random.choice(nominees) votes[extra_vote] += 1 print(f"Tie detected! Extra vote given to {extra_vote}.") eliminated = sorted_votes[1][0] print(f"Eliminated: {eliminated}") players.remove(eliminated) round_num += 1 # Final 3 players print(" --- Final Round ---") print(f"Finalists: {players}") votes = {p: 0 for p in players} for voter in players: # Everyone votes, but not for themselves choices = [p for p in players if p != voter] votes[random.choice(choices)] += 1 print("Final Votes:", votes) sorted_votes = sorted(votes.items(), key=lambda x: x[1]) # Handle ties in final round while not (sorted_votes[0][1] < sorted_votes[1][1] < sorted_votes[2][1]): extra_vote = random.choice(players) choices = [p for p in players if p != extra_vote] votes[random.choice(choices)] += 1 sorted_votes = sorted(votes.items(), key=lambda x: x[1]) winner = sorted_votes[1][0] print(f" WINNER: {winner}") if __name__ == "__main__": simulate_game() ME?
By
myesh,
20 days ago
By
myesh,
20 days ago
Me at the tie for immunity
By
TaylorSwift,
20 days ago
Individual Immunity Challenge Results: ChloeKayCT: 5230 myesh: 5230 Pokepat: 4880 xoJack: 4810 TaylorSwift: 4390 myesh wins individual immunity!
20 days ago
Vote Tally: jenn: 3 myesh: 3 9th person voted out of Outcasted... jenn
20 days ago
Awww did I win?
By
TaylorSwift,
20 days ago
By
Pokepat,
20 days ago
i'm done fighting...
By
jenn,
20 days ago
I'm not done fighting...
By
jenn,
20 days ago
anyways stream my new single! https://suno.com/s/JQDNxXOMmT94lWqY
By
ChloeKayCT,
21 days ago
sees me being the only woman remaining at F6. my Hannah MvGX era
By
ChloeKayCT,
21 days ago
I am so beyond bald-
By
jenn,
21 days ago
LMFAO?
By
jenn,
21 days ago
i was about to say
By
ChloeKayCT,
21 days ago
By
xoJack,
21 days ago
By
xoJack,
21 days ago