From 4cc2362dbba62bb6e012cc5f60ab52867d5652e1 Mon Sep 17 00:00:00 2001 From: taxicomics <168220579+taxicomics@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:37:23 +0000 Subject: [PATCH] Improved usability removed herobrine --- README.md | 2 ++ __pycache__/helper_functions.cpython-310.pyc | Bin 1245 -> 1426 bytes helper_functions.py | 18 +++++++++++++++--- main.py | 15 ++++++++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a382087..7d8d0ea 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,5 @@ The prisoner's dilemma is a game theory thought experiment that involves two rational agents, each of whom can COORPERATE for mutual benefit or betray their partner ("defect") for individual reward. + +YOUR algorithm goes in the contender.py-file. You then go to main and pit it against another contender or itself. \ No newline at end of file diff --git a/__pycache__/helper_functions.cpython-310.pyc b/__pycache__/helper_functions.cpython-310.pyc index 1d6e04e59e8e68ec42e036b21f16d2b715cb7444..76b03822c44de544f7e7001ad23b2fb34545296a 100644 GIT binary patch delta 443 zcmZWlO-chX6wXW1>9q4hyOCBeU~wVs#;wpU1i_66G9qJaXJ*sdni+*k#x8mS4SEG} z=@EpULJ$w(1$>zi70l!N;U)R<^Ip4m{Hf>F369n0R-9XR{xO`rBqw00sFXq*%3VJN45ub{lQx64(^u)x#-?%v$2?miI_wk-Q=wWnEdZyp>jkY zk;X_P$N@nS48au{kW)XeD5feSXpwMEu-}- JZ?jF;`U29iT(STF delta 320 zcmbQleV3CjpO=@50SNM6YNwg7PUMSVjMGB2ET| zdZ@{%Me%t>QOrfDCFmCO7A5AT}^?K!f;zG}sMb5hN49 eo&dX_!zMRBr8Fni4&I! diff --git a/helper_functions.py b/helper_functions.py index 4705fcc..d2a3728 100644 --- a/helper_functions.py +++ b/helper_functions.py @@ -36,6 +36,7 @@ def analyze_results(game_data): #print the results for i in lines: print(i) + return p_1_points,p_2_points def play_game(games_array,func1,func2,how_many_times): for i in range(how_many_times): @@ -43,6 +44,17 @@ def play_game(games_array,func1,func2,how_many_times): choice_2=func2(games_array,1) games_array.append([choice_1,choice_2]) -def random_choice(game_data,player_nr): - ret=True - return ret \ No newline at end of file +def analyze_scores(score_table): + average_score_p_1=0 + average_score_p_2=0 + p1_sum=0 + p2_sum=0 + for i in score_table: + p1_sum+=i[0] + p2_sum+=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(score_table) \ No newline at end of file diff --git a/main.py b/main.py index a382403..508f64a 100644 --- a/main.py +++ b/main.py @@ -9,10 +9,19 @@ import helper_functions import contenders #vars +#keeping track of the individual games games=[] +#keeping track of the games scores for later analysis +scores=[] +nr_of_rounds=30 +nr_of_games=300 +function1=contenders.random_positive_leaner +function2=contenders.random_positive_leaner #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # Put YOUR function down below #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - -helper_functions.play_game( games,contenders.random_positive_leaner , contenders.my_winning_function ,30) -helper_functions.analyze_results(games) +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=[] +helper_functions.analyze_scores(scores) \ No newline at end of file