From aa012140979acf360ce80eb2b11aa0bf2a3361e5 Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Tue, 2 Jan 2024 22:43:49 +0100 Subject: [PATCH] added turn propabilty --- util/Grid.cpp | 3 ++- util/PrismModulesPrinter.cpp | 38 ++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/util/Grid.cpp b/util/Grid.cpp index ed3032c..69d10bf 100644 --- a/util/Grid.cpp +++ b/util/Grid.cpp @@ -249,8 +249,9 @@ void Grid::printToPrism(std::ostream& os, std::vector& configurat } std::vector constants {"const double prop_zero = 0/9;", "const double prop_intended = 6/9;", + "const double prop_turn_intended = 6/9;", "const double prop_displacement = 3/9;", - "const double prop_displacement_half = prop_discplacement * 1/2;", + "const double prop_turn_displacement = 3/9;", }; printer.printConstants(os, constants); diff --git a/util/PrismModulesPrinter.cpp b/util/PrismModulesPrinter.cpp index fbc5350..1d66f3e 100644 --- a/util/PrismModulesPrinter.cpp +++ b/util/PrismModulesPrinter.cpp @@ -730,28 +730,28 @@ namespace prism { actionName = "\t[" + agentName + "turn_at_slip_north"; positionGuard = "\t" + agentName + "IsOnSlipperyNorth"; prob_piece_dir = { 0, 0, 0, 0, 1, 0, 0, 0, 0 /* <- R */ }; - prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_displacement" /* <- R */, "prop_zero", "prop_zero", "prop_zero","prop_zero" }; + prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_turn_displacement" /* <- R */, "prop_zero", "prop_zero", "prop_zero","prop_zero" }; break; case SlipperyType::South: actionName = "\t[" + agentName + "turn_at_slip_south"; positionGuard = "\t" + agentName + "IsOnSlipperySouth"; prob_piece_dir = { 1, 0, 0, 0, 0, 0, 0, 0, 0 /* <- R */ }; - prob_piece_dir_constants = { "prop_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" }; + prob_piece_dir_constants = { "prop_turn_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" }; break; case SlipperyType::East: actionName = "\t[" + agentName + "turn_at_slip_east"; positionGuard = "\t" + agentName + "IsOnSlipperyEast"; prob_piece_dir = { 0, 0, 0, 0, 0, 0, 1, 0, 0 /* <- R */ }; - prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_displacement", "prop_zero", "prop_zero" }; + prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_turn_displacement", "prop_zero", "prop_zero" }; break; case SlipperyType::West: actionName = "\t[" + agentName + "turn_at_slip_west"; positionGuard = "\t" + agentName + "IsOnSlipperyWest"; prob_piece_dir = { 0, 0, 1, 0, 0, 0, 0, 0, 0 /* <- R */ }; - prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" }; + prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_turn_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" }; break; } @@ -768,7 +768,7 @@ namespace prism { // determine residual probability (R) by replacing 0 with (1 - overall sum) prob_piece_dir.at(remainPosIndex) = PROB_PIECES - std::accumulate(prob_piece_dir.begin(), prob_piece_dir.end(), 0); - prob_piece_dir_constants.at(remainPosIndex) = "prop_intended"; + prob_piece_dir_constants.at(remainPosIndex) = "prop_turn_intended"; // { assert(prob_piece_dir.at(remainPosIndex) <= 9 && prob_piece_dir.at(remainPosIndex) >= 6 && "Value not in Range!"); @@ -780,7 +780,11 @@ namespace prism { for (std::size_t v = 0; v < viewTransition.size(); v++) { os << actionName << std::get<2>(viewTransition.at(v)) << moveGuard(agentIndex) << " x" << agentName << "=" << c.second << " & y" << agentName << "=" << c.first << std::get<0>(viewTransition.at(v)); for (std::size_t i = 0; i < ALL_POSS_DIRECTIONS; i++) { + if (i == remainPosIndex) { os << (i == 0 ? " -> " : " + ") << prob_piece_dir_constants.at(i) << " : " << positionTransition.at(i) << std::get<1>(viewTransition.at(v)) << moveUpdate(agentIndex) << (i == ALL_POSS_DIRECTIONS - 1 ? ";\n" : "\n"); + } else { + os << (i == 0 ? " -> " : " + ") << prob_piece_dir_constants.at(i) << " : " << positionTransition.at(i) << moveUpdate(agentIndex) << (i == ALL_POSS_DIRECTIONS - 1 ? ";\n" : "\n"); + } } } @@ -830,9 +834,9 @@ namespace prism { prob_piece_dir_agent_north = { 0 /*n <- R */, 0, 0, 0, 2 , 0, 0, 0 }; prob_piece_dir_agent_west = { 0, 0, 0, 0, 0, 2, 0 /* <- R */, 0 }; - prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_displacement_half", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement", "prop_displacement_half", "prop_zero" }; + prob_piece_dir_constants = { "prop_zero", "prop_zero", "prop_displacement * 1/2", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement", "prop_displacement * 1/2", "prop_zero" }; - prob_piece_dir_constants_agent_north = { "prop_zero", "prop_zero", "prop_zero", "prop_displacement_half", "prop_zero" /* <- R */, "prop_displacement_half", "prop_zero", "prop_zero" }; + prob_piece_dir_constants_agent_north = { "prop_zero", "prop_zero", "prop_zero", "prop_displacement * 1/2", "prop_zero" /* <- R */, "prop_displacement * 1/2", "prop_zero", "prop_zero" }; prob_piece_dir_constants_agent_east = { "prop_zero", "prop_zero", "prop_zero", "prop_displacement", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; prob_piece_dir_constants_agent_south = { "prop_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" } ; prob_piece_dir_constants_agent_west ={ "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_displacement", "prop_zero", "prop_zero" } ; @@ -858,9 +862,9 @@ namespace prism { prob_piece_dir_agent_south = { 2, 0, 0, 0, 0 /*s <- R */, 0, 0, 0 }; prob_piece_dir_agent_west = { 0, 0, 0, 0, 0, 0, 0 /* <- R */, 2 }; - prob_piece_dir_constants = { "prop_zero" /* <- R */, "prop_displacement", "prop_displacement_half", "prop_zero", "prop_zero", "prop_zero", "prop_displacement_half", "prop_displacement" }; + prob_piece_dir_constants = { "prop_zero" /* <- R */, "prop_displacement", "prop_displacement * 1/2", "prop_zero", "prop_zero", "prop_zero", "prop_displacement * 1/2", "prop_displacement" }; - prob_piece_dir_constants_agent_north = { "prop_zero", "prop_displacement_half", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_displacement_half" }; + prob_piece_dir_constants_agent_north = { "prop_zero", "prop_displacement * 1/2", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_displacement * 1/2" }; prob_piece_dir_constants_agent_east = { "prop_zero", "prop_displacement", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; prob_piece_dir_constants_agent_south = { "prop_displacement", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" } ; prob_piece_dir_constants_agent_west ={ "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_displacement" } ; @@ -886,12 +890,12 @@ namespace prism { prob_piece_dir_agent_south = { 2, 0, 0, 0, 0 /*s <- R */, 0, 0, 0 }; prob_piece_dir_agent_west = { 0, 0, 0, 0, 0, 0, 0 /* <- R */, 2 }; - prob_piece_dir_constants = { "prop_displacement_half", "prop_zero", "prop_zero", "prop_zero", "prop_displacement_half", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement" }; + prob_piece_dir_constants = { "prop_displacement * 1/2", "prop_zero", "prop_zero", "prop_zero", "prop_displacement * 1/2", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement" }; - prob_piece_dir_constants_agent_north = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_displacement_half", "prop_displacement_half" }; + prob_piece_dir_constants_agent_north = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_displacement * 1/2", "prop_displacement * 1/2" }; prob_piece_dir_constants_agent_east = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_displacement", "prop_zero" }; - prob_piece_dir_constants_agent_south = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_displacement_half", "prop_displacement_half", "prop_zero" } ; - prob_piece_dir_constants_agent_west ={ "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_displacement_half", "prop_zero", "prop_displacement_half" } ; + prob_piece_dir_constants_agent_south = { "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_displacement * 1/2", "prop_displacement * 1/2", "prop_zero" } ; + prob_piece_dir_constants_agent_west ={ "prop_zero", "prop_zero", "prop_zero", "prop_zero", "prop_zero" /* <- R */, "prop_displacement * 1/2", "prop_zero", "prop_displacement * 1/2" } ; straightPosIndex = 6; @@ -915,11 +919,11 @@ namespace prism { prob_piece_dir_agent_south = { 2, 0, 0, 0, 0 /*s <- R */, 0, 0, 0 }; prob_piece_dir_agent_west = { 0, 0, 0, 0, 0, 0, 0 /* <- R */, 2 }; - prob_piece_dir_constants = {"prop_displacement_half", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement", "prop_displacement_half", "prop_zero","prop_zero", "prop_zero" }; + prob_piece_dir_constants = {"prop_displacement * 1/2", "prop_displacement", "prop_zero" /* <- R */, "prop_displacement", "prop_displacement * 1/2", "prop_zero","prop_zero", "prop_zero" }; - prob_piece_dir_constants_agent_north = { "prop_zero", "prop_displacement_half", "prop_displacement_half", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; - prob_piece_dir_constants_agent_east = { "prop_zero", "prop_displacement_half", "prop_zero", "prop_displacement_half", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; - prob_piece_dir_constants_agent_south = { "prop_zero", "prop_zero", "prop_displacement_half", "prop_displacement_half", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" } ; + prob_piece_dir_constants_agent_north = { "prop_zero", "prop_displacement * 1/2", "prop_displacement * 1/2", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; + prob_piece_dir_constants_agent_east = { "prop_zero", "prop_displacement * 1/2", "prop_zero", "prop_displacement * 1/2", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" }; + prob_piece_dir_constants_agent_south = { "prop_zero", "prop_zero", "prop_displacement * 1/2", "prop_displacement * 1/2", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" } ; prob_piece_dir_constants_agent_west ={ "prop_zero", "prop_zero", "prop_displacement", "prop_zero", "prop_zero" /* <- R */, "prop_zero", "prop_zero", "prop_zero" } ;