@@ -13,17 +13,17 @@ std::unordered_set<uint64_t> visited;
1313 * Explore and print all possible position under a given depth.
1414 * symetric positions are printed only once.
1515 */
16- void explore (const Position &P, char * pos_str, const int depth) {
16+ void explore (const Position &P, char * const pos_str, const int depth) {
1717 uint64_t key = P.key3 ();
1818 if (visited.count (key)) return ; // already explored position
1919 visited.insert (key); // flag new position as visited
2020
21- int nb_moves = P.nbMoves ();
21+ const int nb_moves = P.nbMoves ();
2222 if (nb_moves <= depth)
2323 std::cout << pos_str << std::endl;
2424 if (nb_moves >= depth) return ; // do not explore at further depth
2525
26- for (int i = 0 ; i < Position::WIDTH; i++ ) // explore all possible moves
26+ for (int i = 0 ; i < Position::WIDTH; ++i ) // explore all possible moves
2727 if (P.canPlay (i) && !P.isWinningMove (i)) {
2828 Position P2 (P);
2929 P2.playCol (i);
@@ -71,8 +71,9 @@ void generate_opening_book() {
7171 */
7272int main (int argc, char ** argv) {
7373 if (argc > 1 ) {
74- int depth = atoi (argv[1 ]);
75- char pos_str[depth + 1 ] = {0 };
74+ const int depth = atoi (argv[1 ]);
75+ char pos_str[depth + 1 ];
76+ memset (pos_str, 0 , (depth + 1 ) * sizeof (int ));
7677 explore (Position (), pos_str, depth);
7778 } else generate_opening_book ();
7879}
0 commit comments