source: src/main/java/agents/anac/y2015/meanBot/MeanBot.java@ 127

Last change on this file since 127 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 2.1 KB
Line 
1package agents.anac.y2015.meanBot;
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.DefaultAction;
10import genius.core.actions.Offer;
11import genius.core.parties.AbstractNegotiationParty;
12import genius.core.parties.NegotiationInfo;
13
14/**
15 * This is your negotiation party.
16 */
17public 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}
Note: See TracBrowser for help on using the repository browser.