1 | package agents.anac.y2018.fullagent;
|
---|
2 |
|
---|
3 | import negotiator.Bid;
|
---|
4 | import negotiator.actions.Accept;
|
---|
5 | import negotiator.actions.Action;
|
---|
6 | import negotiator.actions.Offer;
|
---|
7 | import negotiator.boaframework.*;
|
---|
8 |
|
---|
9 | public class FullAgent extends BOAagent {
|
---|
10 |
|
---|
11 | private BidsManager bidsManager;
|
---|
12 |
|
---|
13 | @Override
|
---|
14 | public void agentSetup () {
|
---|
15 | this.bidsManager = new BidsManager(this.negotiationSession);
|
---|
16 |
|
---|
17 | OpponentModel om = new OpponentModel_lgsmi();
|
---|
18 | OMStrategy oms = new OMStrategy_lgsmi();
|
---|
19 | OfferingStrategy offering = new OfferingStrategy_lgsmi(bidsManager);
|
---|
20 | AcceptanceStrategy ac = new AcceptanceStrategy_lgsmi();
|
---|
21 | om.init(this.negotiationSession,om.getParameters());
|
---|
22 | oms.init(this.negotiationSession,om,oms.getParameters());
|
---|
23 | try {
|
---|
24 | offering.init(this.negotiationSession, om, oms, offering.getParameters());
|
---|
25 | } catch (Exception e){
|
---|
26 | System.out.println("offering exception:");
|
---|
27 | System.out.println(e.getMessage());
|
---|
28 | }
|
---|
29 | try {
|
---|
30 | ac.init(this.negotiationSession,offering,om,ac.getParameters());
|
---|
31 | } catch (Exception e){
|
---|
32 | System.out.println("acceptance exception:");
|
---|
33 | System.out.println(e.getMessage());
|
---|
34 | }
|
---|
35 |
|
---|
36 | setDecoupledComponents(ac, offering, om, oms);
|
---|
37 | }
|
---|
38 | @Override
|
---|
39 | public String getName () {
|
---|
40 | return "anac2018/fullagent";
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Chooses an action to perform.
|
---|
46 | *
|
---|
47 | * @return Action the agent performs
|
---|
48 | */
|
---|
49 | @Override
|
---|
50 | public Action chooseAction() {
|
---|
51 | this.bidsManager.ourTurnHasArrived();
|
---|
52 | return super.chooseAction();
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Stores the actions made by a partner. First, it stores the bid in the
|
---|
57 | * history, then updates the opponent model.
|
---|
58 | *
|
---|
59 | * @param opponentAction
|
---|
60 | * by opponent in current turn
|
---|
61 | */
|
---|
62 | @Override
|
---|
63 | public void ReceiveMessage(Action opponentAction) {
|
---|
64 | super.ReceiveMessage(opponentAction);
|
---|
65 | // 1. if the opponent made a bid
|
---|
66 | if (opponentAction instanceof Offer) {
|
---|
67 | Bid oppBid = ((Offer) opponentAction).getBid();
|
---|
68 | // 2. store the opponent's trace
|
---|
69 | try {
|
---|
70 | this.bidsManager.reportNewBid(oppBid);
|
---|
71 | } catch (Exception e) {
|
---|
72 | e.printStackTrace();
|
---|
73 | }
|
---|
74 | } else if (opponentAction instanceof Accept ) {
|
---|
75 | Bid oppBid = ((Accept) opponentAction).getBid();
|
---|
76 | this.bidsManager.reportAcceptanceOfBid(oppBid);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 | }
|
---|