summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp3
-rw-r--r--src/spacebot.cpp9
2 files changed, 6 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1621ba8..578620c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,8 +10,7 @@ int main(int argc, char* argv[])
return 1;
}
- std::string outputFolder = argv[1];
- Spacebot bot(outputFolder);
+ Spacebot bot(argv[1]);
bot.writeNextMove();
return 0;
diff --git a/src/spacebot.cpp b/src/spacebot.cpp
index f2fb95a..b297eb3 100644
--- a/src/spacebot.cpp
+++ b/src/spacebot.cpp
@@ -1,12 +1,12 @@
#include "spacebot.h"
#include <random>
+#include <fstream>
#include <string>
-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()
@@ -27,6 +27,7 @@ Move Spacebot::chooseMove()
void Spacebot::writeMove(const Move& move)
{
+ std::ofstream resultStream(outputPath+"/move.txt");
switch (move)
{
case Move::NOTHING: