Another bug fix, added pawn rank weight bonus

This commit is contained in:
Marcus Penate 2022-04-19 12:48:42 -04:00
parent 204cac3174
commit 6ed4f41803
2 changed files with 15 additions and 10 deletions

View File

@ -580,8 +580,7 @@ std::vector<int> Board::get_moves_for_space(int x, int y, bool check_for_check)
game_board[7][y] = king_piece;
game_board[x][y] = rook_piece;
if (!is_check(game_board[x][y].get_team()))
out_spaces.push_back(7+y*BOARD_SIZE);
out_spaces.push_back(7+y*BOARD_SIZE);
game_board[7][y] = rook_piece;
game_board[x][y] = king_piece;
@ -596,8 +595,7 @@ std::vector<int> Board::get_moves_for_space(int x, int y, bool check_for_check)
game_board[0][y] = king_piece;
game_board[x][y] = rook_piece;
if (!is_check(game_board[x][y].get_team()))
out_spaces.push_back(y*BOARD_SIZE);
out_spaces.push_back(y*BOARD_SIZE);
game_board[0][y] = rook_piece;
game_board[x][y] = king_piece;

View File

@ -378,11 +378,6 @@ int Game::board_heuristic(Board current_board)
int heuristic = 0;
int piece_weights[2][7] = {{-900, -90, -30, -30, -50, -10, 0}, {900, 90, 30, 30, 50, 10, 0}};
///Calculate the weight of an unknown piece for both teams
//The weight of an unknown piece is 2 times the average of the remaining unrevealed pieces
//The weight is 2 times so that the AI understands that the hidden pieces are valuable hidden, otherwise the average
//is less than that of Rooks, making the AI always reveal its rooks.
//In order to still sometimes prefer revealing, the number of vulnerabilities will be considered later into a pieces weight.
int unknown_white_count = 0;
int unknown_black_count = 0;
for(int x = 0; x < BOARD_SIZE; x++)
@ -439,6 +434,18 @@ int Game::board_heuristic(Board current_board)
int adden = piece_weights[cur_piece.get_team()][cur_piece.get_type()];
if (cur_piece.get_type() == PAWN)
{
if (cur_piece.get_team() == WHITE)
{
adden -= 2*(6-y);
}
else
{
adden += 2*(y-1);
}
}
int found_attackers = current_board.get_attackers_for_space(x+y*BOARD_SIZE);
if (found_attackers > 0)
@ -447,7 +454,7 @@ int Game::board_heuristic(Board current_board)
}
else if (found_attackers < 0)
{
adden = 5*adden/4;
adden = 4*adden/3;
}
heuristic += adden;