summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-02-09 07:49:06 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-02-09 07:50:15 +0200
commit110dc9d9debd99dfda2f11773d6e1bce6f622ed3 (patch)
treeb3ce3ee99c2a9bfb0adf8fbf934952fd21c27340 /__main__.py
parent962156c74418699ad93185f402e88f833779a42d (diff)
Refactoring tests and re-enabling linting.
Diffstat (limited to '__main__.py')
-rw-r--r--__main__.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/__main__.py b/__main__.py
index c98633b..253e699 100644
--- a/__main__.py
+++ b/__main__.py
@@ -8,42 +8,42 @@ vars(args)['board'] = None
if args.count is None and args.file is None:
app = App(args)
- is_win = app.run()
+ IS_WIN = app.run()
del app
- sys.exit(not is_win) # Exit koodeissa 0 on onnistunut suoritus
+ sys.exit(not IS_WIN) # Exit koodeissa 0 on onnistunut suoritus
-win_count = 0
+WIN_COUNT = 0
if args.file is None:
args.autoplay = 2
- run_count = args.count
- for i in range(run_count):
- print(end=f" \rSuoritus {i+1:>6}/{run_count} ")
- print(end=f"({100*win_count/(i if i else 1):.1f}%)..")
+ RUN_COUNT = args.count
+ for i in range(RUN_COUNT):
+ print(end=f" \rSuoritus {i+1:>6}/{RUN_COUNT} ")
+ print(end=f"({100*WIN_COUNT/(i if i else 1):.1f}%)..")
if not args.quiet:
print()
app = App(args)
- win_count+=app.run()
+ WIN_COUNT+=app.run()
del app
else:
- run_count = 0
+ RUN_COUNT = 0
with open(args.file, "r", encoding="utf-8") as bfile:
board = []
while True:
line = bfile.readline()
if not line or (line[0]!='.' and line[0]!='@'):
if board:
- win_percent = (100*win_count/run_count) if run_count else 0
+ WIN_PERCENT = (100*WIN_COUNT/RUN_COUNT) if RUN_COUNT else 0
print(end=
- f" \rAjo ...{args.file[-18:]:} ({run_count+1}): "
- f"({win_percent:.1f}%).."
+ f" \rAjo ...{args.file[-18:]:} ({RUN_COUNT+1}): "
+ f"({WIN_PERCENT:.1f}%).."
)
if not args.quiet:
print()
args.board = board
app = App(args)
- win_count += app.run()
- run_count += 1
+ WIN_COUNT += app.run()
+ RUN_COUNT += 1
del app
board = []
if not line:
@@ -52,6 +52,6 @@ else:
board.append([x=='@' for x in line if x in ('.', '@')])
print(
- f"\n## Voittoja {win_count}/{run_count} "
- f"({(100*win_count/run_count) if run_count else 0:.1f}%)"
+ f"\n## Voittoja {WIN_COUNT}/{RUN_COUNT} "
+ f"({(100*WIN_COUNT/RUN_COUNT) if RUN_COUNT else 0:.1f}%)"
)