reworked presentation

This commit is contained in:
taxicomics 2024-04-26 19:45:42 +00:00
parent 00a9debb4b
commit 96eae218c6
5 changed files with 20 additions and 6 deletions

View File

@ -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]

View File

@ -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

View File

@ -19,11 +19,11 @@ 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.")