diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-02-16 18:25:26 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-02-16 18:25:26 +0100 |
commit | 01fa26325d9532ac9d8eaec27eb582b37f039552 (patch) | |
tree | a29d2be5dbe8071f8e0555450106ad7d6912f4d5 /console | |
parent | 7986d9560602528ea3034553eb1f0d82267dabbc (diff) |
updated readme + current move
Diffstat (limited to 'console')
-rw-r--r-- | console/voerbak.c | 7 | ||||
-rw-r--r-- | console/voerbak_connector.py | 5 |
2 files changed, 11 insertions, 1 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) |