Last change
on this file since 107 was
44,
checked in by mszubert, 15 years ago
|
cecj, framsticks and games packages imported
|
File size:
1.1 KB
|
Line | |
---|
1 | package cecj.app.numbers_game; |
---|
2 | |
---|
3 | import java.math.BigInteger; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import cecj.interaction.InteractionResult; |
---|
7 | import cecj.interaction.RealValuedResult; |
---|
8 | import cecj.utils.Pair; |
---|
9 | |
---|
10 | |
---|
11 | public class MultiDimensionalNumbersGame1 extends MultiDimensionalNumbersGame { |
---|
12 | |
---|
13 | @Override |
---|
14 | protected Pair<? extends InteractionResult> compareDimensionsVectors( |
---|
15 | List<BigInteger> candidateVector, List<BigInteger> testVector) { |
---|
16 | |
---|
17 | int comparisonDimension = 0; |
---|
18 | BigInteger maxDiffOnDimension = candidateVector.get(0).subtract(testVector.get(0)).abs(); |
---|
19 | for (int dim = 1; dim < candidateVector.size(); dim++) { |
---|
20 | BigInteger diff = candidateVector.get(dim).subtract(testVector.get(dim)).abs(); |
---|
21 | if (diff.compareTo(maxDiffOnDimension) > 0) { |
---|
22 | maxDiffOnDimension = diff; |
---|
23 | comparisonDimension = dim; |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | if (candidateVector.get(comparisonDimension).compareTo(testVector.get(comparisonDimension)) > 0) { |
---|
28 | return new Pair<RealValuedResult>(new RealValuedResult(1), new RealValuedResult(0)); |
---|
29 | } else { |
---|
30 | return new Pair<RealValuedResult>(new RealValuedResult(0), new RealValuedResult(1)); |
---|
31 | } |
---|
32 | } |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.