From 00a9debb4b45e9e0cf769f0456387b151efa95ea Mon Sep 17 00:00:00 2001 From: taxicomics <168220579+taxicomics@users.noreply.github.com> Date: Fri, 26 Apr 2024 19:11:23 +0000 Subject: [PATCH] commit with optional input parameters --- __pycache__/contenders.cpython-310.pyc | Bin 593 -> 833 bytes __pycache__/helper_functions.cpython-310.pyc | Bin 1426 -> 1667 bytes contenders.py | 15 +++++++++++++++ helper_functions.py | 11 +++++++++-- main.py | 16 ++++++++++------ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/__pycache__/contenders.cpython-310.pyc b/__pycache__/contenders.cpython-310.pyc index 1688457b91c08cb16393aeb22d3d2b606366b265..e28c0764529764531c5b147b7708392bdbd81ccc 100644 GIT binary patch delta 440 zcmYk2%}T>S5XX0tO}hO^tYFoHM-PS;ym;tAya*n>SUeOV#O&G@nxsrpK}hI9Um)}i zy!9D8`38EEyg^?;@aC*ibe8?i%zt*7*?s4)wwpLkgOR;_cJJP5rF#IqvU}**vi8J= zT*4LeL^+81E2zw=idVd!3CP+JR5Zr)F&1wh(l)_WJ>z+Ji1kwVqI$j zlX*-U{-2o&)$YXC$Nf-Y7EI#Jts|WeHCc*yfK(Jq tacXKx5hq9mNEk^iSQiIS>=uVjZhlH>PO2RvkXH;6;$Yxl;$Y$t1puKOBHRD~ diff --git a/__pycache__/helper_functions.cpython-310.pyc b/__pycache__/helper_functions.cpython-310.pyc index 76b03822c44de544f7e7001ad23b2fb34545296a..72a0ee94268efbd40aa9bd4be17cf43268c5d927 100644 GIT binary patch delta 592 zcmZ8dL2J}N6n<}JG6}oM?)IQdX_X)%hP}AG2)&gGz1UJH^bjaZ+=;Rft(^>l%Y;2_ z|A5V{r|rq3^wOJuq(4CP>dk}DH>q9G8NTnmkMEl|$(*(4QRg^{T0pD#HF*8S|I}H3 z_L!6cg$1ObnBu39q7urZ%9K<-Rj%*=lHi9sxOe&TD>99Bn|(uG|74#rsn7XzHXyTf zvqNmr?xFatyCla*bhiR(Bw?FSUJ)s*@C{UqK(|za;1Q&S7jU#*`PQ?(!c}+dtsR27U!sV9}G8QK|?P{_d$t1|E@dK2t#Adq%D~D~xNh+CO5nBs4AEB0hfSsk^ zAy``rp6sIca$a|sJ4~0awunn7nx0%R;>JnhI~cr7G{{QjK00 zZ%|*-kJTrz(ocBlpY`os#f$Z@EJMmJVSYl%cm>j5IT}Np67`bg(SlHfCQOtwxhz^6 zb+jI1IgwUJL$B7}+@w)A5~ahgw20>4AFBq9is;yowO1SOWiFxMTa^x$5|V*N!@%_q scCY`iv%@3CdWU4N=>!=HWGbVU2-`fm;DVeQ%KqF<)8Q|PBnO%M1@ZMZ*8l(j 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