-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
51 lines (41 loc) · 1.09 KB
/
benchmark.py
File metadata and controls
51 lines (41 loc) · 1.09 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from time import time
from wordle import Wordle
from bot import WordleBot
SCORE_MAX = 20
time_start = time()
performance = {}
for i in range(10):
print(i)
wordle = Wordle()
start_guesses_left = wordle.guesses_left
wordle_bot = WordleBot()
wordle_bot.solve(wordle)
score = start_guesses_left - wordle.guesses_left
if score not in performance:
performance[score] = 0
performance[score] += 1
print(performance)
time_took = time() - time_start
median = 0
total_frequency = 0
for i in range(SCORE_MAX):
score = performance.get(i, 0)
total_frequency += score
frequency = 0
for i in range(SCORE_MAX):
score = performance.get(i, 0)
frequency += score
if frequency > total_frequency // 2:
median = i
break
print('median:', median)
for i in range(SCORE_MAX):
if i > 6:
print('\033[43m', end='')
if i == median:
print('\033[92m', end='')
score = performance.get(i, 0)
print(str(i).rjust(4, ' ') + '|' + '#' * score)
print('\033[0m', end='')
print('\033[0m', end='')
print('time took:', time_took, 'seconds')