Compare commits

...

5 Commits

Author SHA1 Message Date
simonkellet
62e5515472 tweaks 2022-09-16 13:17:43 +01:00
simonkellet
9a4963f474 tweaks 2022-06-13 13:13:06 +01:00
simonkellet
bf7a214788 fixes 2022-05-22 12:01:54 +01:00
simonkellet
df7db80888 git ignore 2022-05-22 12:01:28 +01:00
simonkellet
e9a3fb0217 update rd 2022-05-22 11:54:53 +01:00
4 changed files with 6 additions and 14 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
ttt

View File

@ -4,22 +4,11 @@ A simple TicTacToe game written in C in under 2 hours!
## Usage ## Usage
```bash ```bash
./build ./build.sh
``` ```
then then
```bash ```bash
./ttt ./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! Enjoy!

6
main.c
View File

@ -8,7 +8,7 @@
#define RED "\033[31m" /* Red */ #define RED "\033[31m" /* Red */
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
#define BOLDRED "\033[1m\033[31m" /* Bold Yellow */ #define BOLDRED "\033[1m\033[31m" /* Bold RED */
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */ #define BOLDWHITE "\033[1m\033[37m" /* Bold White */
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
#define RESET "\033[0m" #define RESET "\033[0m"
@ -30,7 +30,7 @@ int main(int argc, char *argv[]){
printf("How many players? (1/2)\n> "); printf("How many players? (1/2)\n> ");
scanf("%d", &players); scanf("%d", &players);
//this could be tidier i think //TODO Tidy this up!
if(players == 1){ if(players == 1){
do{ do{
flag = check_win(); flag = check_win();
@ -42,10 +42,12 @@ int main(int argc, char *argv[]){
player_choice('X'); player_choice('X');
print_board(); print_board();
sleep(2);
cpu_choice('O'); cpu_choice('O');
flag = check_win(); flag = check_win();
print_board(); print_board();
sleep(2);
} while(flag == ' '); } while(flag == ' ');

BIN
ttt

Binary file not shown.