Last change
on this file since 521 was
193,
checked in by Maciej Komosinski, 11 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
1002 bytes
|
Rev | Line | |
---|
[44] | 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 CompareOnOneGame 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 maxDimensionValue = testVector.get(0); |
---|
| 19 | for (int dim = 1; dim < testVector.size(); dim++) { |
---|
| 20 | if (testVector.get(dim).compareTo(maxDimensionValue) > 0) { |
---|
| 21 | maxDimensionValue = testVector.get(dim); |
---|
| 22 | comparisonDimension = dim; |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | if (candidateVector.get(comparisonDimension).compareTo(testVector.get(comparisonDimension)) >= 0) { |
---|
| 27 | return new Pair<RealValuedResult>(new RealValuedResult(1), new RealValuedResult(-1)); |
---|
| 28 | } else { |
---|
| 29 | return new Pair<RealValuedResult>(new RealValuedResult(-1), new RealValuedResult(1)); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.