[341] | 1 | package agents.anac.y2018.fullagent;
|
---|
| 2 |
|
---|
[343] | 3 | import genius.core.Bid;
|
---|
| 4 | import genius.core.actions.Accept;
|
---|
| 5 | import genius.core.actions.Action;
|
---|
| 6 | import genius.core.actions.Offer;
|
---|
| 7 | import genius.core.boaframework.AcceptanceStrategy;
|
---|
| 8 | import genius.core.boaframework.BOAagentBilateral;
|
---|
| 9 | import genius.core.boaframework.OMStrategy;
|
---|
| 10 | import genius.core.boaframework.OfferingStrategy;
|
---|
| 11 | import genius.core.boaframework.OpponentModel;
|
---|
[341] | 12 |
|
---|
[343] | 13 | public 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 | }
|
---|