-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_analyzer.py
More file actions
34 lines (28 loc) · 979 Bytes
/
game_analyzer.py
File metadata and controls
34 lines (28 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import eval7
import matplotlib.pyplot as plt
import numpy as np
# Read in log file and prompt user for player identity
log_file_path = "gamelog.txt"
# Read in text file
with open(log_file_path, "r") as file:
log_content = file.readlines()
# Get player is A or player is B
player_identity = input("Enter the player's identity: ")
player_identity = player_identity.upper()
if player_identity != "A" and player_identity != "B":
raise NameError()
# Extract the wins/losses of your player in a round-by-round basis
stack_tracker = []
for line in log_content:
# Check for the player's actions in each round
if player_identity in line:
if "awarded" in line:
awarded_amount = int(line.split("awarded")[1])
stack_tracker.append(awarded_amount)
cumulative_sum = np.cumsum(stack_tracker)
plt.plot(cumulative_sum, color='b')
plt.title('Cumulative Sum Over Time')
plt.xlabel('Time')
plt.ylabel('Cumulative Sum')
plt.grid(True)
plt.show()