Browse Source

removed GridOptions

pull/16/head
sp 10 months ago
parent
commit
aa6fd9219e
  1. 8
      main.cpp
  2. 16
      util/Grid.cpp
  3. 15
      util/Grid.h

8
main.cpp

@ -83,7 +83,6 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
GridOptions gridOptions = { {}, {} };
std::fstream file {outputFilename->value(0), file.trunc | file.out};
std::fstream infile {inputFilename->value(0), infile.in};
std::string line, content, background, rewards, properties;
@ -164,12 +163,11 @@ int main(int argc, char* argv[]) {
setProbability(properties, probabilities, probTurnIntendedIdentifier, probTurnIntended);
}
if(ok) {
Grid grid(contentCells, backgroundCells, gridOptions, stateRewards, probIntended, faultyProbability);
Grid grid(contentCells, backgroundCells, stateRewards, probIntended, faultyProbability);
// grid.printToPrism(std::cout, configurations , gridOptions.getModelType());
grid.printToPrism(std::cout, configurations);
std::stringstream ss;
// grid.printToPrism(file, configurations ,prism::ModelType::MDP);
grid.printToPrism(ss, configurations , gridOptions.getModelType());
grid.printToPrism(ss, configurations);
std::string str = ss.str();
grid.applyOverwrites(str, configurations);
file << str;

16
util/Grid.cpp

@ -3,16 +3,8 @@
#include <algorithm>
prism::ModelType GridOptions::getModelType() const
{
if (agentsWithView.size() > 1) {
return prism::ModelType::SMG;
}
return prism::ModelType::MDP;
}
Grid::Grid(cells gridCells, cells background, const GridOptions &gridOptions, const std::map<coordinates, float> &stateRewards, const float probIntended, const float faultyProbability)
: allGridCells(gridCells), background(background), gridOptions(gridOptions), stateRewards(stateRewards), probIntended(probIntended), faultyProbability(faultyProbability)
Grid::Grid(cells gridCells, cells background, const std::map<coordinates, float> &stateRewards, const float probIntended, const float faultyProbability)
: allGridCells(gridCells), background(background), stateRewards(stateRewards), probIntended(probIntended), faultyProbability(faultyProbability)
{
cell max = allGridCells.at(allGridCells.size() - 1);
maxBoundaries = std::make_pair(max.row - 1, max.column - 1);
@ -38,7 +30,6 @@ Grid::Grid(cells gridCells, cells background, const GridOptions &gridOptions, co
std::string color = adversary.getColor();
color.at(0) = std::toupper(color.at(0));
try {
if(gridOptions.agentsToBeConsidered.size() != 0 && std::find(gridOptions.agentsToBeConsidered.begin(), gridOptions.agentsToBeConsidered.end(), color) == gridOptions.agentsToBeConsidered.end()) continue;
auto success = agentNameAndPositionMap.insert({ color, adversary.getCoordinates() });
floor.push_back(adversary);
if(!success.second) {
@ -130,9 +121,8 @@ void Grid::applyOverwrites(std::string& str, std::vector<Configuration>& configu
}
}
}
void Grid::printToPrism(std::ostream& os, std::vector<Configuration>& configuration ,const prism::ModelType& modelType) {
void Grid::printToPrism(std::ostream& os, std::vector<Configuration>& configuration) {
cells northRestriction, eastRestriction, southRestriction, westRestriction;
cells walkable = floor;
walkable.insert(walkable.end(), goals.begin(), goals.end());
walkable.insert(walkable.end(), boxes.begin(), boxes.end());

15
util/Grid.h

@ -6,29 +6,20 @@
#include <utility>
#include "MinigridGrammar.h"
#include "PrismPrinter.h"
#include "PrismModulesPrinter.h"
#include "PrismFormulaPrinter.h"
#include "ConfigYaml.h"
struct GridOptions {
std::vector<AgentName> agentsToBeConsidered;
std::vector<AgentName> agentsWithView;
std::vector<AgentName> agentsWithProbabilisticBehaviour;
std::vector<float> probabilitiesForActions;
bool enforceOneWays;
prism::ModelType getModelType() const;
};
class Grid {
public:
Grid(cells gridCells, cells background, const GridOptions &gridOptions, const std::map<coordinates, float> &stateRewards = {}, const float probIntended = 1.0, const float faultyProbability = 0);
Grid(cells gridCells, cells background, const std::map<coordinates, float> &stateRewards = {}, const float probIntended = 1.0, const float faultyProbability = 0);
cells getGridCells();
bool isBlocked(coordinates p);
bool isWall(coordinates p);
void printToPrism(std::ostream &os, std::vector<Configuration>& configuration, const prism::ModelType& modelType);
void printToPrism(std::ostream &os, std::vector<Configuration>& configuration);
void applyOverwrites(std::string& str, std::vector<Configuration>& configuration);
std::array<bool, 8> getWalkableDirOf8Neighborhood(cell c);

Loading…
Cancel
Save