source: src/main/java/negotiator/parties/UINegotiationParty.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.2 KB
Line 
1package negotiator.parties;
2
3import java.util.List;
4
5import javax.swing.JOptionPane;
6
7import genius.core.AgentID;
8import genius.core.Bid;
9import genius.core.SupportedNegotiationSetting;
10import genius.core.actions.Accept;
11import genius.core.actions.Action;
12import genius.core.actions.EndNegotiation;
13import genius.core.actions.Offer;
14import genius.core.parties.AbstractNegotiationParty;
15import genius.core.parties.NegotiationInfo;
16import genius.core.utility.AdditiveUtilitySpace;
17
18/**
19 * @author W.Pasman, modified version of Dmytro's UIAgent
20 */
21public class UINegotiationParty extends AbstractNegotiationParty {
22
23 private Action opponentAction = null;
24
25 private Bid myPreviousBid = null;
26 private Bid mostRecentBid;
27
28 /**
29 * One agent will be kept alive over multiple sessions. Init will be called
30 * at the start of each nego session.
31 */
32 @Override
33 public void init(NegotiationInfo info) {
34 super.init(info);
35
36 }
37
38 @Override
39 public void receiveMessage(AgentID sender, Action arguments) {
40 this.opponentAction = arguments;
41 if (opponentAction instanceof Offer) {
42 mostRecentBid = ((Offer) opponentAction).getBid();
43 }
44
45 if (opponentAction instanceof Accept) {
46 JOptionPane.showMessageDialog(null, "Opponent accepted your last offer.");
47 }
48
49 if (opponentAction instanceof EndNegotiation) {
50 JOptionPane.showMessageDialog(null, "Opponent canceled the negotiation session");
51 }
52 }
53
54 @Override
55 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
56 Action action = null;
57 try {
58 EnterBidDialog2 dialog = new EnterBidDialog2(this, getPartyId(), null, true,
59 (AdditiveUtilitySpace) utilitySpace, possibleActions.contains(Accept.class) ? mostRecentBid : null);
60
61 action = dialog.askUserForAction(opponentAction, myPreviousBid, mostRecentBid);
62 if ((action != null) && (action instanceof Offer)) {
63 myPreviousBid = ((Offer) action).getBid();
64 }
65 } catch (Exception e) {
66 System.out.println("Problem in UIAgent2.chooseAction:" + e.getMessage());
67 e.printStackTrace();
68 }
69
70 return action;
71 }
72
73 public SupportedNegotiationSetting getSupportedNegotiationSetting() {
74 return SupportedNegotiationSetting.getLinearUtilitySpaceInstance();
75 }
76
77 @Override
78 public String getDescription() {
79 return "UI Party";
80 }
81}
Note: See TracBrowser for help on using the repository browser.