summaryrefslogtreecommitdiff
path: root/game/objectives/freeroam.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-09 01:21:46 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-09 01:21:46 +0000
commitd39c6dd18248927044d2f75cefd2ed8ba12eb3b7 (patch)
tree49f165919282a3791d2545d2f18aaf9549586e95 /game/objectives/freeroam.cpp
parentSplit ActivityOf<> into its own file (diff)
downloadilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.tar.bz2
ilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.tar.xz
ilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.zip
Make objectives responsible for navigation
Diffstat (limited to 'game/objectives/freeroam.cpp')
-rw-r--r--game/objectives/freeroam.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/game/objectives/freeroam.cpp b/game/objectives/freeroam.cpp
new file mode 100644
index 0000000..0721ef2
--- /dev/null
+++ b/game/objectives/freeroam.cpp
@@ -0,0 +1,22 @@
+#include "freeroam.h"
+#include <game/activities/go.h>
+#include <game/activity.h>
+#include <game/network/link.h>
+#include <iterator>
+#include <memory>
+#include <random>
+#include <vector>
+
+ActivityPtr
+FreeRoam::createActivity() const
+{
+ return std::make_unique<Go>();
+}
+
+Link::Next
+FreeRoam::navigate(Link::Nexts::const_iterator begin, Link::Nexts::const_iterator end) const
+{
+ static std::mt19937 gen(std::random_device {}());
+ auto off = std::uniform_int_distribution<>(0, std::distance(begin, end) - 1)(gen);
+ return begin[off];
+}