diff --git a/__pycache__/contenders.cpython-310.pyc b/__pycache__/contenders.cpython-310.pyc index e28c076..3aea42e 100644 Binary files a/__pycache__/contenders.cpython-310.pyc and b/__pycache__/contenders.cpython-310.pyc differ diff --git a/__pycache__/helper_functions.cpython-310.pyc b/__pycache__/helper_functions.cpython-310.pyc index 72a0ee9..7885ac0 100644 Binary files a/__pycache__/helper_functions.cpython-310.pyc and b/__pycache__/helper_functions.cpython-310.pyc differ diff --git a/contenders.py b/contenders.py index c683db6..a032f81 100644 --- a/contenders.py +++ b/contenders.py @@ -37,6 +37,20 @@ def random_positive_leaner(game_data,player_nr): #your cool code ended here return choice +def random_negative_leaner(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 random.randint(0,10)<4: + choice=True + #your cool code ended here + return choice + def i_hate_certain_numbers(game_data,player_nr): opponent_nr=1-player_nr hated_numbers=[7,13,17,23] diff --git a/helper_functions.py b/helper_functions.py index d350f49..378d4f7 100644 --- a/helper_functions.py +++ b/helper_functions.py @@ -1,10 +1,10 @@ import statistics -def analyze_results(game_data): +def analyze_results(game_data,game_nr): defect_str="X " coorperate_str="O " - spacer_str="___"*len(game_data) - lines=["These are the results",spacer_str] + spacer_str=""*len(game_data) + lines=["Game "+str(game_nr)+":",spacer_str] str1="Player 1: " str2="Player 2: " p_1_points=0 diff --git a/main.py b/main.py index 2579d0e..f3c4e68 100644 --- a/main.py +++ b/main.py @@ -19,13 +19,13 @@ nr_of_games=300#int(input("How many games should be played?")) # Put YOUR functions down below #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX function1=contenders.random_positive_leaner -function2=contenders.i_hate_certain_numbers +function2=contenders.random_negative_leaner for i in range(nr_of_games): helper_functions.play_game( games,function1,function2,nr_of_rounds) - scores.append(helper_functions.analyze_results(games)) + scores.append(helper_functions.analyze_results(games,len(scores)+1)) games=[] - + print("Played "+str(nr_of_games)+ " games with "+str(nr_of_rounds)+" rounds each.") print("(A huge disparity of the average and median could hint at special behaviour)") helper_functions.analyze_scores(scores) \ No newline at end of file