summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp2
-rw-r--r--src/spacebot.cpp9
2 files changed, 6 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1621ba8..c780e1f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -11,7 +11,7 @@ int main(int argc, char* argv[])
}
std::string outputFolder = argv[1];
- Spacebot bot(outputFolder);
+ Spacebot bot(std::move(outputFolder));
bot.writeNextMove();
return 0;
diff --git a/src/spacebot.cpp b/src/spacebot.cpp
index 24a5d1e..716f7cb 100644
--- a/src/spacebot.cpp
+++ b/src/spacebot.cpp
@@ -1,11 +1,11 @@
#include "spacebot.h"
#include <random>
+#include <fstream>
-Spacebot::Spacebot(const std::string& outputPath)
- : mapStream(outputPath+"/map.txt", std::ifstream::in)
- , resultStream(outputPath+"/move.txt", std::ofstream::out)
+Spacebot::Spacebot(std::string outputPath)
+ : outputPath(std::move(outputPath)),
+ gameState(std::ifstream(outputPath+"/map.txt", std::ifstream::in))
{
- std::srand(time(0));
}
void Spacebot::writeNextMove()
@@ -26,6 +26,7 @@ Move Spacebot::chooseMove()
void Spacebot::writeMove(const Move& move)
{
+ std::ofstream resultStream(outputPath+"/move.txt");
switch (move)
{
case Move::NOTHING: