summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile27
-rw-r--r--include/spacebot.h13
-rw-r--r--run.sh3
-rw-r--r--src/main.cpp17
-rw-r--r--src/spacebot.cpp12
7 files changed, 77 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3cacfac
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+CMakeCache.txt
+CMakeFiles
+cmake_install.cmake
+install_manifest.txt
+output/
+cppbot
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7881e49..525c1ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.2.2)
project(cppbot)
+set(CMAKE_CXX_FLAGS "-std=c++11")
+
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE SRC_FILES RELATIVE ${PROJECT_SOURCE_DIR} src/*.cpp)
diff --git a/Makefile b/Makefile
index f1d7a53..1189987 100644
--- a/Makefile
+++ b/Makefile
@@ -138,6 +138,30 @@ src/main.cpp.s:
$(MAKE) -f CMakeFiles/cppbot.dir/build.make CMakeFiles/cppbot.dir/src/main.cpp.s
.PHONY : src/main.cpp.s
+src/spacebot.o: src/spacebot.cpp.o
+.PHONY : src/spacebot.o
+
+# target to build an object file
+src/spacebot.cpp.o:
+ $(MAKE) -f CMakeFiles/cppbot.dir/build.make CMakeFiles/cppbot.dir/src/spacebot.cpp.o
+.PHONY : src/spacebot.cpp.o
+
+src/spacebot.i: src/spacebot.cpp.i
+.PHONY : src/spacebot.i
+
+# target to preprocess a source file
+src/spacebot.cpp.i:
+ $(MAKE) -f CMakeFiles/cppbot.dir/build.make CMakeFiles/cppbot.dir/src/spacebot.cpp.i
+.PHONY : src/spacebot.cpp.i
+
+src/spacebot.s: src/spacebot.cpp.s
+.PHONY : src/spacebot.s
+
+# target to generate assembly for a file
+src/spacebot.cpp.s:
+ $(MAKE) -f CMakeFiles/cppbot.dir/build.make CMakeFiles/cppbot.dir/src/spacebot.cpp.s
+.PHONY : src/spacebot.cpp.s
+
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@@ -150,6 +174,9 @@ help:
@echo "... src/main.o"
@echo "... src/main.i"
@echo "... src/main.s"
+ @echo "... src/spacebot.o"
+ @echo "... src/spacebot.i"
+ @echo "... src/spacebot.s"
.PHONY : help
diff --git a/include/spacebot.h b/include/spacebot.h
new file mode 100644
index 0000000..920eb73
--- /dev/null
+++ b/include/spacebot.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <iostream>
+#include <fstream>
+
+class Spacebot {
+public:
+ Spacebot(const std::string& outputPath);
+ void writeNextMove();
+private:
+ std::ifstream mapStream;
+ std::ofstream resultStream;
+};
diff --git a/run.sh b/run.sh
new file mode 100644
index 0000000..34176a6
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+cppbot $1
diff --git a/src/main.cpp b/src/main.cpp
index 9aeccde..1621ba8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,7 +1,18 @@
#include <iostream>
+#include <string>
-int main()
+#include "spacebot.h"
+
+int main(int argc, char* argv[])
{
- std::cout << "Hello world" << std::endl;
- return 0;
+ if (argc < 2) {
+ std::cout << "usage: " << argv[0] << " <output folder>" << std::endl;
+ return 1;
+ }
+
+ std::string outputFolder = argv[1];
+ Spacebot bot(outputFolder);
+ bot.writeNextMove();
+
+ return 0;
}
diff --git a/src/spacebot.cpp b/src/spacebot.cpp
new file mode 100644
index 0000000..0fc39b1
--- /dev/null
+++ b/src/spacebot.cpp
@@ -0,0 +1,12 @@
+#include "spacebot.h"
+
+Spacebot::Spacebot(const std::string& outputPath)
+ : mapStream(outputPath+"map.txt", std::ifstream::in)
+ , resultStream(outputPath+"move.txt", std::ofstream::out)
+{
+}
+
+void Spacebot::writeNextMove()
+{
+ resultStream << "Shoot" << std::endl;
+}