source: src/main/java/agents/ai2014/group2/G2SubBid.java@ 127

Last change on this file since 127 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.3 KB
Line 
1package agents.ai2014.group2;
2
3import java.util.ArrayList;
4
5class G2SubBid implements Comparable<G2SubBid>{
6 ArrayList<String> values;
7 double ourUtility;
8 ArrayList<Double> otherUtilities;
9
10 public G2SubBid(String value, double ourUtility, ArrayList<Double> otherUtilities) {
11 values = new ArrayList<String>(1);
12 values.add(value);
13 this.ourUtility = ourUtility;
14 this.otherUtilities = otherUtilities;
15 }
16
17 public G2SubBid(G2SubBid one, G2SubBid two) {
18 values = new ArrayList<String>(one.values.size() + two.values.size());
19 values.addAll(one.values);
20 values.addAll(two.values);
21
22 ourUtility = one.ourUtility + two.ourUtility;
23
24 otherUtilities = new ArrayList<Double>(one.otherUtilities.size());
25 for(int i=0; i<one.otherUtilities.size(); i++) {
26 otherUtilities.add(one.otherUtilities.get(i) + two.otherUtilities.get(i));
27 }
28 }
29
30 public String getValue(int i) {
31 return values.get(i);
32 }
33
34 @Override
35 public int compareTo(G2SubBid other) {
36 if(ourUtility > other.ourUtility)
37 return 1;
38 else if(ourUtility == other.ourUtility)
39 return 0;
40 else
41 return -1;
42 }
43
44 public boolean hasHigherOtherUtilities(G2SubBid other) {
45 if(other == null)
46 return true;
47
48 for(int i=otherUtilities.size()-1; i>=0; i--) {
49 if(otherUtilities.get(i) > other.otherUtilities.get(i) + 0.00001)
50 return true;
51 }
52 return false;
53 }
54}
Note: See TracBrowser for help on using the repository browser.