-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgames.py
54 lines (49 loc) · 1.86 KB
/
games.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
__author__ = 'Areg'
class Games:
def __init__(self):
self.allgames = {}
self.allgames["prisonersdillema"] = self.PrisonersDilemma
self.allgames["chicken"] = self.Chicken
self.allgames["staghunt"] = self.StagHunt
def PrisonersDilemma(self, player1turn, player2turn):
if player1turn == "c" and player2turn == "c":
player1score = 3
player2score = 3
elif player1turn == "c" and player2turn == "d":
player1score = 0
player2score = 5
elif player1turn == "d" and player2turn == "c":
player1score = 5
player2score = 0
elif player1turn == "d" and player2turn == "d":
player1score = 1
player2score = 1
return [player1score, player2score]
def Chicken(self, player1turn, player2turn):
if player1turn == "c" and player2turn == "c":
player1score = 3
player2score = 3
elif player1turn == "c" and player2turn == "d":
player1score = 4
player2score = 6
elif player1turn == "d" and player2turn == "c":
player1score = 6
player2score = 4
elif player1turn == "d" and player2turn == "d":
player1score = 1
player2score = 1
return [player1score, player2score]
def StagHunt(self, player1turn, player2turn):
if player1turn == "c" and player2turn == "c":
player1score = 4
player2score = 4
elif player1turn == "c" and player2turn == "d":
player1score = -5
player2score = 3
elif player1turn == "d" and player2turn == "c":
player1score = 3
player2score = -5
elif player1turn == "d" and player2turn == "d":
player1score = 2
player2score = 2
return [player1score, player2score]