-
Notifications
You must be signed in to change notification settings - Fork 0
/
computer.c
54 lines (50 loc) · 1.55 KB
/
computer.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* computer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: byoung-w <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/09/08 14:49:06 by byoung-w #+# #+# */
/* Updated: 2017/03/05 21:33:05 by abassibe ### ########.fr */
/* */
/* ************************************************************************** */
#include "connect_four.h"
t_bool com_easy(void)
{
if (easy_verif(ID_COMPUTER) == 1)
return (true);
else if (easy_verif(ID_PLAYER) == 1)
{
P = 0;
return (true);
}
else if (g_connect.difficulty == DIFFICULTY_EASY)
{
easy_random_pick();
return (true);
}
return (false);
}
t_bool com_medium(void)
{
if (com_easy())
return (true);
else if (medium_verif(ID_COMPUTER) == 1)
return (true);
else if (medium_verif(ID_PLAYER) == 1)
{
P = 0;
return (true);
}
medium_random_pick();
return (false);
}
void computer_turn(void)
{
if (g_connect.difficulty == DIFFICULTY_EASY)
com_easy();
if (g_connect.difficulty == DIFFICULTY_MEDIUM)
com_medium();
g_connect.round++;
}