Team 6
unknown
python
2 years ago
973 B
6
Indexable
import random strategy_name = "Win-stay, Lose-switch" def won_last(myMove, thereMove): if (myMove == thereMove): # Tie so play a new move return random.choice(["p", "s", "r"]) elif (thereMove == "r" and myMove == "p"): # we won the game use the same move return myMove elif (thereMove == "p" and myMove == "s"): # we won the game use the same move return myMove elif (thereMove == "r" and myMove == "p"): # we won the game use the same move return myMove else: if (myMove == "r"): return random.choice(["p", "s"]) if (myMove == "p"): return random.choice(["r", "s"]) if (myMove == "s"): return random.choice(["p", "r"]) def move(my_history, their_history): if (len(my_history) == 0): return "p" else: return won_last(my_history[-1], their_history[-1])
Editor is loading...
Leave a Comment