diff --git a/machine_learning/a_star_search.cpp b/machine_learning/a_star_search.cpp index 349906026..eb6e0002c 100644 --- a/machine_learning/a_star_search.cpp +++ b/machine_learning/a_star_search.cpp @@ -65,10 +65,13 @@ class EightPuzzle { * respectively, else returns -1, -1 */ std::pair find_zero() { - for (int i = 0; i < N; ++i) - for (int j = 0; j < N; ++j) - if (!board[i][j]) + for (int i = 0; i < N; ++i) { + for (int j = 0; j < N; ++j) { + if (!board[i][j]) { return {i, j}; + } + } + } return {-1, -1}; } /** @@ -91,8 +94,9 @@ class EightPuzzle { * @returns -1 if invalid i or j position */ int get(size_t i, size_t j) const { - if (in_range(i) && in_range(j)) + if (in_range(i) && in_range(j)) { return board[i][j]; + } return -1; } /** @@ -157,8 +161,9 @@ class EightPuzzle { * @returns `true` if check.state is equal to `this->state`, else `false` */ bool operator==(const EightPuzzle &check) const { - if (check.get_size() != N) + if (check.get_size() != N) { return false; + } for (size_t i = 0; i < N; ++i) { for (size_t j = 0; j < N; ++j) { if (board[i][j] != check.board[i][j]) { @@ -552,4 +557,4 @@ static void test() { int main() { test(); // run self-test implementations return 0; -} +} \ No newline at end of file