diff --git a/__pycache__/contenders.cpython-310.pyc b/__pycache__/contenders.cpython-310.pyc index 1688457..e28c076 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 76b0382..72a0ee9 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 6f0d7c7..c683db6 100644 --- a/contenders.py +++ b/contenders.py @@ -35,4 +35,19 @@ def random_positive_leaner(game_data,player_nr): if random.randint(0,10)<6: 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] + #for ease of use this is index of the opponents value + choice=True + #this function should return either true(coorperate) or false(defect) + + #your cool code goes here + round_nr=len(game_data) + if round_nr in hated_numbers: + choice=False + + #your cool code ended here return choice \ No newline at end of file diff --git a/helper_functions.py b/helper_functions.py index d2a3728..d350f49 100644 --- a/helper_functions.py +++ b/helper_functions.py @@ -1,3 +1,5 @@ +import statistics + def analyze_results(game_data): defect_str="X " coorperate_str="O " @@ -46,15 +48,20 @@ def play_game(games_array,func1,func2,how_many_times): def analyze_scores(score_table): average_score_p_1=0 + all_p1_scores=[] + all_p2_scores=[] average_score_p_2=0 p1_sum=0 p2_sum=0 for i in score_table: p1_sum+=i[0] + all_p1_scores.append(i[0]) p2_sum+=i[1] + all_p2_scores.append(i[1]) + average_score_p_1=p1_sum/len(score_table) average_score_p_2=p2_sum/len(score_table) - print(str(average_score_p_1)) - print(str(average_score_p_2)) + print(str(average_score_p_1)+" AVG Player 1 Score |"+str(statistics.median(all_p1_scores))+" Median Player 1 Score") + print(str(average_score_p_2)+" AVG Player 2 Score |"+str(statistics.median(all_p2_scores))+" Median Player 1 Score") #print(score_table) \ No newline at end of file diff --git a/main.py b/main.py index 508f64a..2579d0e 100644 --- a/main.py +++ b/main.py @@ -13,15 +13,19 @@ import contenders games=[] #keeping track of the games scores for later analysis scores=[] -nr_of_rounds=30 -nr_of_games=300 +nr_of_rounds=30#int(input("How many should be played in a game?")) +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_positive_leaner -#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -# Put YOUR function down below -#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +function2=contenders.i_hate_certain_numbers + for i in range(nr_of_games): helper_functions.play_game( games,function1,function2,nr_of_rounds) scores.append(helper_functions.analyze_results(games)) 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