mirror of
				https://github.com/taxicomics/PrisonersDilemma.git
				synced 2025-10-31 12:35:06 +01:00 
			
		
		
		
	reworked presentation
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -37,6 +37,20 @@ def random_positive_leaner(game_data,player_nr): | |||||||
|     #your cool code ended here |     #your cool code ended here | ||||||
|     return choice |     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): | def i_hate_certain_numbers(game_data,player_nr): | ||||||
|     opponent_nr=1-player_nr |     opponent_nr=1-player_nr | ||||||
|     hated_numbers=[7,13,17,23] |     hated_numbers=[7,13,17,23] | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| import statistics | import statistics | ||||||
|  |  | ||||||
| def analyze_results(game_data): | def analyze_results(game_data,game_nr): | ||||||
|     defect_str="X " |     defect_str="X " | ||||||
|     coorperate_str="O " |     coorperate_str="O " | ||||||
|     spacer_str="___"*len(game_data) |     spacer_str=""*len(game_data) | ||||||
|     lines=["These are the results",spacer_str] |     lines=["Game "+str(game_nr)+":",spacer_str] | ||||||
|     str1="Player 1: " |     str1="Player 1: " | ||||||
|     str2="Player 2: " |     str2="Player 2: " | ||||||
|     p_1_points=0 |     p_1_points=0 | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.py
									
									
									
									
									
								
							| @@ -19,13 +19,13 @@ nr_of_games=300#int(input("How many games should be played?")) | |||||||
| #                      Put YOUR functions down below | #                      Put YOUR functions down below | ||||||
| #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||||||
| function1=contenders.random_positive_leaner | function1=contenders.random_positive_leaner | ||||||
| function2=contenders.i_hate_certain_numbers | function2=contenders.random_negative_leaner | ||||||
|  |  | ||||||
| for i in range(nr_of_games): | for i in range(nr_of_games): | ||||||
|     helper_functions.play_game( games,function1,function2,nr_of_rounds) |     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=[] |     games=[] | ||||||
|      |  | ||||||
| print("Played "+str(nr_of_games)+ " games with "+str(nr_of_rounds)+" rounds each.") | 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)") | print("(A huge disparity of the average and median could hint at special behaviour)") | ||||||
| helper_functions.analyze_scores(scores) | helper_functions.analyze_scores(scores) | ||||||
		Reference in New Issue
	
	Block a user