source: src/main/java/negotiator/parties/RandomCounterOfferNegotiationParty.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: 2.5 KB
Line 
1package negotiator.parties;
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 * Basic voting implementation: this agent accepts and rejects offers with a 50%
15 * chance.
16 * <p/>
17 * The class was created as part of a series of agents used to understand the
18 * api better
19 *
20 * @author David Festen
21 */
22public class RandomCounterOfferNegotiationParty
23 extends AbstractNegotiationParty {
24 private Bid lastOffer;
25
26 /**
27 * Initializes a new instance of the
28 * {@link negotiator.parties.RandomCounterOfferNegotiationParty} class.
29 *
30 * @param utilitySpace
31 * The utility space used by this class
32 * @param deadlines
33 * The deadlines for this session
34 * @param timeline
35 * The time line (if time deadline) for this session, can be null
36 * @param randomSeed
37 * The seed that should be used for all randomization (to be
38 * reproducible)
39 */
40 @Override
41 public void init(NegotiationInfo info) {
42
43 super.init(info);
44 }
45
46 /**
47 * If placing offers: do random offer if voting: accept/reject with a 50%
48 * chance on both
49 *
50 * @param possibleActions
51 * List of all actions possible.
52 * @return The chosen action
53 */
54 @Override
55 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
56
57 // if we can not accept, we need to do random voting
58 if (!possibleActions.contains(Accept.class)) {
59 return new Offer(getPartyId(), generateRandomBid());
60 }
61
62 // else do 10/90: random offer, accept
63 return timeline.getTime() >= 0.9 ? new Accept(getPartyId(), lastOffer)
64 : new Offer(getPartyId(), generateRandomNonZeroBid());
65 }
66
67 private Bid generateRandomNonZeroBid() {
68 Bid randomBid;
69 double util;
70 do {
71 randomBid = generateRandomBid();
72 try {
73 util = utilitySpace.getUtility(randomBid);
74 } catch (Exception e) {
75 util = 0.0;
76 }
77 } while (util < 0.1);
78 return randomBid;
79 }
80
81 /**
82 * Processes action messages received by a given sender.
83 *
84 * @param sender
85 * The initiator of the action
86 * @param arguments
87 * The action performed
88 */
89 @Override
90 public void receiveMessage(AgentID sender, Action action) {
91 if (action instanceof Offer) {
92 lastOffer = ((Offer) action).getBid();
93 }
94 }
95
96 @Override
97 public String getDescription() {
98 return "Place random bids until 90% of time";
99 }
100
101}
Note: See TracBrowser for help on using the repository browser.