Commit 795f84eb authored by Julian Rudolf's avatar Julian Rudolf
Browse files

changed style for saved experiments txt file

parent 9c45fe84
......@@ -15,8 +15,6 @@ def calculate_times(filename):
mean_time = time_sum / len(times)
worst_case = max(times)
print(mean_time)
print(worst_case)
return mean_time, worst_case
......@@ -33,7 +31,7 @@ def run_experiment(max_steps, length, source_filename, target_filename):
reset(True, int(length))
mean, worst_case = calculate_times(source_filename)
string = "Max Steps: " + str(max_steps) + " | Snake Length: " + str(length) + "\n" + "Mean = " + str(mean) + "\nWorst Case = " + str(worst_case) + "\n"
string = (str(mean)).ljust(25) + " " + str(worst_case)
target_file = open(target_filename, "a")
target_file.write(string)
......
......@@ -20,9 +20,12 @@ SOURCE_FILE="times.txt"
rm $TARGET_FILE
rm $SOURCE_FILE
echo "Mean Worst-Case" >> $TARGET_FILE
echo "-------------------------------------------" >> $TARGET_FILE
echo "Starting experiments!"
for i in 10 15 20
do
echo "Snake Length: " $i
for j in {10..30}
do
echo "Snake length: " $i " max_steps: " $j
......
......@@ -617,7 +617,7 @@ def remove_files(files, master_filename='master.nm'):
# return:
# crash_prob : probability of a crash for each possible direction
def get_shield(crash_prob_queue, snake_player, snake_enemy, count=0, recalc=False, p_move=0):
shield_start = time.process_time()
shield_start = time.process_time_ns()
# master file name
master_filename = 'master_' + str(uuid.uuid4()) + '.nm'
......@@ -667,8 +667,9 @@ def get_shield(crash_prob_queue, snake_player, snake_enemy, count=0, recalc=Fals
# return the crash probabilities (multiprocessing)
crash_prob_queue.put(crash_prob)
shield_end = time.process_time()
shield_end = time.process_time_ns()
total_time = shield_end - shield_start
total_time /= 1e+9
if times_filename:
times_file = open("../Experiments/" + times_filename, "a")
times_file.write(str(total_time) + "\n")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment