2-APL UPC project.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

first approach to playing scenario

cyberslas e6575b00 c5094109

+45 -24
+37 -19
code/2apl_platform/briscola_chiamata/notary.2apl
··· 9 9 Beliefs: 10 10 gatekeeper(gk). /* we know who the gatekeeper is, for simplicity */ 11 11 dealer(d). 12 - currentturn(1). /* the first turn is for the agent in postion 1 */ 12 + currentturn(0). /* the first turn is for the agent in postion 0 */ 13 13 14 14 15 15 ··· 28 28 } 29 29 } 30 30 31 + /** 32 + * --- BIDDING SCENARIO --- 33 + */ 31 34 message(X, inform, _, _, askfor(Pos)) <- true | 32 35 { 33 36 ··· 48 51 { 49 52 PlayerPass(X) 50 53 } 51 - 52 - turnended() <- currentturn(X) | /**/ 53 - { 54 - if B( X = 4 ) then 55 - { 56 - RemoveTrun(X); 57 - UpdateTrun(0); 58 - @cardtale(selectTrun(0)) 59 - } 60 - else 61 - { 62 - RemoveTrun(X); 63 - UpdateTrun(X + 1); 64 - @cardtale(selectTrun(X + 1)) 65 - } 66 - } 67 - 54 + 55 + /** 56 + * --- DECLARE BRISCOLA SCENARIO --- 57 + */ 68 58 message(X, inform, _, _, declarebriscola(Briscola)) <- true | 69 59 { 70 60 B( assigned(Pos, X) ); ··· 122 112 send(P3, inform, declarebriscola(Briscola, X)); 123 113 B( assigned(3, P4)); 124 114 send(P4, inform, declarebriscola(Briscola, X)) 115 + }; 116 + 117 + // START THE GAME!!! 118 + selectturn() 119 + } 120 + 121 + /** 122 + * --- PLAY SCENARIO --- 123 + */ 124 + selectturn() <- currentturn(X) | 125 + { 126 + if B( X = 4 ) then 127 + { 128 + RemoveTrun(X); 129 + UpdateTrun(0); 130 + B( assigned(0, P)); 131 + send(P, inform, yourturn(0)) 132 + } 133 + else 134 + { 135 + RemoveTrun(X); 136 + UpdateTrun(X + 1); 137 + B( assigned(X + 1, P)); 138 + send(P, inform, yourturn(X + 1)) 125 139 } 126 140 } 127 - 141 + 142 + event(cardPlayed(S, R), cardtable) <- true | 143 + { 144 + selectturn() 145 + }
+8 -5
code/2apl_platform/briscola_chiamata/player.2apl
··· 167 167 send(n, inform, declarebriscola([clubs, ace])); 168 168 if B( iscard(H, [clubs, ace]) ) then 169 169 { 170 - print("I go alone"); 170 + print("I go alone!"); 171 171 AddTeamMember(alone) // The player goes alone 172 172 } 173 173 } ··· 177 177 // Update knowledge about the team 178 178 if B( iscard(H, Briscola) ) then 179 179 { 180 - print("I go with "+ Y); 180 + print("I go with bid winner!"); 181 181 AddTeamMember(Y) 182 182 } 183 183 } ··· 185 185 /** 186 186 * --- PLAY SCENARIO --- 187 187 */ 188 - turnselected(X) <- assigned(X, _) and scenario(playing) | /* when percepts turnselected, and its his turn*/ 188 + message(n, inform, _, _, yourturn(Y)) <- true | 189 189 { 190 - /*TODO*/ 191 - skip 190 + print("My turn!"); 191 + B( getcard(H, 3, [S, R]) ); 192 + @cardtable(playCard(S, R)) 192 193 } 194 + 195 + 193 196