diff options
-rw-r--r-- | console/voerbak.c | 7 | ||||
-rw-r--r-- | console/voerbak_connector.py | 5 | ||||
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | readme_en.md | 2 |
4 files changed, 13 insertions, 3 deletions
diff --git a/console/voerbak.c b/console/voerbak.c index 86f6076..8aaf4e9 100644 --- a/console/voerbak.c +++ b/console/voerbak.c @@ -105,9 +105,14 @@ int main() { while (scanf("%d", &move) == 1) { if (move == 0) break; if (move < 1 || move > width) continue; + bool dropSuccess = dropFisje(board, width, height, move - 1, player_1 + 1); - printBoard(board, width, height); + player_1 = player_1 ^ dropSuccess; // only flip turns on successful drop + printf("m:%s\n", player_1 ? "true" : "false"); + fflush(stdout); + + printBoard(board, width, height); } return 0; diff --git a/console/voerbak_connector.py b/console/voerbak_connector.py index 742ddc0..6274ada 100644 --- a/console/voerbak_connector.py +++ b/console/voerbak_connector.py @@ -18,6 +18,7 @@ class bord: def __init__(self, w, h): self.width = w self.height = h + self.player_1 = True self.board = "0" * (w * h) self.win_positions = [] self.process = subprocess.Popen(["./voerbak"], @@ -38,6 +39,9 @@ class bord: log.info(f"won: {buffer[2:].split('-')}") elif buffer.startswith("e:"): log.warning(buffer[2:]) + elif buffer.startswith("m:"): + substr = buffer[2:] + self.player_1 = True if substr == "true" else False buffer = self.get_output() self.board = buffer @@ -60,6 +64,7 @@ class bord: def main(): gert = bord(7, 6) while True: + print(gert.player_1) if len(gert.win_positions) > 0: print(f"won: {gert.win_positions}") exit(0) @@ -92,7 +92,7 @@ Om dit project te starten moet je 2 terminals gebruiken die afzonderlijk de flas # activeer virtual environment -flask run +python3 api/main.py # term 2 diff --git a/readme_en.md b/readme_en.md index cf8dce2..34bba27 100644 --- a/readme_en.md +++ b/readme_en.md @@ -94,7 +94,7 @@ In order to start this project you'll need two terminal windows to start the fla # activate virtual environment -flask run +python3 api/main.py # term 2 |