2-APL UPC project.
0
fork

Configure Feed

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

bidding phase works

cyberslas a60960c4 42ea2718

+128 -21
+11
code/2apl_platform/briscola_chiamata/dealer.2apl
··· 28 28 { 29 29 adopta(deal(To + 1)) 30 30 } 31 + else 32 + { 33 + adopta(sendfirstbid(0)) 34 + } 35 + } 36 + 37 + sendfirstbid(0) <- true | 38 + { 39 + B( assigned(0, Next) ); 40 + send(Next, inform, firstbid(0)); 41 + dropgoal(sendfirstbid(0)) 31 42 } 32 43 33 44 PC-rules:
+6
code/2apl_platform/briscola_chiamata/notary.2apl
··· 25 25 send(d, inform, dealer(d)) 26 26 } 27 27 } 28 + 29 + message(X, inform, _, _, askfor(Pos)) <- true | 30 + { 31 + B(assigned(Pos, Y)); 32 + send(X, inform, is(Y)) 33 + } 28 34 29 35 turnended () <- currentturn(X) | /**/ 30 36 {
+111 -21
code/2apl_platform/briscola_chiamata/player.2apl
··· 4 4 { true } AddBidHistorical(Cantity, Who) { bidhistorical(Cantity, Who) } 5 5 { true } SetAsDealer(X) { dealer(X) } 6 6 { true } SetHand(X) { hand(X) } 7 + { not lastbid(X) } AddLastBid(X) { lastbid(X) } 8 + { lastbid(X) } RemoveLastBid(X) { not lastbid(X) } 9 + 7 10 Beliefs: 8 11 notary(n). 9 12 gatekeeper(gk). ··· 14 17 [ B(gatekeeper(X)) ; send(X, request, register(me)) ] 15 18 16 19 PC-rules: 20 + 21 + /** 22 + * --- JOIN THE GAME SCENARIO --- 23 + */ 17 24 message(X, inform, _, _, registered(POS, Y)) <- true | 18 25 { 19 26 SetAssigned(POS, Y) ··· 22 29 { 23 30 print("I'm out!") 24 31 } 25 - 26 - message(X, inform, _, _, firstbid(_)) <- scenario(bidding) | /* message from dealer, telling that this agent is the firts to bid */ 27 - { 28 - /* for fist, the agent bids */ 29 - /* TODO the agent must know who is the next bidding, or ask to dealer*/ 30 - send (Next, inform, bid(_)) 31 32 32 - } 33 - 34 - message(X, inform, _, _, firstbid(_)) <- scenario(bidding) | /* message from dealer, telling that this agent is the firts to bid */ 33 + /** 34 + * --- DEAL SCENARIO --- 35 + */ 36 + message(X, inform, _, _, givecards(Hand)) <- true | 35 37 { 36 - /* for fist, the agent bids */ 37 - /* TODO the agent must know who is the next bidding, or ask to dealer*/ 38 - send (Next, inform, bid(1)) 38 + print ("I've cards!"); 39 + SetHand(Hand) 39 40 } 40 - 41 - message(X, inform, _, _, bid(Cuantity, Pos)) <- scenario(bidding) | /* message from dealer, telling that this agent is the firts to bid */ 41 + 42 + /** 43 + * --- BIDDING SCENARIO --- 44 + */ 45 + message(X, inform, _, _, firstbid(Y)) <- true | /* message from dealer, telling that this agent is the firts to bid */ 42 46 { 43 - if B( bidhistorical(_, me) ) then 47 + print("I'm the first bidding!"); 48 + if B( assigned(Pos, _) and Pos < 4) then 44 49 { 45 - send (Next, inform, pass(_)) 50 + send(n, inform, askfor(Pos + 1)) 46 51 } 47 52 else 48 53 { 49 - send (Next, inform, bid(1)) 54 + send(n, inform, askfor(0)) 50 55 } 51 56 52 57 } 53 - 54 - message(X, inform, _, _, givecards(Hand)) <- true | 58 + 59 + message(X, inform, _, _, bid(Cuantity, PosSender)) <- not bidhistorical(_, _) | 55 60 { 56 - print ("I've cards!"); 57 - SetHand(Hand) 61 + AddBidHistorical(Cuantity, X); 62 + AddLastBid(Cuantity); 63 + if B( assigned(Pos, _) and Pos < 4) then 64 + { 65 + send(n, inform, askfor(Pos + 1)) 66 + } 67 + else 68 + { 69 + send(n, inform, askfor(0)) 70 + } 58 71 } 72 + message(X, inform, _, _, pass(Cuantity)) <- not bidhistorical(_, _) | 73 + { 74 + AddBidHistorical(Cuantity, X); 75 + AddLastBid(Cuantity); 76 + if B( assigned(Pos, _) and Pos < 4) then 77 + { 78 + send(n, inform, askfor(Pos + 1)) 79 + } 80 + else 81 + { 82 + send(n, inform, askfor(0)) 83 + } 84 + } 85 + 86 + message(X, inform, _, _, bid(Cuantity, PosSender)) <- bidhistorical(_, _) | 87 + { 88 + AddBidHistorical(Cuantity, X); 89 + B( lastbid(LB) ); 90 + RemoveLastBid(LB); 91 + AddLastBid(Cuantity); 92 + if B( assigned(Pos, _) and Pos < 4) then 93 + { 94 + send(n, inform, askfor(Pos + 1)) 95 + } 96 + else 97 + { 98 + send(n, inform, askfor(0)) 99 + } 100 + } 101 + message(X, inform, _, _, pass(Cuantity)) <- bidhistorical(_, _) | 102 + { 103 + AddBidHistorical(Cuantity, X); 104 + B( lastbid(LB) ); 105 + RemoveLastBid(LB); 106 + AddLastBid(Cuantity); 107 + if B( assigned(Pos, _) and Pos < 4) then 108 + { 109 + send(n, inform, askfor(Pos + 1)) 110 + } 111 + else 112 + { 113 + send(n, inform, askfor(0)) 114 + } 115 + } 116 + 117 + message(X, inform, _, _, is(Next)) <- not bidhistorical(_, _) | 118 + { 119 + B( assigned(Pos, Me) ); 120 + print("I bid!"); 121 + AddBidHistorical(61, Me); 122 + send(Next, inform, bid(61, Pos)) 123 + } 124 + 125 + message(X, inform, _, _, is(Next)) <- bidhistorical(_, _) | 126 + { 127 + B( assigned(Pos, Me) ); 128 + B( lastbid(LB) ); 129 + if B( bidhistorical(_, Me) ) then 130 + { 131 + print("I pass..."); 132 + send(Next, inform, pass(LB)) 133 + } 134 + else 135 + { 136 + print("I bid!"); 137 + AddBidHistorical(LB + 1, Me); 138 + send(Next, inform, bid(LB + 1, Pos)); 139 + RemoveLastBid(LB); 140 + AddLastBid(LB + 1) 141 + } 142 + 143 + } 144 + 59 145 146 + 147 + /** 148 + * --- PLAY SCENARIO --- 149 + */ 60 150 turnselected(X) <- assigned(X, _) and scenario(playing) | /* when percepts turnselected, and its his turn*/ 61 151 { 62 152 /*TODO*/