forked from nhamil/python-tilewe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_tournament.py
More file actions
31 lines (24 loc) · 1.14 KB
/
example_tournament.py
File metadata and controls
31 lines (24 loc) · 1.14 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
import multiprocessing
import tilewe
import tilewe.engine
import tilewe.tournament
def run_tournament():
tournament = tilewe.tournament.Tournament([
tilewe.engine.MaximizeMoveDifferenceEngine(),
tilewe.engine.LargestPieceEngine(),
tilewe.engine.TileWeightEngine("WallCrawler", 'wall_crawl'),
tilewe.engine.TileWeightEngine("Turtle", 'turtle'),
tilewe.engine.MostOpenCornersEngine(),
tilewe.engine.RandomEngine(),
])
results = tournament.play(100, n_threads=multiprocessing.cpu_count(), move_seconds=15)
# print the result of game 1
print(results.match_data[0].board)
# print the total real time the tournament took and the average duration of each match, in seconds
print(f"Tournament ran for {round(results.real_time, 4)}s with avg " +
f"match duration {round(results.average_match_duration, 4)}s\n")
# print the engine rankings sorted by win_counts desc and then by avg_scores asc
print(results.get_engine_rankings_display('win_counts', 'desc'))
print(results.get_engine_rankings_display('avg_scores', 'asc'))
if __name__ == '__main__':
run_tournament()