-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplayer.c
61 lines (49 loc) · 1.16 KB
/
player.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <sos.h>
char board[50][50];
int Player1, Player2, Computer, players, n;
void two_player()
{
do
{
player_move(1);
if(game_done())
{
return;
}
player_move(2);
}while (!game_done());
return;
}
void player_move(int player)
{
int square;
int row, col;
char symbol;
do
{
draw_board();
printf("\nPlayer %d enter a square: \n",player);
do
{
scanf("%d", &square);
}while (!square_valid(square));
row = (square-1)/n;
col = (square-1)%n;
printf("What symbol do you want to enter in square %d? (S or O) \n", square);
do
{
symbol = getchar();
}while ((symbol != 'S') && (symbol != 's') && (symbol != 'O') && (symbol != 'o') && (symbol != '0'));
if((symbol == 'S') || (symbol == 's'))
{
symbol = 'S';
}
else
{
symbol = 'O';
}
board[row][col] = symbol;
}while(find_sos (square, player, symbol));
return;
}