source: src/main/java/agents/anac/y2018/lancelot/Lancelot.java

Last change on this file was 345, checked in by Tim Baarslag, 4 years ago

Fixed agent 2018 descriptions

File size: 4.3 KB
Line 
1package agents.anac.y2018.lancelot;
2
3import java.util.List;
4
5import agents.anac.y2018.lancelot.etc.bidSearch;
6import agents.anac.y2018.lancelot.etc.strategy;
7import genius.core.AgentID;
8import genius.core.Bid;
9import genius.core.actions.Accept;
10import genius.core.actions.Action;
11import genius.core.actions.Offer;
12import genius.core.parties.AbstractNegotiationParty;
13import genius.core.parties.NegotiationInfo;
14import genius.core.timeline.TimeLineInfo;
15
16/**
17 * This is your negotiation party.
18 */
19public class Lancelot extends AbstractNegotiationParty {
20
21 private Bid lastReceivedBid = null;
22 private double opponent_eval = 0.0;
23 private TimeLineInfo timeLineInfo;
24 private strategy mStrategy;
25 private bidSearch mBidSearch;
26
27 private boolean DEBUG = false;
28
29
30 @Override
31 public void init(NegotiationInfo info) {
32
33 super.init(info);
34
35 if (DEBUG){
36 System.out.println("*** MyAgent ***");
37 }
38 System.out.println("Discount Factor is " + info.getUtilitySpace().getDiscountFactor());
39 System.out.println("Reservation Value is " + info.getUtilitySpace().getReservationValueUndiscounted());
40
41 // if you need to initialize some variables, please initialize them
42 // below
43 mStrategy = new strategy(utilitySpace,timeline,info);
44 mBidSearch = new bidSearch(utilitySpace,timeline);
45 }
46
47
48 /**
49 * Each round this method gets called and ask you to accept or offer. The
50 * first party in the first round is a bit different, it can only propose an
51 * offer.
52 *
53 * @param validActions
54 * Either a list containing both accept and offer or only offer.
55 * @return The chosen action.
56 */
57 public Action chooseAction(List<Class<? extends Action>> validActions) {
58 if (lastReceivedBid == null || !validActions.contains(Accept.class) ||!(mStrategy.decideAcceptOrOffer(lastReceivedBid,opponent_eval,utilitySpace.getUtilityWithDiscount(lastReceivedBid,timeline.getTime())))) {
59 Bid offer_bid = null;
60// if(timeline.getTime() < 0.6) {
61// offer_bid = mBidSearch.offerOppositeBid();
62// } else if(timeline.getTime() < 0.8){
63// offer_bid = mBidSearch.getRandomBid(timeline.getTime() + 0.1);
64// } else{
65// double min_util = mStrategy.getUtilThreshold2(timeline.getTime(),opponent_eval,utilitySpace.getUtilityWithDiscount(lastReceivedBid,timeline.getTime()));
66// offer_bid = mBidSearch.offerPositiveBid(min_util);
67// }
68 if(timeline.getTime() < 0.2){
69 offer_bid = mBidSearch.getRandomBid(1-timeline.getTime() - 0.1);
70 } else if(timeline.getTime() < 0.98){
71 double min_util = mStrategy.getUtilThreshold2(timeline.getTime(), opponent_eval, utilitySpace.getUtilityWithDiscount(lastReceivedBid, timeline.getTime()));
72 offer_bid = mBidSearch.offerPositiveBid(min_util);
73 } else{
74// double min_util = mStrategy.getUtilThreshold3(timeline.getTime(), opponent_eval, utilitySpace.getUtilityWithDiscount(lastReceivedBid, timeline.getTime()));
75 double min_util = mStrategy.getUtilThresholdForOffer();
76 offer_bid = mBidSearch.offerPositiveBid(min_util);
77 }
78 return new Offer(getPartyId(), offer_bid);
79 }
80 else {
81 System.out.println("Accept");
82 return new Accept(getPartyId(), lastReceivedBid);
83 }
84 }
85
86 /**
87 * All offers proposed by the other parties will be received as a message.
88 * You can use this information to your advantage, for example to predict
89 * their utility.
90 *
91 * @param sender
92 * The party that did the action. Can be null.
93 * @param action
94 * The action that party did.
95 */
96 @Override
97 public void receiveMessage(AgentID sender, Action action) {
98 super.receiveMessage(sender, action);
99 if (action instanceof Offer) {
100 lastReceivedBid = ((Offer) action).getBid();
101 mBidSearch.updateBidTable(lastReceivedBid);
102 opponent_eval = mStrategy.evaluateOpponent(lastReceivedBid);
103// System.out.println("receivedBid = " + lastReceivedBid + "by " + sender.getName());
104 }
105 }
106
107 @Override
108 public String getDescription() {
109 return "ANAC2018";
110 }
111
112}
Note: See TracBrowser for help on using the repository browser.