-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmartOpponent.py
29 lines (23 loc) · 960 Bytes
/
SmartOpponent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import AbstractOpponent
class SmartOpponent(AbstractOpponent.AbstractOpponent):
def __init__(self):
self._hist = []
def choice(self) -> int:
players_favourite = {"Rock": 0, "Paper": 0, "Scissors": 0}
# players_winrate = {"Rock": 0, "Paper": 0, "Scissors": 0}
for entry in self._hist:
players_favourite[entry["player"]] += 1
# players_winrate[entry["player"]] = players_winrate[entry["player"]] + (1 if entry["won"] == "player" else 0) / players_favourite[entry["player"]]
for k in players_favourite:
print(f"{k}\t{players_favourite[k]}")
"""
for k in players_winrate:
print(f"{k}\t{players_winrate[k]}")
"""
return 0
def _complementary(self, ):
def addToHistory(self, lastChoice: dict):
self._hist.append(lastChoice)
"""
{"player": "Rock", "computer": "Scissors", "won": "player"}
"""