2-APL UPC project.
0
fork

Configure Feed

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

declarebriscola works

cyberslas 32895d68 2b009dcb

+119 -4
+81 -3
code/2apl_platform/briscola_chiamata/notary.2apl
··· 4 4 { true } SetDealer(X) { dealer(X) } 5 5 { not currentturn(_) } UpdateTrun(X) { currentturn(X) } 6 6 { currentturn(X) } RemoveTrun(X) { not currentturn(X) } 7 + { true } PlayerPass(X) { playerpass(X) } 7 8 8 9 Beliefs: 9 10 gatekeeper(gk). /* we know who the gatekeeper is, for simplicity */ 10 11 dealer(d). 11 12 currentturn(1). /* the first turn is for the agent in postion 1 */ 13 + 12 14 13 15 14 16 Plans: ··· 28 30 29 31 message(X, inform, _, _, askfor(Pos)) <- true | 30 32 { 33 + 31 34 B(assigned(Pos, Y)); 32 - send(X, inform, is(Y)) 35 + if B( not playerpass(Y) ) then 36 + { 37 + send(X, inform, is(Y)) 38 + } 39 + else 40 + { 41 + /*TODO: in general, here we must implement if there is some "jump" and if all them passed, 42 + send the bidwinner message to the winner, but for the prototipe, this works. */ 43 + send(X, inform, bidwinner(0)) 44 + } 33 45 } 34 46 35 - turnended () <- currentturn(X) | /**/ 47 + message(X, inform, _, _, pass(Y)) <- true | 48 + { 49 + PlayerPass(X) 50 + } 51 + 52 + turnended() <- currentturn(X) | /**/ 36 53 { 37 54 if B( X = 4 ) then 38 55 { ··· 46 63 UpdateTrun(X + 1); 47 64 @cardtale(selectTrun(X + 1)) 48 65 } 49 - } 66 + } 67 + 68 + message(X, inform, _, _, declarebriscola(Briscola)) <- true | 69 + { 70 + B( assigned(Pos, X) ); 71 + if B( Pos = 0 ) then 72 + { 73 + B( assigned(1, P1)); 74 + send(P1, inform, declarebriscola(Briscola, X)); 75 + B( assigned(2, P2)); 76 + send(P2, inform, declarebriscola(Briscola, X)); 77 + B( assigned(3, P3)); 78 + send(P3, inform, declarebriscola(Briscola, X)); 79 + B( assigned(4, P4)); 80 + send(P4, inform, declarebriscola(Briscola, X)) 81 + }; 82 + if B( Pos = 1 ) then 83 + { 84 + B( assigned(0, P1)); 85 + send(P1, inform, declarebriscola(Briscola, X)); 86 + B( assigned(2, P2)); 87 + send(P2, inform, declarebriscola(Briscola, X)); 88 + B( assigned(3, P3)); 89 + send(P3, inform, declarebriscola(Briscola, X)); 90 + B( assigned(4, P4)); 91 + send(P4, inform, declarebriscola(Briscola, X)) 92 + }; 93 + if B( Pos = 2 ) then 94 + { 95 + B( assigned(0, P1)); 96 + send(P1, inform, declarebriscola(Briscola, X)); 97 + B( assigned(1, P2)); 98 + send(P2, inform, declarebriscola(Briscola, X)); 99 + B( assigned(3, P3)); 100 + send(P3, inform, declarebriscola(Briscola, X)); 101 + B( assigned(4, P4)); 102 + send(P4, inform, declarebriscola(Briscola, X)) 103 + }; 104 + if B( Pos = 3 ) then 105 + { 106 + B( assigned(0, P1)); 107 + send(P1, inform, declarebriscola(Briscola, X)); 108 + B( assigned(1, P2)); 109 + send(P2, inform, declarebriscola(Briscola, X)); 110 + B( assigned(2, P3)); 111 + send(P3, inform, declarebriscola(Briscola, X)); 112 + B( assigned(4, P4)); 113 + send(P4, inform, declarebriscola(Briscola, X)) 114 + }; 115 + if B( Pos = 4 ) then 116 + { 117 + B( assigned(0, P1)); 118 + send(P1, inform, declarebriscola(Briscola, X)); 119 + B( assigned(1, P2)); 120 + send(P2, inform, declarebriscola(Briscola, X)); 121 + B( assigned(2, P3)); 122 + send(P3, inform, declarebriscola(Briscola, X)); 123 + B( assigned(3, P4)); 124 + send(P4, inform, declarebriscola(Briscola, X)) 125 + } 126 + } 127 +
+38 -1
code/2apl_platform/briscola_chiamata/player.2apl
··· 7 7 { not lastbid(X) } AddLastBid(X) { lastbid(X) } 8 8 { lastbid(X) } RemoveLastBid(X) { not lastbid(X) } 9 9 10 + { true } AddTeamMember(X) { team(X) } 11 + 10 12 Beliefs: 11 13 notary(n). 12 14 gatekeeper(gk). 13 15 dealer(d). 14 16 player(X) :- assigned(POS, X). 17 + 18 + getcard([], 0, []). 19 + getcard([X], 0, []). 20 + getcard([ Card1, Card2 | Rest ], 0, [Card1, Card2]). 21 + getcard([ Card1, Card2 | Rest ], Index, X) :- Y is Index - 1, getcard(Rest, Y, X). 22 + 23 + iscard([], []). 24 + iscard([Card1, Card2 | REST ], [Card1, Card2]). 25 + iscard([ X, Y | REST ], Q) :- iscard(REST, Q). 15 26 16 27 Plans: 17 28 [ B(gatekeeper(X)) ; send(X, request, register(me)) ] ··· 130 141 if B( bidhistorical(_, Me) ) then 131 142 { 132 143 print("I pass..."); 133 - send(Next, inform, pass(LB)) 144 + send(Next, inform, pass(LB)); 145 + send(n, inform, pass(LB)) 134 146 } 135 147 else 136 148 { ··· 143 155 144 156 } 145 157 158 + 159 + /** 160 + * --- DECLARE BRISCOLA SCENARIO --- 161 + */ 162 + message(X, inform, _, _, bidwinner(Y)) <- hand(H) | 163 + { 164 + print("I've the Briscola!"); 165 + // --- Declare Briscola 166 + //B( getcard(H, 3, Briscola) ); FIXME this line do not work 167 + send(n, inform, declarebriscola([clubs, ace])); 168 + if B( iscard(H, [clubs, ace]) ) then 169 + { 170 + print("I go alone"); 171 + AddTeamMember(alone) // The player goes alone 172 + } 173 + } 146 174 175 + message(X, inform, _, _, declarebriscola(Briscola, Y)) <- hand(H) | 176 + { 177 + // Update knowledge about the team 178 + if B( iscard(H, Briscola) ) then 179 + { 180 + print("I go with "+ Y); 181 + AddTeamMember(Y) 182 + } 183 + } 147 184 148 185 /** 149 186 * --- PLAY SCENARIO ---