1 | package uva.projectai.y2018.jasparon;
|
---|
2 |
|
---|
3 | import java.util.Collections;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import genius.core.bidding.BidDetails;
|
---|
7 | import genius.core.boaframework.*;
|
---|
8 |
|
---|
9 | public class JasparonBiddingStrategy extends OfferingStrategy {
|
---|
10 |
|
---|
11 | private int bidRank = 0;
|
---|
12 |
|
---|
13 | public JasparonBiddingStrategy(NegotiationSession negotiationSession, OpponentModel opponentModel, OMStrategy omStrategy) {
|
---|
14 | super.init(negotiationSession, null);
|
---|
15 | this.opponentModel = opponentModel;
|
---|
16 | this.omStrategy = omStrategy;
|
---|
17 | this.endNegotiation = false;
|
---|
18 |
|
---|
19 | OutcomeSpace outcomeSpace = new SortedOutcomeSpace(negotiationSession.getUtilitySpace());
|
---|
20 | this.negotiationSession.setOutcomeSpace(outcomeSpace);
|
---|
21 | }
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | public BidDetails determineOpeningBid() {
|
---|
25 | return negotiationSession.getOutcomeSpace().getMaxBidPossible();
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public BidDetails determineNextBid() {
|
---|
30 | if (negotiationSession.getTime() > 0.8) {
|
---|
31 | // Find bid with highest utility for me, made by opponent
|
---|
32 | System.out.println(this.nextBid.getBid());
|
---|
33 | return this.getBestOpponentOffer();
|
---|
34 | } else {
|
---|
35 | // Slowly descend down sorted list of bids, sorted on a function of my and opponents utility
|
---|
36 | System.out.println(this.nextBid.getBid());
|
---|
37 | return this.getOptimalBid();
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | private BidDetails getOptimalBid() {
|
---|
42 | JasparonBidComparator bidComparator = new JasparonBidComparator(opponentModel);
|
---|
43 | List<BidDetails> allBids = negotiationSession.getOutcomeSpace().getAllOutcomes();
|
---|
44 | Collections.sort(allBids, bidComparator);
|
---|
45 |
|
---|
46 | BidDetails nextBid = allBids.get(bidRank);
|
---|
47 | if (bidRank < allBids.size() - 1) {
|
---|
48 | bidRank++;
|
---|
49 | }
|
---|
50 |
|
---|
51 | return nextBid;
|
---|
52 | }
|
---|
53 |
|
---|
54 | private BidDetails getBestOpponentOffer() {
|
---|
55 | return negotiationSession.getOpponentBidHistory().getBestBidDetails();
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public String getName() {
|
---|
60 | // TODO Auto-generated method stub
|
---|
61 | return "Adapted SmithBidding";
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|