Commit 8799fc97 authored by Jan Pokorný's avatar Jan Pokorný 💬

grading moves as in Qubic

parent 0e4bbc70
......@@ -145,6 +145,32 @@ void fill_column(ConnectFour3D::CF3DBoard & board, ConnectFour3D::CF3DBoard ston
board = board | stone;
}
//same as qubic for now
int gradeMovesCF(int stone_index, QubicBoard firstPlayerStones, QubicBoard secondPlayerStones, bool plays_first) {
int score = 100;
QubicBoard nextPlayer = plays_first ? firstPlayerStones : secondPlayerStones;
QubicBoard opponent = plays_first ? secondPlayerStones : firstPlayerStones;
bool isomd = is_on_main_diagonal(1UL << stone_index);
int numLines = isomd ? 7 : 4;
const int score_transformation[16] = {// row is player, column is opponent, -0 marks tha it is not possible
5, 0, 0, 1000,
15, -2, -2, -0,
100, -2, -0, -0,
10000, -0, -0, -0};
for (int i = 0; i < numLines; ++i) {
QubicBoard line = ConnectFour3D::pointLines[stone_index][i];
int nextPlayerCount = countOnes(nextPlayer & line);
int opponentCount = countOnes(opponent & line);
int combined = nextPlayerCount * 4 + opponentCount;
score += score_transformation[combined];
}
(void)firstPlayerStones;
(void)secondPlayerStones;
return (isomd == !plays_first) ? score + 10 : score;
}
vector<ConnectFour3D> ConnectFour3D::generateChildren() const {
CF3DBoard stones = firstPlayerStones | secondPlayerStones;
bool plays_first = countOnes(stones) % 2 == 0;
......@@ -156,7 +182,7 @@ vector<ConnectFour3D> ConnectFour3D::generateChildren() const {
int current_child = 0;
for (int i = 0; i < 64; ++i) {
if ((stone & put_mask) == 0) {
int points = 0; //gradeMoves(i, firstPlayerStones, secondPlayerStones, plays_first);
int points = gradeMovesCF(i, firstPlayerStones, secondPlayerStones, plays_first);
validMoves[current_child++] = {stone, points};
fill_column(put_mask, stone);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment