@ -2,6 +2,7 @@
# include <map>
# include <string>
# include <stdexcept>
std : : string northUpdate ( const AgentName & a ) { return " (row " + a + " '=row " + a + " -1) " ; }
@ -143,21 +144,21 @@ namespace prism {
}
void PrismModulesPrinter : : printLockedDoorActions ( const std : : string & agentName , const std : : string & identifier ) {
std : : string actionName = " [ " + agentName + " _unlock _ " + identifier + " ] " ;
std : : string actionName = " [ " + agentName + " _toggle _ " + identifier + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " ! " < < identifier < < " Open -> ( " < < identifier < < " Open'=true); \n " ;
actionName = " [ " + agentName + " _clos e_ " + identifier + " ] " ;
actionName = " [ " + agentName + " _toggl e_ " + identifier + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < actionName < < " " < < identifier < < " Open -> ( " < < identifier < < " Open'=false); \n " ;
}
void PrismModulesPrinter : : printUnlockedDoorActions ( const std : : string & agentName , const std : : string & identifier ) {
std : : string actionName = " [ " + agentName + " _open _ " + identifier + " ] " ;
std : : string actionName = " [ " + agentName + " _toggle _ " + identifier + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " ! " < < identifier < < " Open -> ( " < < identifier < < " Open'=true); \n " ;
actionName = " [ " + agentName + " _clos e_ " + identifier + " ] " ;
os < < " " < < actionName < < " ! " < < identifier < < " Open -> ( " < < identifier < < " Open'=true); \n " ;
actionName = " [ " + agentName + " _toggl e_ " + identifier + " ] " ;
agentNameActionMap . at ( agentName ) . insert ( { NOFAULT , actionName } ) ;
os < < " " < < agent Name < < " " < < identifier < < " Open -> ( " < < identifier < < " Open'=false); \n " ;
os < < " " < < action Name < < " " < < identifier < < " Open -> ( " < < identifier < < " Open'=false); \n " ;
}
void PrismModulesPrinter : : printRobotModule ( const AgentName & agentName , const coordinates & initialPosition ) {
@ -187,13 +188,13 @@ namespace prism {
printPortableObjectActionsForRobot ( agentName , identifier ) ;
}
printNonMovementActionsForRobot ( agentName ) ;
//printNonMovementActionsForRobot(agentName);
os < < " \n " < < actionStream . str ( ) ;
actionStream . str ( std : : string ( ) ) ;
if ( agentNameAndPositionMap . size ( ) > 1 & & agentName = = " Agent " ) printDoneActions ( agentName ) ;
if ( agentNameAndPositionMap . size ( ) > 1 & & agentName = = " Agent " & & anyGoals ) printDoneActions ( agentName ) ;
os < < " endmodule \n \n " ;
}
@ -209,14 +210,14 @@ namespace prism {
}
void PrismModulesPrinter : : printUnlockedDoorActionsForRobot ( const std : : string & agentName , const std : : string & identifier ) {
actionStream < < " [ " < < agentName < < " _open _ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _clos e_ " < < identifier < < " ] " < < agentName < < " IsNextTo " < < identifier < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _toggle _ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _toggl e_ " < < identifier < < " ] " < < agentName < < " IsNextTo " < < identifier < < " -> true; \n " ;
actionStream < < " \n " ;
}
void PrismModulesPrinter : : printLockedDoorActionsForRobot ( const std : : string & agentName , const std : : string & identifier , const std : : string & key ) {
actionStream < < " [ " < < agentName < < " _unlock _ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " & " < < agentName < < " Carrying " < < key < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _clos e_ " < < identifier < < " ] " < < agentName < < " IsNextTo " < < identifier < < " & " < < agentName < < " Carrying " < < key < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _toggle _ " < < identifier < < " ] " < < agentName < < " CannotMove " < < identifier < < " & " < < agentName < < " Carrying " < < key < < " -> true; \n " ;
actionStream < < " [ " < < agentName < < " _toggl e_ " < < identifier < < " ] " < < agentName < < " IsNextTo " < < identifier < < " & " < < agentName < < " Carrying " < < key < < " -> true; \n " ;
actionStream < < " \n " ;
}
@ -246,11 +247,11 @@ namespace prism {
std : : string actionName = " [ " + a + " _move_ " + direction + " ] " ;
agentNameActionMap . at ( a ) . insert ( { FORWARD , actionName } ) ;
std : : string guard = " " + actionName + " " + viewVariable ( a , viewDirection ) ;
if ( slipperyBehaviour ( ) ) guard + = " & ! " + a + " IsOnSlippery " ;
if ( anyLava ) guard + = " & ! " + a + " IsOnLava " ;
if ( anyGoals ) guard + = " & ! " + a + " IsOnGoal " ;
if ( slipperyBehaviour ( ) ) guard + = " & ! " + a + " IsOnSlippery " ;
if ( anyLava ) guard + = " & ! " + a + " IsOnLava " ;
if ( anyGoals & & a = = " Agent " ) guard + = " & ! " + a + " IsOnGoal " ;
guard + = " & ! " + a + " CannotMove " + direction + " Wall " ;
if ( anyPortableObject ( ) ) guard + = " & ! " + a + " CannotMoveConditionally " ;
if ( anyPortableObject ( ) | | ! lockedDoors . empty ( ) | | ! unlockedDoors . empty ( ) ) guard + = " & ! " + a + " CannotMoveConditionally " ;
guard + = " -> " ;
return guard ;
}
@ -298,6 +299,22 @@ namespace prism {
printSlipperyMovementActionsForWest ( a ) ;
printSlipperyTurnActionsForWest ( a ) ;
}
if ( ! slipperyTiles . at ( " NorthWest " ) . empty ( ) ) {
printSlipperyMovementActionsForNorthWest ( a ) ;
printSlipperyTurnActionsForNorthWest ( a ) ;
}
if ( ! slipperyTiles . at ( " NorthEast " ) . empty ( ) ) {
printSlipperyMovementActionsForNorthEast ( a ) ;
printSlipperyTurnActionsForNorthEast ( a ) ;
}
if ( ! slipperyTiles . at ( " SouthWest " ) . empty ( ) ) {
printSlipperyMovementActionsForSouthWest ( a ) ;
printSlipperyTurnActionsForSouthWest ( a ) ;
}
if ( ! slipperyTiles . at ( " SouthWest " ) . empty ( ) ) {
printSlipperyMovementActionsForSouthWest ( a ) ;
printSlipperyTurnActionsForSouthWest ( a ) ;
}
}
void PrismModulesPrinter : : printSlipperyMovementActionsForNorth ( const AgentName & a ) {
@ -397,44 +414,117 @@ namespace prism {
}
void PrismModulesPrinter : : printSlipperyTurnActionsForNorth ( const AgentName & a ) {
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { " ! " + a + " CannotSlipNorth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { a + " CannotSlipNorth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " North " , RIGHT , { " ! " + a + " CannotSlipNorth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " North " , RIGHT , { a + " CannotSlipNorth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipNorth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipNorth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipNorth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipNorth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " North " , LEFT , { " ! " + a + " CannotSlipNorth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " North " , LEFT , { " ! " + a + " CannotSlipNorth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " North " , LEFT , { a + " CannotSlipNorth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " North " , LEFT , { a + " CannotSlipNorth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyTurnActionsForEast ( const AgentName & a ) {
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { " ! " + a + " CannotSlipEast " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { a + " CannotSlipEast " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " East " , RIGHT , { " ! " + a + " CannotSlipEast " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " East " , RIGHT , { a + " CannotSlipEast " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipEast " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipEast " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipEast " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipEast " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " East " , LEFT , { " ! " + a + " CannotSlipEast " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " East " , LEFT , { " ! " + a + " CannotSlipEast " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " East " , LEFT , { a + " CannotSlipEast " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " East " , LEFT , { a + " CannotSlipEast " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyTurnActionsForSouth ( const AgentName & a ) {
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { " ! " + a + " CannotSlipSouth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { a + " CannotSlipSouth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " South " , RIGHT , { " ! " + a + " CannotSlipSouth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " South " , RIGHT , { a + " CannotSlipSouth " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipSouth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipSouth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipSouth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipSouth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " South " , LEFT , { " ! " + a + " CannotSlipSouth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " South " , LEFT , { " ! " + a + " CannotSlipSouth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " South " , LEFT , { a + " CannotSlipSouth " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " South " , LEFT , { a + " CannotSlipSouth " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyTurnActionsForWest ( const AgentName & a ) {
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { " ! " + a + " CannotSlipWest " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , RIGHT , { a + " CannotSlipWest " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " West " , RIGHT , { " ! " + a + " CannotSlipWest " } , " true " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=mod(view " + a + " +1,4)) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " right " , " West " , RIGHT , { a + " CannotSlipWest " } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " West " , LEFT , { " ! " + a + " CannotSlipWest " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " West " , LEFT , { " ! " + a + " CannotSlipWest " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " West " , LEFT , { a + " CannotSlipWest " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " West " , LEFT , { a + " CannotSlipWest " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyMovementActionsForNorthWest ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperyNorthWest tiles is not yet implemented. " ) ; }
void PrismModulesPrinter : : printSlipperyTurnActionsForNorthWest ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperyNorthWest tiles is not yet implemented. " ) ; }
void PrismModulesPrinter : : printSlipperyMovementActionsForNorthEast ( const AgentName & a ) {
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 0 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { probIntended , eastUpdate ( a ) } , { 1 - probIntended , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 0 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 0 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 0 , { a + " CannotSlipNorthEast " , a + " CannotSlipEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 3 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " " , { { probIntended , northUpdate ( a ) } , { 1 - probIntended , eastUpdate ( a ) + " & " + northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 3 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 3 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 3 , { a + " CannotSlipNorthEast " , a + " CannotSlipNorth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , " true " } } ) < < " ; \n " ;
float pd3 = ( 1 - probIntended ) / 3 ;
float pi3 = probIntended ;
float sum2 = probIntended + 2 * ( 1 - probIntended ) / 3 ;
float pd2 = ( 1 - probIntended ) / sum2 ;
float pi2 = probIntended / sum2 ;
float sum1 = probIntended + ( 1 - probIntended ) / 3 ;
float pd1 = ( 1 - probIntended ) / sum1 ;
float pi1 = probIntended / sum1 ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi3 , southUpdate ( a ) } , { pd3 , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { pd3 , eastUpdate ( a ) } , { pd3 , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 3.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { 1 / 3.f , eastUpdate ( a ) } , { 1 / 3.f , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { pd2 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { 1 / 2.f , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { pd2 , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } , { 1 / 2.f , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipEast " , a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { " ! " + a + " CannotSlipNorthEast " , a + " CannotSlipEast " , a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd2 , eastUpdate ( a ) } , { pd2 , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , eastUpdate ( a ) } , { 1 / 2.f , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , " ! " + a + " CannotSlipEast " , a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , southUpdate ( a ) } , { pd1 , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , a + " CannotSlipEast " , " ! " + a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , southUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , a + " CannotSlipEast " , a + " CannotSlipSouthEast " , " ! " + a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , southUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 1 , { a + " CannotSlipNorthEast " , a + " CannotSlipEast " , a + " CannotSlipSouthEast " , a + " CannotSlipSouth " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , " true " } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi3 , westUpdate ( a ) } , { pd3 , northUpdate ( a ) + " & " + westUpdate ( a ) } , { pd3 , northUpdate ( a ) } , { pd3 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi2 , westUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + westUpdate ( a ) } , { pd2 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi2 , westUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + westUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , westUpdate ( a ) } , { pd1 , northUpdate ( a ) + " & " + westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi2 , westUpdate ( a ) } , { pd2 , northUpdate ( a ) } , { pd2 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , westUpdate ( a ) } , { pd1 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { pi1 , westUpdate ( a ) } , { pd1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { " ! " + a + " CannotSlipWest " , a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 3.f , northUpdate ( a ) + " & " + westUpdate ( a ) } , { 1 / 3.f , northUpdate ( a ) } , { 1 / 3.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , northUpdate ( a ) + " & " + westUpdate ( a ) } , { 1 / 2.f , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , northUpdate ( a ) + " & " + westUpdate ( a ) } , { 1 / 2.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , " ! " + a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) + " & " + westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 / 2.f , northUpdate ( a ) } , { 1 / 2.f , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , a + " CannotSlipNorthWest " , " ! " + a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , " ! " + a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , northUpdate ( a ) + " & " + eastUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyMovementGuard ( a , " NorthEast " , 2 , { a + " CannotSlipWest " , a + " CannotSlipNorthWest " , a + " CannotSlipNorth " , a + " CannotSlipNorthEast " } ) < < printSlipperyMovementUpdate ( a , " " , { { 1 , " true " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyTurnActionsForNorthEast ( const AgentName & a ) {
actionStream < < printSlipperyTurnGuard ( a , " right " , " NorthEast " , RIGHT , { } , " true " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=mod(view " + a + " +1,4)) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " NorthEast " , LEFT , { } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , " NorthEast " , LEFT , { } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
void PrismModulesPrinter : : printSlipperyMovementActionsForSouthWest ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperySouthWest tiles is not yet implemented. " ) ; }
void PrismModulesPrinter : : printSlipperyTurnActionsForSouthWest ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperySouthWest tiles is not yet implemented. " ) ; }
void PrismModulesPrinter : : printSlipperyMovementActionsForSouthEast ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperySouthEast tiles is not yet implemented. " ) ; }
void PrismModulesPrinter : : printSlipperyTurnActionsForSouthEast ( const AgentName & a ) { throw std : : logic_error ( " The logic for SlipperySouthEast tiles is not yet implemented. " ) ; }
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipWest " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=view " + a + " -1) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { " ! " + a + " CannotSlipWest " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { probIntended , " (view " + a + " '=3) " } , { 1 - probIntended , westUpdate ( a ) } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipWest " } , " view " + a + " >0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=view " + a + " -1) " } } ) < < " ; \n " ;
actionStream < < printSlipperyTurnGuard ( a , " left " , LEFT , { a + " CannotSlipWest " } , " view " + a + " =0 " ) < < printSlipperyTurnUpdate ( a , { { 1 , " (view " + a + " '=3) " } } ) < < " ; \n " ;
}
std : : string PrismModulesPrinter : : printSlipperyMovementGuard ( const AgentName & a , const std : : string & direction , const ViewDirection & viewDirection , const std : : vector < std : : string > & guards ) {
std : : string actionName = " [ " + a + " _move_ " + viewDirectionToString . at ( viewDirection ) + " ] " ;
@ -446,10 +536,10 @@ namespace prism {
return updatesToString ( u ) ;
}
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 std : : string & tiltDirection , const ActionId & actionId , const std : : vector < std : : string > & guards , const std : : string & cond ) {
std : : string actionName = " [ " + a + " _turn_ " + direction + " ] " ;
agentNameActionMap . at ( a ) . insert ( { actionId , actionName } ) ;
return " " + actionName + " " + a + " IsOnSlippery & " + buildConjunction ( a , guards ) + " & " + cond + " -> " ;
return " " + actionName + " " + a + " IsOnSlippery " + tiltDirection + " & " + buildConjunction ( a , guards ) + " & " + cond + " -> " ;
}
std : : string PrismModulesPrinter : : printSlipperyTurnUpdate ( const AgentName & a , const updates & u ) {
@ -502,7 +592,7 @@ namespace prism {
else os < < " , " ;
os < < actionName ;
}
if ( agentName = = " Agent " ) os < < " , [Agent_on_goal] " ;
if ( agentName = = " Agent " & & anyGoals ) os < < " , [Agent_on_goal] " ;
os < < " \n endplayer \n " ;
}