From 59d1d28357fa84c253cdf08744c4b0fc9d754632 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 9 Jun 2024 19:00:21 +0200 Subject: [PATCH] added report counter --- tic_tac_toe.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tic_tac_toe.py b/tic_tac_toe.py index f0a032b..20d1e9b 100644 --- a/tic_tac_toe.py +++ b/tic_tac_toe.py @@ -7,10 +7,23 @@ import json float_formatter = "{:.3f}".format np.set_printoptions(formatter={'float_kind': float_formatter}) +REPORT_INTERVAL = 1000 +report_counter = REPORT_INTERVAL + + +def report(k): + global report_counter + if report_counter > 0: + report_counter -= 1 + else: + report_counter = REPORT_INTERVAL-1 + print(f"Iteration: {k:8d}") + def play(player_provider: PlayerProvider, k_max=10000, with_debug=False): player_provider.set_debug(with_debug) for k in range(0, k_max): + report(k) players = player_provider.choose() state = create_empty_state() move = 1