Skip to content

Commit

Permalink
Backup development/release utilities and scripts to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
eric15342335 committed Sep 25, 2024
1 parent e8c3612 commit 7b2b8ec
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
106 changes: 106 additions & 0 deletions devtools/GameSaveAnalysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import matplotlib.pyplot as plt

def read_data(file_path):
"""
Read data from a file and return the x and y values.
Args:
file_path (str): The path to the data file.
Returns:
tuple: A tuple containing the x and y values. If the file is not found or has invalid data, returns empty lists.
"""
with open(file_path, 'r') as file:
lines = file.readlines()
if len(lines) >= 3:
data_line = lines[2].strip()
if data_line.endswith('-1'):
data_values = [float(val) for val in data_line[:-2].split()] # Remove the '-1' terminator
x = list(range(1, len(data_values) + 1))
return x, data_values
return [], []

def get_user_input():
"""
Prompt the user to enter file numbers and validate the input.
Returns:
list: A list of selected file numbers.
"""
print("Enter the file numbers you want to display (0-19), separated by spaces:")
user_input = input().strip()
try:
file_numbers = [int(num) for num in user_input.split() if 0 <= int(num) <= 19]
return file_numbers
except ValueError:
print("Invalid input. Please enter numbers between 0 and 19.")
return get_user_input()

def get_graph_type():
"""
Prompt the user to choose between percentage change or absolute value graph.
Returns:
str: The chosen graph type ('pct' for percentage change, 'abs' for absolute value).
"""
print("Do you want to show percentage change or absolute value graph?")
print("Enter 'pct' for percentage change or 'abs' for absolute value:")
graph_type = input().strip().lower()
if graph_type == 'pct':
return 'pct'
elif graph_type == 'abs':
return 'abs'
else:
print("Invalid input. Please enter 'pct' or 'abs'.")
return get_graph_type()

# Get user input for file selection
selected_files = get_user_input()

# Get user input for graph type
graph_type = get_graph_type()

data = []

for file_num in selected_files:
file_path = f"saves/save/{file_num}.save"
try:
x, y = read_data(file_path)
if x and y: # Only add if we have data
if graph_type == 'pct':
percentage_changes = []
for i in range(1, len(y)):
if y[i-1] != 0: # Avoid division by zero
pct_change = ((y[i] - y[i-1]) / y[i-1]) * 100
else:
pct_change = 0 # or float('inf') if you prefer
percentage_changes.append(pct_change)
data.append((x[:-1], percentage_changes, file_num)) # Exclude the last index for pct_change
else:
data.append((x, y, file_num))
except FileNotFoundError:
print(f"File not found: {file_path}")
except Exception as e:
print(f"Error reading {file_path}: {e}")

if not data:
print("No valid data to plot.")
else:
fig, ax = plt.subplots(figsize=(10, 6))

for x, y, file_num in data:
ax.plot(x, y, label=f"File {file_num}")

if graph_type == 'pct':
graph_title = "Percentage Change of Values from Selected Data Files"
y_label = "Percentage Change (%)"
else:
graph_title = "Absolute Values from Selected Data Files"
y_label = "Value"

ax.set_title(graph_title)
ax.set_xlabel("Index")
ax.set_ylabel(y_label)
ax.legend()
plt.grid(True)
plt.show()
16 changes: 16 additions & 0 deletions devtools/coveralls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
virtualenv _venv --clear
source _venv/scripts/activate
pip install cpp-coveralls

branches="`git branch -lr | cut -c 10- | cut -d ' ' -f 1 | grep -v HEAD`"

for branch in $branches
do
echo $branch
git checkout $branch
make clean
CXXFLAGS=--coverage make goto
gcov src/*.cpp -o .
coveralls
rm *.gcda *.gcno *.gcov
done
Binary file added devtools/peupdate.exe
Binary file not shown.
1 change: 1 addition & 0 deletions devtools/peupdate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_backup\peupdate.exe stocksim-msvc.exe -r -f -t 0 -l -c
Binary file added devtools/stocksim-icon.ico
Binary file not shown.

0 comments on commit 7b2b8ec

Please sign in to comment.