File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import logging
33import random
44import re
5+ import sys
56from collections import Counter
67from typing import Optional
78
1516from effectful .ops .semantics import handler
1617
1718
18- @dataclass
19+ @dataclass ( frozen = True )
1920class Step :
2021 start : int
2122 end : int
@@ -267,7 +268,8 @@ def do_voting(self) -> Step: # algorithm 2
267268 ):
268269 self .votes [vote ] += 1
269270 max_other_votes = max (
270- self .votes [o_vote ] for o_vote in self .votes if o_vote != vote
271+ (self .votes [o_vote ] for o_vote in self .votes if o_vote != vote ),
272+ default = 0 ,
271273 )
272274 if self .votes [vote ] >= max_other_votes + self .k :
273275 return vote
@@ -303,11 +305,15 @@ def solve_hanoi(state: GameState):
303305 state .visualise ()
304306
305307
306- logging .basicConfig ()
308+ logging .basicConfig (
309+ level = logging .INFO ,
310+ stream = sys .stdout ,
311+ format = "%(asctime)s [%(levelname)s] %(name)s: %(message)s" ,
312+ )
307313
308314with (
309- handler (ThreadPoolFuturesInterpretation (max_workers = 3 )),
310- handler (LLMLoggingHandler ()),
315+ handler (ThreadPoolFuturesInterpretation ()),
311316 handler (OpenAIAPIProvider (OpenAI ())),
317+ handler (LLMLoggingHandler ()),
312318):
313319 solve_hanoi (state = GameState .new (3 ))
You can’t perform that action at this time.
0 commit comments