2-APL UPC project.
0
fork

Configure Feed

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

the briscola card is choosen randomly

cyberslas 96f0fc59 d3f1247b

+27 -7
+15 -2
code/2apl_platform/briscola_chiamata/dealer.2apl
··· 2 2 { not assigned(POS, X) } SetAssigned(POS, X) { assigned(POS, X) } 3 3 { true } AddDeck(X) { deck(X) } 4 4 { deck(X) } RemoveDeck(X) { not deck(X) } 5 + { true } AddDeckBackup(X) { deckbackup(X) } 5 6 Beliefs: 6 7 notary(n). 7 8 gatekeeper(gk). 8 9 player(X) :- assigned(POS, X). 9 10 gethand([C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16 | NewDeck], [C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16], NewDeck). 11 + 12 + getcard([], 0, []). 13 + getcard([X], 0, []). 14 + getcard([ S, R | REST ], 0, [S, R]). 15 + getcard([ S, R | REST ], I, X) :- Y is I - 1, getcard(REST, Y, X). 10 16 11 17 Goals: 12 18 deal(0) ··· 56 62 57 63 event(deckShuffled(X), cardtable) <- true | 58 64 { 59 - AddDeck(X) 65 + AddDeck(X); 66 + AddDeckBackup(X) 60 67 } 61 68 62 - 69 + message(X, inform, _, _, askforacard(Y)) <- true | 70 + { 71 + B(deckbackup(D)); 72 + B(is( RAND, int( random( 40 ) ) )); 73 + B(getcard(D, RAND, [S, R])); 74 + send(X, inform, acard([S, R])) 75 + } 63 76
+12 -5
code/2apl_platform/briscola_chiamata/player.2apl
··· 183 183 { 184 184 print("I've the Briscola!"); 185 185 AddBriscola(0); 186 + //TODO: The knowledge of a general deck must be included into NPC belief base to be able to 187 + //chose a random card of the deck 188 + send(d, inform, askforacard(0)) 189 + } 190 + message(d, inform, _, _, acard(X)) <- briscola(B) | 191 + { 192 + B(X = [S, R]); 186 193 // --- Declare Briscola 187 - //B( getcard(H, 3, Briscola) ); FIXME this line do not work 188 - send(n, inform, declarebriscola([clubs, ace])); 189 - @cardtable(briscolaDeclared(clubs,ace)); 190 - if B( iscard(H, [clubs, ace]) ) then 194 + send(n, inform, declarebriscola([S, R])); 195 + @cardtable(briscolaDeclared(S, R)); 196 + if B( iscard(H, [S, R]) ) then 191 197 { 192 198 print("I go alone!"); 193 199 AddTeamMember(alone) // The player goes alone 194 200 } 195 201 } 202 + 196 203 197 204 message(X, inform, _, _, declarebriscola(Briscola, Y)) <- hand(H) | 198 205 { ··· 255 262 256 263 message(n, inform, _, _, youlose(Y)) <- briscola(_) | 257 264 { 258 - B( assigned(Pos, Me) ); 265 + B( assigned(Pos, Me) ); 259 266 @cardtable(updateScore(Me, -2)) 260 267 } 261 268