Browse code

Switch from C to C++ stdlib for time

Robert Cranston authored on 21/05/2025 21:57:36
Showing 1 changed files

  • maze.cpp index cee73ee..e03e25d 100644
... ...
@@ -1,6 +1,5 @@
1 1
 #include <chrono>
2 2
 #include <cstdlib>
3
-#include <ctime>
4 3
 #include <iostream>
5 4
 #include <sstream>
6 5
 #include <thread>
... ...
@@ -119,7 +118,8 @@ int main(int argc, char const * [])
119 118
     using namespace std::chrono;
120 119
     if (argc == 1)
121 120
     {
122
-        auto seed = (unsigned)std::time(nullptr);
121
+        auto time = system_clock::now().time_since_epoch();
122
+        auto seed = (unsigned)duration_cast<seconds>(time).count();
123 123
         auto maze = hunt_and_kill(80/2, 24-1, seed, [](Maze & maze) {
124 124
             maze.print();
125 125
             std::this_thread::sleep_for(milliseconds(20));