-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI2_move_pawn.cpp
42 lines (40 loc) · 1.24 KB
/
AI2_move_pawn.cpp
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
#include "AI.h"
void move_2(Player* player_AI, Board* table_s, char AI_pawn_char, bool& inserted, int i, int j)
{
/*
Here we want to move the pawn which are closest to the home by dice1 if possible
*/
if (table_s->pawns[i][j] == AI_pawn_char && i + player_AI->dice1 < N_COLUMNS && player_AI->dice1 != 0)
{
inserted = AI2_check_insert_conditions(table_s, player_AI, i, j, AI_pawn_char, player_AI->dice1);
if (inserted)
{
player_AI->dice1 = 0;
}
}
if (table_s->pawns[i][j] == AI_pawn_char && i + player_AI->dice2 < N_COLUMNS && player_AI->dice2 != 0)
{
inserted = AI2_check_insert_conditions(table_s, player_AI, i, j, AI_pawn_char, player_AI->dice2);
if (inserted)
{
player_AI->dice2 = 0;
}
}
}
void AI2_move_pawn(Board* table_s, Player* player_AI, int i, int j, int dice_sum, char AI_pawn_char)
{
bool inserted = false;
/*
Here we want to move the pawn which is the closest to the home by dice_sum if possible.
*/
if (table_s->pawns[i][j] == AI_pawn_char && i + dice_sum < N_COLUMNS && dice_sum != 0)
{
inserted = AI2_check_insert_conditions(table_s, player_AI, i, j, AI_pawn_char, dice_sum);
if (inserted)
{
player_AI->dice1 = 0;
player_AI->dice2 = 0;
}
}
move_2(player_AI, table_s, AI_pawn_char, inserted, i, j);
}