Line | |
---|
1 | package ai2020.group6;
|
---|
2 |
|
---|
3 | import java.util.Collections;
|
---|
4 | import java.util.Comparator;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import geniusweb.issuevalue.Bid;
|
---|
8 | import geniusweb.profile.DefaultPartialOrdering;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * DecreasingOrderBiddingStrategy generates a sorted list of possible bids and
|
---|
12 | * each round goes down this list.
|
---|
13 | *
|
---|
14 | * @author Group 6
|
---|
15 | */
|
---|
16 | public class DecreasingOrderBiddingStrategy implements IBiddingStrategy {
|
---|
17 |
|
---|
18 | List<Bid> bidlist = null;
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Bid generateBid ( MAState state ) {
|
---|
22 | if ( bidlist == null ) {
|
---|
23 | DefaultPartialOrdering dpo = (DefaultPartialOrdering) state.getProfile();
|
---|
24 | bidlist = dpo.getBids();
|
---|
25 | Collections.sort(bidlist, new Comparator<Bid>() {
|
---|
26 | @Override
|
---|
27 | public int compare(Bid b1, Bid b2) {
|
---|
28 | return dpo.isPreferredOrEqual(b1, b2) ? -1 : 1;
|
---|
29 | }
|
---|
30 | });
|
---|
31 | }
|
---|
32 |
|
---|
33 | return bidlist.remove(0);
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.