PrisonersDilemma/main.py

31 lines
1.2 KiB
Python
Raw Permalink Normal View History

2024-04-26 20:01:54 +02:00
#basic setup
#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.
#imports
import helper_functions
import contenders
#vars
2024-04-26 20:37:23 +02:00
#keeping track of the individual games
2024-04-26 20:01:54 +02:00
games=[]
2024-04-26 20:37:23 +02:00
#keeping track of the games scores for later analysis
scores=[]
2024-04-26 21:11:23 +02:00
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?"))
2024-04-26 20:01:54 +02:00
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2024-04-26 21:11:23 +02:00
# Put YOUR functions down below
2024-04-26 20:01:54 +02:00
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2024-04-26 22:56:46 +02:00
function1=contenders.lil_devil
function2=contenders.lil_devil
2024-04-26 21:11:23 +02:00
2024-04-26 20:37:23 +02:00
for i in range(nr_of_games):
helper_functions.play_game( games,function1,function2,nr_of_rounds)
2024-04-26 21:45:42 +02:00
scores.append(helper_functions.analyze_results(games,len(scores)+1))
2024-04-26 20:37:23 +02:00
games=[]
2024-04-26 21:45:42 +02:00
2024-04-26 21:11:23 +02:00
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)")
2024-04-26 20:37:23 +02:00
helper_functions.analyze_scores(scores)