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

Last change on this file was 345, checked in by Tim Baarslag, 4 years ago

Fixed agent 2018 descriptions

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