-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai_turn.c
61 lines (54 loc) · 916 Bytes
/
ai_turn.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
61
/*
** ai_turn.c for a in /home/soucan_d/soucan_d/Projets/CPE_2015_Allum1
**
** Made by Dimitri
** Login <[email protected]>
**
** Started on Wed Feb 10 11:41:07 2016 Dimitri
** Last update Wed Feb 17 03:53:23 2016 Dimitri
*/
#include <time.h>
#include <stdlib.h>
int make_human_and_ai_play_a_round(int a)
{
static int player_turn;
if (player_turn == 0)
{
player_turn++;
my_putstr("Your turn:\n");
return (1);
}
else
{
my_putstr("AI's turn...\n");
player_turn--;
return (2);
}
}
int get_ai_rand_matches(int pipe)
{
int nb;
srand(time(NULL));
nb = (rand() % pipe) + 1;
return (nb);
}
int rand_line(char **str)
{
int line;
int a;
line = 1;
a = 0;
while (str[line][a] != 0)
{
if (str[line][a] == '|')
return (line);
else if (a == 6)
{
a = 0;
line = line + 1;
}
else
a = a + 1;
}
return (0);
}