This commit is contained in:
Mylloon 2023-02-21 14:20:03 +01:00
parent fc077eb86b
commit 94d9102b64
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -106,11 +106,13 @@ bool is_in_history(Node current, std::vector<Node> history) {
int c = 0; int c = 0;
for (int l = 0; l < NBL; ++l) { for (int l = 0; l < NBL; ++l) {
for (int m = 0; m < NBC; ++m) { for (int m = 0; m < NBC; ++m) {
if (current.state.board[l][m] != current.state.board[l][m]) c++; if (current.state.board[l][m] != current.state.board[l][m])
c++;
} }
} }
if (c == 0) return true; if (c == 0)
return true;
} }
return false; return false;
} }
@ -319,6 +321,9 @@ int dfs(Node &result, int depth, std::vector<Node> history) {
sok_board_t next = result.state; sok_board_t next = result.state;
// Déplacement caisse, ancienne position // Déplacement caisse, ancienne position
if (next.board[cx][cy] == CRATE_ON_TARGET) {
++next.num_crates_free;
}
next.board[cx][cy] = next.board[cx][cy] =
next.board[cx][cy] == CRATE_ON_TARGET ? TARGET : FREE; next.board[cx][cy] == CRATE_ON_TARGET ? TARGET : FREE;
// Déplacement caisse, nouvelle position // Déplacement caisse, nouvelle position