source: src/main/java/agents/anac/y2018/fullagent/FullAgent.java@ 341

Last change on this file since 341 was 341, checked in by Katsuhide Fujita, 4 years ago

Katsuhide Fujita added ANAC2018 agents.

File size: 2.4 KB
Line 
1package agents.anac.y2018.fullagent;
2
3import negotiator.Bid;
4import negotiator.actions.Accept;
5import negotiator.actions.Action;
6import negotiator.actions.Offer;
7import negotiator.boaframework.*;
8
9public 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}
Note: See TracBrowser for help on using the repository browser.