From 517d366f2258654f892749904c73d0e24456a3ba Mon Sep 17 00:00:00 2001 From: simonkellet Date: Sat, 21 May 2022 22:44:50 +0100 Subject: [PATCH] code clean up and rd update --- README.md | 11 +++++++++++ main.c | 4 ++-- ttt | Bin 19528 -> 19552 bytes 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c90a389..42ec433 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,15 @@ then ./ttt ``` +## CPU +There is infact a CPU programmed into this application! +You can play against it if you swap out: +```c +41 player_choice('O'); +``` +with +```c +41 cpu_choice('O'); +``` + Enjoy! diff --git a/main.c b/main.c index 5e4fa99..62edd49 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ #include #include -#include #include +#include #define ROWS 3 #define COLUMNS 3 @@ -14,7 +14,6 @@ #define RESET "\033[0m" char board[ROWS][COLUMNS]; -char ESC = 27; void print_board(); void clear_board(); @@ -105,6 +104,7 @@ void player_choice(char player){ if(board[pr][pc] != ' ' ){ printf(BOLDRED "\n[%c] Cannot play here, skipping...\n" RESET, player); + sleep(2); } else { board[pr][pc] = player; } diff --git a/ttt b/ttt index 83d584f7dde50b16bc3d98b6e82aca94f4a119cd..7e66a8c1d2bb0412081b4f7c62bf0b9c19f62d58 100755 GIT binary patch delta 3602 zcmZu!4Nz3q6~6cFzWrf=-DO#pMRZy4571puDL=BZM4v8TM$=%YN&Nvq0|_dBPBBTd zG$f8lJK_1t>{bLz zX74%oJKy>4x%a-kZ};LcdgB=FPq$vS5T*IKA$6hLGsY$ZA2orM+Co#AMxP4!5O|9A zhxbvlkosAUv0BW3eE95pm!#i&uU(qx-n$r%Yc|s=uxcG((WcYWKt%`m(R)n6TG89C zcqh?2$D*{EjcJ+Ef2!~!+H~-jX(3ar6FXXV>}ZAO#7i{-p+rk|V`XZ|#L?WGM2JYb zR4i2)Ysri1_}$PE9U&U>BXzttquEG^K#oF4=O`SpB8+X?$E~_V(yHRE{#iI&)pgKh zcvOGIiPOefou9jUH0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