source: ai2020/group6/DecreasingOrderBiddingStrategy.java@ 5

Last change on this file since 5 was 3, checked in by wouter, 4 years ago

#1925 added group6 code.

File size: 878 bytes
RevLine 
[3]1package ai2020.group6;
2
3import java.util.Collections;
4import java.util.Comparator;
5import java.util.List;
6
7import geniusweb.issuevalue.Bid;
8import 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 */
16public 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.