source: src/test/java/multipartyexample/Groupn.java@ 209

Last change on this file since 209 was 50, checked in by Tim Baarslag, 6 years ago

EvaluatorDiscrete clean-up
agent API calls to util space

File size: 1.4 KB
Line 
1package multipartyexample;
2
3import java.util.List;
4
5import genius.core.AgentID;
6import genius.core.Bid;
7import genius.core.actions.Accept;
8import genius.core.actions.Action;
9import genius.core.actions.Offer;
10import genius.core.parties.AbstractNegotiationParty;
11import genius.core.parties.NegotiationInfo;
12
13/**
14 * This is your negotiation party.
15 */
16public class Groupn extends AbstractNegotiationParty {
17
18 private Bid lastReceivedBid = null;
19
20 @Override
21 public void init(NegotiationInfo info) {
22
23 super.init(info);
24
25 System.out.println("Discount Factor is " + getUtilitySpace().getDiscountFactor());
26 System.out.println("Reservation Value is " + getUtilitySpace().getReservationValueUndiscounted());
27
28 // if you need to initialize some variables, please initialize them
29 // below
30
31 }
32
33 @Override
34 public Action chooseAction(List<Class<? extends Action>> validActions) {
35
36 // with 50% chance, counter offer
37 // if we are the first party, also offer.
38 if (lastReceivedBid == null || !validActions.contains(Accept.class) || Math.random() > 0.5) {
39 return new Offer(getPartyId(), generateRandomBid());
40 } else {
41 return new Accept(getPartyId(), lastReceivedBid);
42 }
43 }
44
45 @Override
46 public void receiveMessage(AgentID sender, Action action) {
47 super.receiveMessage(sender, action);
48 if (action instanceof Offer) {
49 lastReceivedBid = ((Offer) action).getBid();
50 }
51 }
52
53 @Override
54 public String getDescription() {
55 return "example party group N";
56 }
57
58}
Note: See TracBrowser for help on using the repository browser.