From 53bd62f3a55cde1dce09bdb867dfe0b84d578227 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Sat, 27 Jan 2024 13:31:17 +0200 Subject: Adding exit codes and batch runner script. --- README.md | 6 +++--- __main__.py | 6 +++++- app.py | 1 + batch/100-run-beginner-bad.sh | 8 ++++++++ tui/autotui.py | 10 ++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 batch/100-run-beginner-bad.sh diff --git a/README.md b/README.md index 0be8738..dab4191 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ Miinaharava ratkaisijalla ### Asenna `git clone https://github.com/Aineopintojen-harjoitustyo-Algoritmit-j/miinaharava` -### Aja +### Pelaa `python3 miinaharava` ### Käyttöohjeet `python3 miinaharava -h` -### Automaattipelin suoritusesimerkki -`python3 miinaharava -i -a -u` +### Skripti joka pelaa automaattisesti 100 peliä aloittelijan vaikeustasolla +`bash miinaharava/batch/100-run-beginner-bad.sh` diff --git a/__main__.py b/__main__.py index edf3888..627f724 100644 --- a/__main__.py +++ b/__main__.py @@ -1,4 +1,5 @@ """ __main__.py - Tästä suoritus alkaa """ +import sys from argparse import ArgumentParser from app import App @@ -35,4 +36,7 @@ parser.add_argument( args = parser.parse_args() app = App(args) -app.run() +is_win = app.run() +del app + +sys.exit(not is_win) # Exit koodeissa 0 on onnistunut suoritus diff --git a/app.py b/app.py index be44752..a38c897 100644 --- a/app.py +++ b/app.py @@ -27,3 +27,4 @@ class App: """ käynnistää pelin """ while self.game.next(): pass + return self.board.is_winning() diff --git a/batch/100-run-beginner-bad.sh b/batch/100-run-beginner-bad.sh new file mode 100644 index 0000000..f66ea22 --- /dev/null +++ b/batch/100-run-beginner-bad.sh @@ -0,0 +1,8 @@ +#!/bin/bash +let COUNT=100 +let WINS=0 +for ((i=0;i