Created
September 20, 2012 04:35
-
-
Save dbanetto/3753997 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
#Edit for player list | |
players = [ "Lukos", "david", "elf_and_safety", "jack" , "sefirosu" , "supa_kappa" , "Nantres", "orange_lightning" ] | |
#Hardcode people to be in a team like so: | |
dire = ["Blake"] | |
rad = ["Daniel"] | |
#debug | |
#print (len(dire) , len(rad)) | |
maxrad = 5; | |
maxDire = 5; | |
def randomiseList(l): | |
output = [] | |
for i in range(len(l)): | |
r = int ( round((random.random() * len(l) - 1), 0) ) | |
#debug | |
#print( r , len(l) , len(output)) | |
output.append(l[r]) | |
l.pop(r) | |
return output | |
def makeTeams(): | |
for player in players: | |
team = random.random() | |
if team == 0.5: | |
team = 0 | |
#debug | |
#print(player , team) | |
if team > 0.5 and len(dire) < maxDire: | |
dire.append(player) | |
#finished with this player, NEXT! | |
continue | |
if team < 0.5 and len(rad) < maxrad: | |
rad.append(player) | |
continue | |
#If the team is full move to the other team if there is space | |
if team < 0.5 and len(dire) < maxDire and len(rad) == maxrad: | |
dire.append(player) | |
continue | |
if team > 0.5 and len(rad) < maxrad and len(dire) == maxDire: | |
rad.append(player) | |
continue | |
def printList(l): | |
for i in l: | |
print(i) | |
#debug | |
#print(players) | |
#Randomise the player list | |
players = randomiseList(players) | |
#print(players) | |
makeTeams() | |
#output the teams | |
print("DIRE") | |
printList (dire) | |
print("\nradi") | |
printList (rad) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment