From 1c0e7383a71d10fec06a2a48e46ae3f118215bcb Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Tue, 22 Nov 2022 13:06:55 -0800 Subject: added print for winning player name --- ttt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ttt.c b/ttt.c index fcb3724..c50b9d0 100644 --- a/ttt.c +++ b/ttt.c @@ -110,7 +110,7 @@ int get_game_state(int boardState[3][3]) { int* user_input_pos(int boardState[3][3], int turn) { char* tip = malloc(3 * sizeof(char)); int* ip = malloc(2 * sizeof(int)); - printf("Enter coordinates: "); + printf("Enter coordinates (like \"A3\"): "); scanf("%2s", tip); for(int i = 0; i < 2; i++) { if(tip[i] <= '9' && tip[i] >= '0') { @@ -164,7 +164,6 @@ struct PosInfo minimax(int boardState[3][3], int turn) { } } } - //don't forget to clean up bestmove pointers struct PosInfo posInfo; posInfo.eval = eval; posInfo.pos = bestMove; @@ -194,7 +193,9 @@ int main() { if(s == 1 || s == 2) { clear_screen(); draw_board(board); - printf("Someone won!"); + printf("Player "); + printf(s == 1 ? "X" : "O"); + printf(" won!"); printf("\n"); break; } -- cgit v1.3.1