SLIDE 13 The Dining Philosophers: JaCaMo+
1 +! s t a r t : true 2 < − focusWhenAvailable ( " philoArtifact " ) ; enact ( " philosopher " ) . 3 +enacted ( Id , " philosopher " , R o l e I d ) 4 < − +enactment id ( R o l e I d ) ; . my name (Me) ; 5 i n ( " philo_init" , Me, Left , Right ) ; 6 +m y l e f t f o r k ( L e f t ) ; +m y r i g h t f o r k ( Right ) ; 7 ! ! l i v i n g . 8 +! l i v i n g : counter (C) 9 < − ! t h i n k i n g ; ! e a t i n g . 10 +! e a t i n g : m y l e f t f o r k ( L e f t ) & m y r i g h t f o r k ( Right ) & counter (C) 11 < − . my name (Me) ; ? enactment id ( R o l e I d ) ; 12 askForks ( Left , Right , C ) . 13 +cc ( My Role Id , " philosopher " , a v a i l a b l e ( Left , Right , C) , 14 r e t u r n F o r k s ( Left , Right , C) , "DETACHED" ) 15 : enactment id ( My Role Id ) & m y l e f t f o r k ( L e f t ) & 16 m y r i g h t f o r k ( Right ) & counter (C) 17 < − ! eat ( Left , Right , C ) ; 18 r e t u r n F o r k s ( Left , Right , C ) . 19 +cc ( My Role Id , " philosopher " , a v a i l a b l e ( Left , Right , C) , 20 r e t u r n F o r k s ( Left , Right , C) , "SATISFIED" ) 21 : enactment id ( My Role Id ) & m y l e f t f o r k ( L e f t ) 22 < − ? counter (C ) ; −+counter (C+1); ! l i v i n g . 23 +! eat ( Left , Right , C ) : m y l e f t f o r k ( L e f t ) & m y r i g h t f o r k ( Right ) 24 & a v a i l a b l e ( Left , Right , C) & counter (C) 25 < − . my name (Me) ; ? enactment id ( R o l e I d ) . 26 p r i n t l n (Me, " " , Role Id , " eating" ) . 27 +! t h i n k i n g : counter (C) 28 < − . my name (Me) ; ? enactment id ( R o l e I d ) ; 29 p r i n t l n (Me, " " , Role Id , " thinking , time " ,C ) .
This creates the commitments cc(My Role Id, "philosopher", available(Left, Right, C), returnForks(Left, Right, C), "CONDITIONAL") in the social state.
BBC (UniTO) NorMAS 2015 Dagstuhl, March 23-27, 2015 12 / 16