1 | package agents.anac.y2015.meanBot;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 |
|
---|
5 | import genius.core.AgentID;
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.actions.Accept;
|
---|
8 | import genius.core.actions.Action;
|
---|
9 | import genius.core.actions.DefaultAction;
|
---|
10 | import genius.core.actions.Offer;
|
---|
11 | import genius.core.parties.AbstractNegotiationParty;
|
---|
12 | import genius.core.parties.NegotiationInfo;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * This is your negotiation party.
|
---|
16 | */
|
---|
17 | public class MeanBot extends AbstractNegotiationParty {
|
---|
18 |
|
---|
19 | private Bid currentBid;
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | public void init(NegotiationInfo info) {
|
---|
23 | super.init(info);
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Each round this method gets called and ask you to accept or offer. The
|
---|
28 | * first party in the first round is a bit different, it can only propose an
|
---|
29 | * offer.
|
---|
30 | *
|
---|
31 | * @param validActions
|
---|
32 | * Either a list containing both accept and offer or only offer.
|
---|
33 | * @return The chosen action.
|
---|
34 | */
|
---|
35 | @Override
|
---|
36 | public Action chooseAction(List<Class<? extends Action>> validActions) {
|
---|
37 | try {
|
---|
38 | if (validActions.contains(Accept.class) && timeline.getTime() >= .95
|
---|
39 | && utilitySpace.getUtility(currentBid) > .5) {
|
---|
40 | return new Accept(getPartyId(), currentBid);
|
---|
41 | } else
|
---|
42 | return new Offer(getPartyId(), utilitySpace.getMaxUtilityBid());
|
---|
43 |
|
---|
44 | } catch (Exception e) {
|
---|
45 | return new Accept(getPartyId(), currentBid); // Not sure what to put
|
---|
46 | // here...
|
---|
47 | // Don't know what
|
---|
48 | // error I would be hitting.
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * All offers proposed by the other parties will be received as a message.
|
---|
54 | * You can use this information to your advantage, for example to predict
|
---|
55 | * their utility.
|
---|
56 | *
|
---|
57 | * @param sender
|
---|
58 | * The party that did the action.
|
---|
59 | * @param action
|
---|
60 | * The action that party did.
|
---|
61 | */
|
---|
62 | @Override
|
---|
63 | public void receiveMessage(AgentID sender, Action action) {
|
---|
64 | super.receiveMessage(sender, action);
|
---|
65 |
|
---|
66 | if (action instanceof Offer) {
|
---|
67 | // Know what the most recent bid on the table is, for evaluation.
|
---|
68 | currentBid = DefaultAction.getBidFromAction(action);
|
---|
69 | }
|
---|
70 | // Here you can listen to other parties' messages
|
---|
71 | }
|
---|
72 |
|
---|
73 | @Override
|
---|
74 | public String getDescription() {
|
---|
75 | return "ANAC2015";
|
---|
76 | }
|
---|
77 |
|
---|
78 | }
|
---|