added lil_devil

This commit is contained in:
taxicomics 2024-04-26 20:56:46 +00:00
parent 65fa2622c6
commit 863835c851
3 changed files with 28 additions and 3 deletions

View File

@ -65,3 +65,28 @@ def i_hate_certain_numbers(game_data,player_nr):
#your cool code ended here #your cool code ended here
return choice return choice
def lil_devil(game_data,player_nr):
#game_data is the array of games so far, either empty(first round) or formatted like this: player_nr [[False, False],[False, False]] (2 rounds of only defections)
#player_nr is this players index, so whether they are the first(0) or the second(1) value in a round
opponent_nr=1-player_nr
#for ease of use this is index of the opponents value
choice=False
#this function should return either true(coorperate) or false(defect)
#your cool code goes here
if len(game_data)>0:
#what to do if this is NOT the first round
if not game_data[-1][opponent_nr]:
if random.randint(0,10)<6:
choice=False
else:
choice=True
#this example always does the opposite of what the opponent did last round
else:
#what to do in the first round
choice=False
#this example starts with a cooperation
#your cool code ended here
return choice

View File

@ -18,8 +18,8 @@ nr_of_games=300#int(input("How many games should be played?"))
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Put YOUR functions down below # Put YOUR functions down below
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function1=contenders.random_positive_leaner function1=contenders.lil_devil
function2=contenders.random_negative_leaner function2=contenders.lil_devil
for i in range(nr_of_games): for i in range(nr_of_games):
helper_functions.play_game( games,function1,function2,nr_of_rounds) helper_functions.play_game( games,function1,function2,nr_of_rounds)