diff --git a/__pycache__/contenders.cpython-310.pyc b/__pycache__/contenders.cpython-310.pyc index 3aea42e..835021d 100644 Binary files a/__pycache__/contenders.cpython-310.pyc and b/__pycache__/contenders.cpython-310.pyc differ diff --git a/contenders.py b/contenders.py index a032f81..4b50938 100644 --- a/contenders.py +++ b/contenders.py @@ -64,4 +64,29 @@ def i_hate_certain_numbers(game_data,player_nr): choice=False #your cool code ended here - return choice \ No newline at end of file + 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 diff --git a/main.py b/main.py index f3c4e68..7c29127 100644 --- a/main.py +++ b/main.py @@ -18,8 +18,8 @@ nr_of_games=300#int(input("How many games should be played?")) #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # Put YOUR functions down below #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -function1=contenders.random_positive_leaner -function2=contenders.random_negative_leaner +function1=contenders.lil_devil +function2=contenders.lil_devil for i in range(nr_of_games): helper_functions.play_game( games,function1,function2,nr_of_rounds)