@ -3,11 +3,6 @@
# include <map>
# include <map>
# include <string>
# include <string>
# define NOFAULT -1
# define LEFT 0
# define RIGHT 1
# define FORWARD 2
std : : string northUpdate ( const AgentName & a ) { return " (row " + a + " '=row " + a + " -1) " ; }
std : : string northUpdate ( const AgentName & a ) { return " (row " + a + " '=row " + a + " -1) " ; }
std : : string southUpdate ( const AgentName & a ) { return " (row " + a + " '=row " + a + " +1) " ; }
std : : string southUpdate ( const AgentName & a ) { return " (row " + a + " '=row " + a + " +1) " ; }
@ -16,8 +11,8 @@ std::string westUpdate(const AgentName &a) { return "(col"+a+"'=col"+a+"-1)"; }
namespace prism {
namespace prism {
PrismModulesPrinter : : PrismModulesPrinter ( std : : ostream & os , const ModelType & modelType , const coordinates & maxBoundaries , const cells & boxes , const cells & balls , const cells & lockedDoors , const cells & unlockedDoors , const cells & keys , const std : : map < std : : string , cells > & slipperyTiles , const AgentNameAndPositionMap & agentNameAndPositionMap , std : : vector < Configuration > config , const float probIntended , const float faultyProbability , const bool anyLava , const bool anyGoals )
: os ( os ) , modelType ( modelType ) , maxBoundaries ( maxBoundaries ) , boxes ( boxes ) , balls ( balls ) , lockedDoors ( lockedDoors ) , unlockedDoors ( unlockedDoors ) , keys ( keys ) , slipperyTiles ( slipperyTiles ) , agentNameAndPositionMap ( agentNameAndPositionMap ) , configuration ( config ) , probIntended ( probIntended ) , faultyProbability ( faultyProbability ) , anyLava ( anyLava ) , anyGoals ( anyGoals ) {
PrismModulesPrinter : : PrismModulesPrinter ( std : : ostream & os , const ModelType & modelType , const coordinates & maxBoundaries , const cells & lockedDoors , const cells & unlockedDoors , const cells & keys , const std : : map < std : : string , cells > & slipperyTiles , const AgentNameAndPositionMap & agentNameAndPositionMap , std : : vector < Configuration > config , const float probIntended , const float faultyProbability , const bool anyLava , const bool anyGoals )
: os ( os ) , modelType ( modelType ) , maxBoundaries ( maxBoundaries ) , lockedDoors ( lockedDoors ) , unlockedDoors ( unlockedDoors ) , keys ( keys ) , slipperyTiles ( slipperyTiles ) , agentNameAndPositionMap ( agentNameAndPositionMap ) , configuration ( config ) , probIntended ( probIntended ) , faultyProbability ( faultyProbability ) , anyLava ( anyLava ) , anyGoals ( anyGoals ) {
numberOfPlayer = agentNameAndPositionMap . size ( ) ;
numberOfPlayer = agentNameAndPositionMap . size ( ) ;
size_t index = 0 ;
size_t index = 0 ;
for ( auto begin = agentNameAndPositionMap . begin ( ) ; begin ! = agentNameAndPositionMap . end ( ) ; begin + + , index + + ) {
for ( auto begin = agentNameAndPositionMap . begin ( ) ; begin ! = agentNameAndPositionMap . end ( ) ; begin + + , index + + ) {
@ -45,12 +40,6 @@ namespace prism {
for ( const auto & key : keys ) {
for ( const auto & key : keys ) {
printPortableObjectModule ( key ) ;
printPortableObjectModule ( key ) ;
}
}
for ( const auto & ball : balls ) {
printPortableObjectModule ( ball ) ;
}
for ( const auto & box : boxes ) {
printPortableObjectModule ( box ) ;
}
for ( const auto & door : unlockedDoors ) {
for ( const auto & door : unlockedDoors ) {
printDoorModule ( door , true ) ;
printDoorModule ( door , true ) ;
}
}
@ -104,8 +93,8 @@ namespace prism {
void PrismModulesPrinter : : printPortableObjectModule ( const cell & object ) {
void PrismModulesPrinter : : printPortableObjectModule ( const cell & object ) {
std : : string identifier = capitalize ( object . getColor ( ) ) + object . getType ( ) ;
std : : string identifier = capitalize ( object . getColor ( ) ) + object . getType ( ) ;
os < < " \n module " < < identifier < < std : : endl ;
os < < " \n module " < < identifier < < std : : endl ;
os < < " x " < < identifier < < " : [-1.. " < < maxBoundaries . second < < " ] init " < < object . column < < " ; \n " ;
os < < " y " < < identifier < < " : [-1.. " < < maxBoundaries . first < < " ] init " < < object . row < < " ; \n " ;
os < < " col " < < identifier < < " : [-1.. " < < maxBoundaries . first < < " ] ;\n " ;
os < < " row " < < identifier < < " : [-1.. " < < maxBoundaries . second < < " ] ;\n " ;
os < < " " < < identifier < < " PickedUp : bool; \n " ;
os < < " " < < identifier < < " PickedUp : bool; \n " ;
os < < " \n " ;
os < < " \n " ;
@ -115,28 +104,30 @@ namespace prism {
os < < " endmodule \n \n " ;
os < < " endmodule \n \n " ;
}
}
void PrismModulesPrinter : : printPortableObjectActions ( const std : : string & agentName , const std : : string & identifier ) {
void PrismModulesPrinter : : printPortableObjectActions ( const std : : string & agentName , const std : : string & identifier , const bool canBeDroped ) {
std : : string actionName = " [ " + agentName + " _pickup_ " + identifier + " ] " ;
std : : string actionName = " [ " + agentName + " _pickup_ " + identifier + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " true -> (x " < < identifier < < " '=-1) & (y " < < identifier < < " '=-1) & ( " < < identifier < < " PickedUp'=true); \n " ;
agentNameActionMap . at ( agentName ) . insert ( { PICKUP , actionName } ) ;
os < < " " < < actionName < < " true -> (col " < < identifier < < " '=-1) & (row " < < identifier < < " '=-1) & ( " < < identifier < < " PickedUp'=true); \n " ;
if ( canBeDroped ) {
actionName = " [ " + agentName + " _drop_ " + identifier + " _north] " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _north] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (x " < < identifier < < " '=x " < < agentName < < " ) & (y " < < identifier < < " '=y " < < agentName < < " -1) & ( " < < identifier < < " PickedUp'=false); \n " ;
agentNameActionMap . at ( agentName ) . insert ( { DROP , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (col " < < identifier < < " '=col " < < agentName < < " ) & (row " < < identifier < < " '=row " < < agentName < < " -1) & ( " < < identifier < < " PickedUp'=false); \n " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _west] " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _west] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (x " < < identifier < < " '=x " < < agentName < < " -1) & (y " < < identifier < < " '=y " < < agentName < < " ) & ( " < < identifier < < " PickedUp'=false); \n " ;
agentNameActionMap . at ( agentName ) . insert ( { DROP , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (col " < < identifier < < " '=col " < < agentName < < " -1) & (row " < < identifier < < " '=row " < < agentName < < " ) & ( " < < identifier < < " PickedUp'=false); \n " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _south] " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _south] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (x " < < identifier < < " '=x " < < agentName < < " ) & (y " < < identifier < < " '=y " < < agentName < < " +1) & ( " < < identifier < < " PickedUp'=false); \n " ;
agentNameActionMap . at ( agentName ) . insert ( { DROP , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (col " < < identifier < < " '=col " < < agentName < < " ) & (row " < < identifier < < " '=row " < < agentName < < " +1) & ( " < < identifier < < " PickedUp'=false); \n " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _east] " ;
actionName = " [ " + agentName + " _drop_ " + identifier + " _east] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " " < < " ttrue -> (x " < < identifier < < " '=x " < < agentName < < " +1) & (y " < < identifier < < " '=y " < < agentName < < " ) & ( " < < identifier < < " PickedUp'=false); \n " ;
agentNameActionMap . at ( agentName ) . insert ( { DROP , actionName } ) ;
os < < " " < < actionName < < " " < < " true -> (col " < < identifier < < " '=col " < < agentName < < " +1) & (row " < < identifier < < " '=row " < < agentName < < " ) & ( " < < identifier < < " PickedUp'=false); \n " ;
}
}
}
void PrismModulesPrinter : : printDoorModule ( const cell & door , const bool & opened ) {
void PrismModulesPrinter : : printDoorModule ( const cell & door , const bool & opened ) {
std : : string identifier = capitalize ( door . getColor ( ) ) + door . getType ( ) ;
std : : string identifier = capitalize ( door . getColor ( ) ) + door . getType ( ) ;
os < < " \n module " < < identifier < < std : : endl ;
os < < " \n module " < < identifier < < std : : endl ;
os < < " " < < identifier < < " Open : bool init false ; \n " ;
os < < " " < < identifier < < " Open : bool; \n " ;
os < < " \n " ;
os < < " \n " ;
if ( opened ) {
if ( opened ) {
@ -171,9 +162,9 @@ namespace prism {
void PrismModulesPrinter : : printRobotModule ( const AgentName & agentName , const coordinates & initialPosition ) {
void PrismModulesPrinter : : printRobotModule ( const AgentName & agentName , const coordinates & initialPosition ) {
os < < " \n module " < < agentName < < std : : endl ;
os < < " \n module " < < agentName < < std : : endl ;
os < < " col " < < agentName < < " : [1.. " < < maxBoundaries . second < < " ] init " < < initialPosition . second < < " ; \n " ;
os < < " row " < < agentName < < " : [1.. " < < maxBoundaries . first < < " ] init " < < initialPosition . first < < " ; \n " ;
os < < " view " < < agentName < < " : [0..3] init 1 ; \n " ;
os < < " col " < < agentName < < " : [1.. " < < maxBoundaries . first < < " ] ;\n " ;
os < < " row " < < agentName < < " : [1.. " < < maxBoundaries . second < < " ] ;\n " ;
os < < " view " < < agentName < < " : [0..3]; \n " ;
printTurnActionsForRobot ( agentName ) ;
printTurnActionsForRobot ( agentName ) ;
printMovementActionsForRobot ( agentName ) ;
printMovementActionsForRobot ( agentName ) ;
@ -192,35 +183,30 @@ namespace prism {
for ( const auto & key : keys ) {
for ( const auto & key : keys ) {
std : : string identifier = capitalize ( key . getColor ( ) ) + key . getType ( ) ;
std : : string identifier = capitalize ( key . getColor ( ) ) + key . getType ( ) ;
os < < " " < < agentName < < " Carrying " < < identifier < < " : bool init false ; \n " ;
os < < " " < < agentName < < " Carrying " < < identifier < < " : bool; \n " ;
printPortableObjectActionsForRobot ( agentName , identifier ) ;
printPortableObjectActionsForRobot ( agentName , identifier ) ;
}
}
for ( const auto & ball : balls ) {
std : : string identifier = capitalize ( ball . getColor ( ) ) + ball . getType ( ) ;
os < < " " < < agentName < < " Carrying " < < identifier < < " : bool init false; \n " ;
printPortableObjectActionsForRobot ( agentName , identifier ) ;
}
printNonMovementActionsForRobot ( agentName ) ;
for ( const auto & box : boxes ) {
std : : string identifier = capitalize ( box . getColor ( ) ) + box . getType ( ) ;
os < < " " < < agentName < < " Carrying " < < identifier < < " : bool init false; \n " ;
printPortableObjectActionsForRobot ( agentName , identifier ) ;
}
os < < " \n " < < actionStream . str ( ) ;
os < < " \n " < < actionStream . str ( ) ;
actionStream . str ( std : : string ( ) ) ;
actionStream . str ( std : : string ( ) ) ;
if ( agentNameAndPositionMap . size ( ) > 1 & & agentName = = " Agent " ) printDoneActions ( agentName ) ;
os < < " endmodule \n \n " ;
os < < " endmodule \n \n " ;
}
}
void PrismModulesPrinter : : printPortableObjectActionsForRobot ( const std : : string & a , const std : : string & i ) {
actionStream < < " [ " < < a < < " _pickup_ " < < i < < " ] " < < " ! " < < a < < " IsCarrying & " < < a < < " CannotMove " < < i < < " -> ( " < < a < < " Carrying " < < i < < " '=true); \n " ;
void PrismModulesPrinter : : printPortableObjectActionsForRobot ( const std : : string & a , const std : : string & i , const bool canBeDroped ) {
actionStream < < " [ " < < a < < " _pickup_ " < < i < < " ] " < < " ! " < < a < < " IsCarrying & " < < a < < " IsInFrontOf " < < i < < " -> ( " < < a < < " Carrying " < < i < < " '=true); \n " ;
if ( canBeDroped ) {
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _north] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =3 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveNorthWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _north] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =3 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveNorthWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _west] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =2 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveWestWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _west] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =2 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveWestWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _south] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =1 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveSouthWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _south] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =1 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveSouthWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _east] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =0 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveEastWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " [ " < < a < < " _drop_ " < < i < < " _east] \t " < < a < < " Carrying " < < i < < " & view " < < a < < " =0 & ! " < < a < < " CannotMoveConditionally & ! " < < a < < " CannotMoveEastWall -> ( " < < a < < " Carrying " < < i < < " '=false); \n " ;
actionStream < < " \n " ;
actionStream < < " \n " ;
}
}
}
void PrismModulesPrinter : : printUnlockedDoorActionsForRobot ( const std : : string & agentName , const std : : string & identifier ) {
void PrismModulesPrinter : : printUnlockedDoorActionsForRobot ( const std : : string & agentName , const std : : string & identifier ) {
actionStream < < " [ " < < agentName < < " _open_ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _open_ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " -> true; \n " ;
@ -276,13 +262,25 @@ namespace prism {
std : : string PrismModulesPrinter : : printTurnGuard ( const AgentName & a , const std : : string & direction , const ActionId & actionId , const std : : string & cond ) {
std : : string PrismModulesPrinter : : printTurnGuard ( const AgentName & a , const std : : string & direction , const ActionId & actionId , const std : : string & cond ) {
std : : string actionName = " [ " + a + " _turn_ " + direction + " ] " ;
std : : string actionName = " [ " + a + " _turn_ " + direction + " ] " ;
agentNameActionMap . at ( a ) . insert ( { actionId , actionName } ) ;
agentNameActionMap . at ( a ) . insert ( { actionId , actionName } ) ;
return " " + actionName + " " + cond + " -> " ;
std : : string guard = " " + actionName ;
if ( slipperyBehaviour ( ) ) guard + = " ! " + a + " IsOnSlippery & " ;
if ( anyLava ) guard + = " ! " + a + " IsOnLava & " ;
guard + = cond + " -> " ;
return guard ;
}
}
std : : string PrismModulesPrinter : : printTurnUpdate ( const AgentName & a , const update & u , const ActionId & actionId ) const {
std : : string PrismModulesPrinter : : printTurnUpdate ( const AgentName & a , const update & u , const ActionId & actionId ) const {
return updateToString ( u ) + " ; \ n " ;
return updateToString ( u ) + " ; \ n " ;
}
}
void PrismModulesPrinter : : printNonMovementActionsForRobot ( const AgentName & agentName ) {
for ( auto const [ actionId , action ] : nonMovementActions ) {
std : : string actionName = " [ " + agentName + " _ " + action + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { actionId , actionName } ) ;
actionStream < < " " < < actionName < < " true -> true; \n " ;
}
}
void PrismModulesPrinter : : printSlipperyMovementActionsForRobot ( const AgentName & a ) {
void PrismModulesPrinter : : printSlipperyMovementActionsForRobot ( const AgentName & a ) {
if ( ! slipperyTiles . at ( " North " ) . empty ( ) ) {
if ( ! slipperyTiles . at ( " North " ) . empty ( ) ) {
printSlipperyMovementActionsForNorth ( a ) ;
printSlipperyMovementActionsForNorth ( a ) ;
@ -322,10 +320,8 @@ namespace prism {
actionStream < < printSlipperyMovementGuard ( a , " North " , 0 , { " ! " + a + " CannotSlipEast " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " North " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 0 , { " ! " + a + " CannotSlipEast " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " North " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 0 , { a + " CannotSlipEast " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " North " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 0 , { a + " CannotSlipEast " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " North " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { " ! " + a + " CannotSlipSouth " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " North " , { { probIntended , southUpdate ( a ) } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { a + " CannotSlipSouth " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " North " , { { 1 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " North " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { a + " CannotSlipSouth " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " North " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " North " , { { probIntended , southUpdate ( a ) } , { 1 - probIntended , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " North " , 1 , { a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " North " , { { 1 , " true " } } ) < < " ; \n " ;
}
}
void PrismModulesPrinter : : printSlipperyMovementActionsForEast ( const AgentName & a ) {
void PrismModulesPrinter : : printSlipperyMovementActionsForEast ( const AgentName & a ) {
@ -348,10 +344,8 @@ namespace prism {
actionStream < < printSlipperyMovementGuard ( a , " East " , 1 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 1 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 1 , { a + " CannotSlipSouth " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 1 , { a + " CannotSlipSouth " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { " ! " + a + " CannotSlipWest " , " ! " + a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { probIntended , eastUpdate ( a ) } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { a + " CannotSlipWest " , " ! " + a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { " ! " + a + " CannotSlipWest " , a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { 1 , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { a + " CannotSlipWest " , a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { " ! " + a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { probIntended , eastUpdate ( a ) } , { 1 - probIntended , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " East " , 2 , { a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " East " , { { 1 , " true " } } ) < < " ; \n " ;
}
}
void PrismModulesPrinter : : printSlipperyMovementActionsForSouth ( const AgentName & a ) {
void PrismModulesPrinter : : printSlipperyMovementActionsForSouth ( const AgentName & a ) {
@ -374,10 +368,8 @@ namespace prism {
actionStream < < printSlipperyMovementGuard ( a , " South " , 0 , { " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " South " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 0 , { " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " South " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 0 , { a + " CannotSlipEast " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " South " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 0 , { a + " CannotSlipEast " , a + " CannotSlipSouthEast " } ) < < printSlipperyMovementUpdate ( a , " South " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { " ! " + a + " CannotSlipSouth " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " South " , { { probIntended , southUpdate ( a ) } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { a + " CannotSlipSouth " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " South " , { { 1 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " South " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { a + " CannotSlipSouth " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " South " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " South " , { { probIntended , northUpdate ( a ) } , { 1 - probIntended , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " South " , 3 , { a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " South " , { { 1 , " true " } } ) < < " ; \n " ;
}
}
void PrismModulesPrinter : : printSlipperyMovementActionsForWest ( const AgentName & a ) {
void PrismModulesPrinter : : printSlipperyMovementActionsForWest ( const AgentName & a ) {
@ -400,10 +392,8 @@ namespace prism {
actionStream < < printSlipperyMovementGuard ( a , " West " , 1 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipSouthWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 1 , { " ! " + a + " CannotSlipSouth " , a + " CannotSlipSouthWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 1 , { a + " CannotSlipSouth " , a + " CannotSlipSouthWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 1 , { a + " CannotSlipSouth " , a + " CannotSlipSouthWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { " ! " + a + " CannotSlipEast " , " ! " + a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { probIntended , westUpdate ( a ) } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { a + " CannotSlipEast " , " ! " + a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { 1 , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { " ! " + a + " CannotSlipEast " , a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { a + " CannotSlipEast " , a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { " ! " + a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { probIntended , westUpdate ( a ) } , { 1 - probIntended , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " West " , 0 , { a + " CannotSlipWest " } ) < < printSlipperyMovementUpdate ( a , " West " , { { 1 , " true " } } ) < < " ; \n " ;
}
}
void PrismModulesPrinter : : printSlipperyTurnActionsForNorth ( const AgentName & a ) {
void PrismModulesPrinter : : printSlipperyTurnActionsForNorth ( const AgentName & a ) {
@ -459,7 +449,7 @@ namespace prism {
std : : string PrismModulesPrinter : : printSlipperyTurnGuard ( const AgentName & a , const std : : string & direction , const ActionId & actionId , const std : : vector < std : : string > & guards , const std : : string & cond ) {
std : : string PrismModulesPrinter : : printSlipperyTurnGuard ( const AgentName & a , const std : : string & direction , const ActionId & actionId , const std : : vector < std : : string > & guards , const std : : string & cond ) {
std : : string actionName = " [ " + a + " _turn_ " + direction + " ] " ;
std : : string actionName = " [ " + a + " _turn_ " + direction + " ] " ;
agentNameActionMap . at ( a ) . insert ( { actionId , actionName } ) ;
agentNameActionMap . at ( a ) . insert ( { actionId , actionName } ) ;
return " " + actionName + " " + buildConjunction ( a , guards ) + " & " + cond + " -> " ;
return " " + actionName + " " + a + " IsOnSlippery & " + buildConjunction ( a , guards ) + " & " + cond + " -> " ;
}
}
std : : string PrismModulesPrinter : : printSlipperyTurnUpdate ( const AgentName & a , const updates & u ) {
std : : string PrismModulesPrinter : : printSlipperyTurnUpdate ( const AgentName & a , const updates & u ) {
@ -468,9 +458,11 @@ namespace prism {
void PrismModulesPrinter : : printFaultyMovementModule ( const AgentName & a ) {
void PrismModulesPrinter : : printFaultyMovementModule ( const AgentName & a ) {
os < < " \n module " < < a < < " FaultyBehaviour " < < std : : endl ;
os < < " \n module " < < a < < " FaultyBehaviour " < < std : : endl ;
os < < " previousAction " < < a < < " : [-1..2] init -1 ; \n " ;
os < < " previousAction " < < a < < " : [0.. " + std : : to_string ( NOFAULT ) + " ] ; \n " ;
std : : set < size_t > exclude = { PICKUP , DROP , TOGGLE , DONE } ;
for ( const auto [ actionId , actionName ] : agentNameActionMap . at ( a ) ) {
for ( const auto [ actionId , actionName ] : agentNameActionMap . at ( a ) ) {
if ( exclude . count ( actionId ) > 0 ) continue ;
os < < " " < < actionName < < faultyBehaviourGuard ( a , actionId ) < < " -> " < < faultyBehaviourUpdate ( a , actionId ) < < " ; \n " ;
os < < " " < < actionName < < faultyBehaviourGuard ( a , actionId ) < < " -> " < < faultyBehaviourUpdate ( a , actionId ) < < " ; \n " ;
}
}
os < < " endmodule \n \n " ;
os < < " endmodule \n \n " ;
@ -478,7 +470,7 @@ namespace prism {
void PrismModulesPrinter : : printMoveModule ( ) {
void PrismModulesPrinter : : printMoveModule ( ) {
os < < " \n module " < < " Arbiter " < < std : : endl ;
os < < " \n module " < < " Arbiter " < < std : : endl ;
os < < " clock : [0.. " < < agentIndexMap . size ( ) - 1 < < " ] init 0 ; \n " ;
os < < " clock : [0.. " < < agentIndexMap . size ( ) - 1 < < " ]; \n " ;
for ( const auto [ agentName , actions ] : agentNameActionMap ) {
for ( const auto [ agentName , actions ] : agentNameActionMap ) {
for ( const auto [ actionId , actionName ] : actions ) {
for ( const auto [ actionId , actionName ] : actions ) {
@ -499,7 +491,7 @@ namespace prism {
}
}
void PrismModulesPrinter : : printDoneActions ( const AgentName & agentName ) {
void PrismModulesPrinter : : printDoneActions ( const AgentName & agentName ) {
os < < " [ " < < agentName < < " _done ] " < < moveGuard ( agentName ) < < agentName < < " IsInGoal | " < < agentName < < " IsInLava -> ( " < < agentName < < " Done'=true) ; \n " ;
os < < " [ " < < agentName < < " _on_goal ] " < < agentName < < " IsOnGoal & clock=0 -> true ; \n " ;
}
}
void PrismModulesPrinter : : printPlayerStruct ( const AgentName & agentName ) {
void PrismModulesPrinter : : printPlayerStruct ( const AgentName & agentName ) {
@ -510,6 +502,7 @@ namespace prism {
else os < < " , " ;
else os < < " , " ;
os < < actionName ;
os < < actionName ;
}
}
if ( agentName = = " Agent " ) os < < " , [Agent_on_goal] " ;
os < < " \n endplayer \n " ;
os < < " \n endplayer \n " ;
}
}
@ -629,7 +622,7 @@ namespace prism {
}
}
bool PrismModulesPrinter : : anyPortableObject ( ) const {
bool PrismModulesPrinter : : anyPortableObject ( ) const {
return ! keys . empty ( ) | | ! boxes . empty ( ) | | ! balls . empty ( ) ;
return ! keys . empty ( ) ;
}
}
bool PrismModulesPrinter : : faultyBehaviour ( ) const {
bool PrismModulesPrinter : : faultyBehaviour ( ) const {