source: src/main/java/parties/in4010/q12015/group9/Group9.java@ 126

Last change on this file since 126 was 126, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

Added input for strategyParameters to SessionPanel (gui)

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

Our own package:

  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 3.6 KB
Line 
1package parties.in4010.q12015.group9;
2
3import java.util.List;
4
5import java.util.HashMap;
6
7import genius.core.AgentID;
8import genius.core.Bid;
9import genius.core.BidHistory;
10import genius.core.actions.Accept;
11import genius.core.actions.Action;
12import genius.core.actions.DefaultAction;
13import genius.core.actions.Offer;
14import genius.core.bidding.BidDetails;
15import genius.core.parties.AbstractNegotiationParty;
16import genius.core.parties.NegotiationInfo;
17import genius.core.utility.AdditiveUtilitySpace;
18
19/**
20 * This is your negotiation party.
21 */
22public class Group9 extends AbstractNegotiationParty {
23 private Bid prevReceivedBid;
24 private Bid currentConsideredBid;
25 private int acceptCount;
26 private OpponentModeling opponentModels;
27 private AcceptStrat acceptStrat;
28 private BiddingStrat biddingStrat;
29 private HashMap<Object, BidHistory> previousBidsMap;
30
31 /**
32 * Each round this method gets called and ask you to accept or offer. The
33 * first party in the first round is a bit different, it can only propose an
34 * offer.
35 *
36 * @param validActions
37 * Either a list containing both accept and offer or only offer.
38 * @return The chosen action.
39 */
40 @Override
41 public Action chooseAction(List<Class<? extends Action>> validActions) {
42 Bid ourBid = biddingStrat.createBid(previousBidsMap, opponentModels.getOpponentUtilities(), this.getTimeLine());
43
44 if (!validActions.contains(Accept.class)) {
45 currentConsideredBid = ourBid;
46 return new Offer(getPartyId(), ourBid);
47 } else {
48 if (acceptStrat.determineAcceptance(prevReceivedBid, previousBidsMap, ourBid,
49 opponentModels.getOpponentUtilities(), this.getTimeLine())) {
50 return new Accept(getPartyId(), prevReceivedBid);
51 } else {
52 currentConsideredBid = ourBid;
53 return new Offer(getPartyId(), ourBid);
54 }
55 }
56 }
57
58 /**
59 * All offers proposed by the other parties will be received as a message.
60 * You can use this information to your advantage, for example to predict
61 * their utility.
62 *
63 * @param sender
64 * The party that did the action.
65 * @param action
66 * The action that party did.
67 */
68 @Override
69 public void receiveMessage(AgentID sender, Action action) {
70 if (action instanceof Accept) { // .getClass().isInstance(new
71 // Accept(getPartyId()))) {
72 acceptCount = acceptCount + 1;
73 updateBidhistory(sender, currentConsideredBid);
74 opponentModels.updateModel(sender, action, previousBidsMap);
75 } else if (DefaultAction.getBidFromAction(action) != null) {
76 acceptCount = 0;
77 prevReceivedBid = DefaultAction.getBidFromAction(action);
78 updateBidhistory(sender, prevReceivedBid);
79 opponentModels.updateModel(sender, action, previousBidsMap);
80 }
81 super.receiveMessage(sender, action);
82 // Here you hear other parties' messages
83 }
84
85 // Simple helper for putting a newly received bid into the history
86 private void updateBidhistory(AgentID sender, Bid sendBid) {
87
88 if (!previousBidsMap.containsKey(sender)) {
89 previousBidsMap.put(sender, new BidHistory());
90 }
91 BidDetails tempBidDetails = new BidDetails(sendBid, this.getUtility(sendBid),
92 this.getTimeLine().getCurrentTime());
93 previousBidsMap.get(sender).add(tempBidDetails);
94 }
95
96 @Override
97 public String getDescription() {
98 return "example party group 9";
99 }
100
101 // Mostly initiate the super, besides that create the BOA components
102 @Override
103 public void init(NegotiationInfo info) {
104 super.init(info);
105 acceptCount = 0;
106 opponentModels = new OpponentModeling((AdditiveUtilitySpace) getUtilitySpace());
107 acceptStrat = new AcceptStrat((AdditiveUtilitySpace) getUtilitySpace());
108 biddingStrat = new BiddingStrat((AdditiveUtilitySpace) getUtilitySpace());
109 previousBidsMap = new HashMap<Object, BidHistory>();
110 }
111
112}
Note: See TracBrowser for help on using the repository browser.