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
|
int AI_move(int i, setting_game setting, int playerturn)
{
int move;
if (player[i].difficulty == 1)
return AI_move_random(setting, playerturn);
if (player[i].difficulty == 2)
{
if (playerturn == 1) move = AI_move_random(setting, playerturn);
else if (playerturn == 2) move = AI_move_near(i, playerturn);
else if (playerturn >= 3)
{
move = AI_move_win_vertical(i, playerturn);
if (move == 0) move = AI_move_win_horizontal(i, playerturn);
if (move == 0) move = AI_move_win_diagonal_left(i, playerturn);
if (move == 0) move = AI_move_win_diagonal_right(i, playerturn);
if (move == 0) move = AI_move_near(i, playerturn);
if (move == 0) move = AI_move_random(setting, playerturn);
}
return move;
}
if (player[i].difficulty == 3)
{
if (playerturn == 1) move = AI_move_random(setting, playerturn);
else if (playerturn == 2) move = AI_move_near(i, playerturn);
else if (playerturn >= 3)
{
if (move == 0) move = AI_move_block_horizontal(i, playerturn);
if (move == 0) move = AI_move_block_vertical(i, playerturn);
if (move == 0) move = AI_move_block_diagonal_left(i, playerturn);
if (move == 0) move = AI_move_block_diagonal_right(i, playerturn);
if (move == 0) move = AI_move_win_vertical(i, playerturn);
if (move == 0) move = AI_move_win_horizontal(i, playerturn);
if (move == 0) move = AI_move_win_diagonal_left(i, playerturn);
if (move == 0) move = AI_move_win_diagonal_right(i, playerturn);
if (move == 0) move = AI_move_near(i, playerturn);
if (move == 0) move = AI_move_random(setting, playerturn);
}
cout << move;
return move;
}
|