Guest User

Untitled

a guest
Jan 16th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. players = {"player 1":0, "player 2":0}
  2.  
  3. def play_ghost():
  4. for p_id in cycle(players):
  5. ##code..
  6. if end_game() : ##if this is true, add 1 to the OTHER player
  7. ##what to write here ?
  8.  
  9. wins = {"player1": 0, "player2": 0}
  10. this, other = "player1", "player2"
  11. for i in range(rounds_count): # really, variable i don't use
  12. this, other = other, this # swap players
  13. if end_game():
  14. wins[this] +=1
  15. else:
  16. wins[other] += 1
  17.  
  18. players = [0, 0]
  19.  
  20. players[1] # player 2, because lists are 0-based
  21. players[1:] # all players but the first
  22. # if you want to do more complex selects, do this, but DON'T for simple stuff
  23. [player for index, player in enumerate(players) if index == 1]
  24.  
  25. players = {"player 1":0, "player 2":0}
  26. names = players.keys()
  27. other = dict(zip(names, names[::-1]))
  28. # other = {'player 1': 'player 2', 'player 2': 'player 1'}
  29.  
  30. def play_ghost():
  31. for p_id in cycle(players):
  32. ##code..
  33. if end_game() : ##if this is true, add 1 to the OTHER player
  34. players[other[p_id]] += 1
  35.  
  36. players = [0, 0]
  37. def play_ghost():
  38. for index in range(len(players)):
  39. #code...
  40. if end_game():
  41. players[(index + 1) % 2] += 1 # Uses mode to select other player
Add Comment
Please, Sign In to add comment