-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathteam8.py
More file actions
38 lines (35 loc) · 1.21 KB
/
team8.py
File metadata and controls
38 lines (35 loc) · 1.21 KB
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
####
# Each team's file must define four tokens:
# team_name: a string
# strategy_name: a string
# strategy_description: a string
# move: A function that returns 'c' or 'b'
####
team_name = 'T4T+random' # Only 10 chars displayed.
strategy_name = 'T4T but occasionally does opposite'
strategy_description = 'T4T but occasionally does opposite'
def move(my_history, their_history, my_score, their_score):
import random
#random.random() returns a decimal number from 0 and 1.
#collude on the first turn 90% of the time
if len(their_history)==0:
#random.random() is less than 0.90 90% of the time.
if random.random() < 0.90:
return 'c'
else:
return 'b'
elif their_history[-1] == 'b':
#Betray 90% of the time after being betrayed
if random.random() < 0.90:
return 'b'
#Collud 10% of the time after being betrayed
else:
return 'c'
#When opponent colled last turn:
else:
#Collude 90% of the time after opponent colludes
if random.random() < 0.90:
return 'c'
#Betray 10% of the time after opponent colludes
else:
return 'b'