Implemented counting of identical stone pairs
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@275 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
5e855398b9
commit
656bfe905b
1 changed files with 18 additions and 6 deletions
|
@ -104,10 +104,18 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInitialMeldPossible() {
|
public boolean isInitialMeldPossible() {
|
||||||
|
Pair<TreeMap<Pair<Integer, StoneColor>, Integer>, Integer> stoneCounts = countStones();
|
||||||
|
|
||||||
|
return findSetsWithTotalPoints(settings.getInitialMeldThreshold(),
|
||||||
|
stoneCounts.getFirst(), stoneCounts.getSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pair<TreeMap<Pair<Integer, StoneColor>, Integer>, Integer> countStones() {
|
||||||
int jokerCount = 0;
|
int jokerCount = 0;
|
||||||
TreeMap<Pair<Integer, StoneColor>, Integer> stoneCounts = new TreeMap<Pair<Integer, StoneColor>, Integer>(
|
TreeMap<Pair<Integer, StoneColor>, Integer> stoneCounts = new TreeMap<Pair<Integer, StoneColor>, Integer>(
|
||||||
comparator);
|
comparator);
|
||||||
|
|
||||||
|
|
||||||
for (Pair<Stone, Position> entry : this) {
|
for (Pair<Stone, Position> entry : this) {
|
||||||
if (entry.getFirst().isJoker()) {
|
if (entry.getFirst().isJoker()) {
|
||||||
jokerCount++;
|
jokerCount++;
|
||||||
|
@ -119,9 +127,7 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
incrementStoneCount(stoneCounts, key);
|
incrementStoneCount(stoneCounts, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new Pair<TreeMap<Pair<Integer, StoneColor>, Integer>, Integer>(stoneCounts, jokerCount);
|
||||||
return findSetsWithTotalPoints(settings.getInitialMeldThreshold(),
|
|
||||||
stoneCounts, jokerCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void incrementStoneCount(
|
private void incrementStoneCount(
|
||||||
|
@ -264,7 +270,13 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIdenticalStoneCount() {
|
public int getIdenticalStoneCount() {
|
||||||
// TODO Auto-generated method stub
|
Pair<TreeMap<Pair<Integer, StoneColor>, Integer>, Integer> stoneCounts = countStones();
|
||||||
return 0;
|
int pairCount = 0;
|
||||||
|
|
||||||
|
for(int count : stoneCounts.getFirst().values()) {
|
||||||
|
pairCount += count / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pairCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue