#include "spacebot.h" #include "move_string_mapper.h" #include "brain/neural_network.h" #include Spacebot::Spacebot(std::string outputPath, std::string brainFilename) : _outputFilename(outputPath+"/move.txt"), _brainFilename(brainFilename), _gameState(std::ifstream(outputPath+"/map.txt")) { } void Spacebot::writeNextMove() { Move move = chooseMove(); writeMove(move); } Move Spacebot::chooseMove() { auto sensorInputs = _gameState.toBitArray(); NeuralNetwork network(std::ifstream(_brainFilename), sensorInputs, static_cast(Move::BUILD_SHIELD)); int moveInt = network.findMaxOutputIndex(); return static_cast(moveInt); } void Spacebot::writeMove(const Move& move) { std::ofstream resultStream(_outputFilename); resultStream << MoveStringMapper().toString(move) << std::endl; return; }