Arqade Asked by SteakOverflow on December 12, 2020
How do I assign a specific role to a single, randomly selected player and make sure nobody else has the role?
My own take on this was the following:
Preconditions:
Random selection:
This might require some short delays between each step.
However this solution has several drawbacks:
Answered by SteakOverflow on December 12, 2020
Ok, here is a revised version based on the idea of skipping empty slots (new posting in order to avoid that the old comments become confusing). I'm assuming there are maximum T teams and maximum P players on each team.
Step 1: Remove the role from all players (-1 to Role Mapper chip).
Step 2: Pick a random number A between 0 and T*P (exclusive). Pick another random number B between 1 and the number of players in the game (inclusive) (number of players is provided by Player Event chip).
Step 3: Initialize a counter N with 0.
Step 4: Initialize a "slot counter" S with A.
Step 5: For any value of the slot counter S, compute the team as S/P+1; and the index on the team with (S mod P)+1. Use the Team Mapping chip to get the Player ID for each value of S. If you get a valid Player ID, increase the counter N by 1.
Step 6: If N == B, assign the role to this player and end.
Step 7: Change S to (S+1) mod (T*P).
Step 8: Continue with Step 5
Answered by forbym on December 12, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP