2-APL UPC project.
0
fork

Configure Feed

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

score update works

cyberslas 6662f6d1 54d8d202

+72 -9
+30 -3
code/2apl_platform/briscola_chiamata/notary.2apl
··· 9 9 { true } AddBriscola(S, R) { briscola(S, R) } 10 10 { true } RemoveCardPlayed(S, R, X) { not cardontable(S, R, X) } 11 11 12 + { not points(P, X) } AddPoints(P, X) { points(P, X) } 13 + { points(P, X) } RemovePoints(P, X) { not points(P, X) } 14 + 12 15 Beliefs: 13 16 gatekeeper(gk). /* we know who the gatekeeper is, for simplicity */ 14 17 dealer(d). ··· 32 35 getwinner(Winner) :- cardontable(_, five, Winner), !. 33 36 getwinner(Winner) :- cardontable(_, four, Winner), !. 34 37 getwinner(Winner) :- cardontable(_, two, Winner), !. 38 + 39 + major(X, Y) :- X >= Y. 40 + win(X, P1, [X, P1]). 41 + win(X, P1, [X, P1|T]) :- win(Y, P2, T), major(P1, P2). 42 + win(Y, P2, [X, P1|T]) :- win(Y, P2, T), major(P2, P1). 43 + whowins(X) :- points(P0, S0), points(P1, S1), points(P2, S2), points(P3, S3), points(P4, S4), not P0 = P1, not P1 = P2, not P2 = P3, not P3 = P4, not P0 = P2, not P0 = P3, not P0 = P4, not P1 = P3, not P1 = P4, not P2 = P4, win(X, Y, [P0, S0, P1, S1, P2, S2, P3, S3, P4, S4]). 35 44 36 45 Plans: 37 46 @cardtable(enterAsNotary()) /* join the game as notary */ ··· 40 49 message(X, inform, _, _, registered(POS, Y)) <- true | 41 50 { 42 51 SetAssigned(POS, Y); /* update belief about assigned sit */ 52 + AddPoints(Y, 0); 43 53 if B( POS = 4 ) then /* if we believe we already assigned all the sits, then choose the dealer */ 44 54 { 45 55 /*@cardtable(chooseDealer(), D);*/ ··· 190 200 191 201 //Send point to the winner 192 202 B( getwinner(W) ); 193 - send(W, inform, yourscore( X0 + X1 + X2 + X3 + X4)); 194 - @cardtable(updateScore(W, X0 + X1 + X2 + X3 + X4)); 203 + send(W, inform, yourpoints( X0 + X1 + X2 + X3 + X4)); 204 + @cardtable(updatePoints(W, X0 + X1 + X2 + X3 + X4)); 205 + B( points(W, POINTS) ); 206 + RemovePoints(W, POINTS); 207 + AddPoints(W, POINTS + X0 + X1 + X2 + X3 + X4); 195 208 196 209 //Clean table 197 210 B( assigned(0, P0)); ··· 212 225 213 226 //New round 214 227 selectturn() 215 - } 228 + } 229 + 230 + message(X, inform, _, _, doiwin(P)) <- true | 231 + { 232 + if B(whowins(X)) then 233 + { 234 + send(X, inform, youwin(P)) 235 + } 236 + else 237 + { 238 + send(X, inform, youlose(P)) 239 + } 240 + } 241 + 242 +
+42 -6
code/2apl_platform/briscola_chiamata/player.2apl
··· 8 8 { not lastbid(X) } AddLastBid(X) { lastbid(X) } 9 9 { lastbid(X) } RemoveLastBid(X) { not lastbid(X) } 10 10 11 + { not points(X) } AddPoints(X) { points(X) } 12 + { points(X) } RemovePoints(X) { not points(X) } 13 + 11 14 { true } AddTeamMember(X) { team(X) } 12 - 15 + 16 + { true } AddBriscola(X) { briscola(X) } 17 + 13 18 Beliefs: 14 19 notary(n). 15 20 gatekeeper(gk). ··· 28 33 deletehandcard(R, S, [R, S|T], T). 29 34 deletehandcard(R, S, [X, Y|T], [H|T1]):- deletehandcard(R, S, T, T1). 30 35 36 + points(0). 37 + 31 38 getpoints(jack, X) :- X is 2. 32 39 getpoints(queen, X) :- X is 3. 33 40 getpoints(king, X) :- X is 4. ··· 175 182 message(X, inform, _, _, bidwinner(Y)) <- hand(H) | 176 183 { 177 184 print("I've the Briscola!"); 185 + AddBriscola(0); 178 186 // --- Declare Briscola 179 187 //B( getcard(H, 3, Briscola) ); FIXME this line do not work 180 188 send(n, inform, declarebriscola([clubs, ace])); ··· 213 221 // Check if hand is ended 214 222 if B(RES = []) then 215 223 { 216 - endround() 224 + endhand() 217 225 } 218 226 } 219 227 220 - message(n, inform, _, _, yourscore(Y)) <- true | 228 + message(n, inform, _, _, yourpoints(Y)) <- true | 229 + { 230 + B( points(P) ); 231 + RemovePoints(P); 232 + AddPoints(P + Y) 233 + } 234 + 235 + endhand() <- hand([]) | 236 + { 237 + print("I finish my hand!"); 238 + RemoveHand([]); 239 + B( points(P) ); 240 + send(n, inform, doiwin(P)) 241 + } 242 + 243 + message(n, inform, _, _, youwin(Y)) <- briscola(_) | 244 + { 245 + B( assigned(Pos, Me) ); 246 + @cardtable(updateScore(Me, 2)) 247 + } 248 + 249 + message(n, inform, _, _, youwin(Y)) <- not briscola(_) | 221 250 { 222 - skip 251 + B( assigned(Pos, Me) ); 252 + @cardtable(updateScore(Me, 1)) 223 253 } 224 254 225 - endround() <- hand([]) | 255 + message(n, inform, _, _, youlose(Y)) <- briscola(_) | 226 256 { 227 - print("I finish my hand!") 257 + B( assigned(Pos, Me) ); 258 + @cardtable(updateScore(Me, -2)) 228 259 } 229 260 261 + message(n, inform, _, _, youlose(Y)) <- not briscola(_) | 262 + { 263 + B( assigned(Pos, Me) ); 264 + @cardtable(updateScore(Me, -1)) 265 + } 230 266