Ca. 150 Zeilen überflüssigen Code entfernt
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@463 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
bc835d499f
commit
ac3c13c50b
6 changed files with 339 additions and 416 deletions
|
@ -85,17 +85,9 @@ public class AIControl extends AbstractTurnControl {
|
|||
List<Stone> tableStones = new ArrayList<Stone>();
|
||||
List<Stone> handStones = new ArrayList<Stone>();
|
||||
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
handStones.add(entry.getFirst());
|
||||
}
|
||||
addHandStones(handStones);
|
||||
|
||||
if (turnInfo.getLaidOut()) {
|
||||
for (Pair<StoneSet, Position> entry : turnInfo.getTable()) {
|
||||
for (Stone stone : entry.getFirst()) {
|
||||
tableStones.add(stone);
|
||||
}
|
||||
}
|
||||
}
|
||||
addTableStones(tableStones);
|
||||
|
||||
logic = new TurnLogic(settings, tableStones, handStones);
|
||||
|
||||
|
@ -133,6 +125,22 @@ public class AIControl extends AbstractTurnControl {
|
|||
|
||||
}
|
||||
|
||||
private void addHandStones(List<Stone> handStones) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
handStones.add(entry.getFirst());
|
||||
}
|
||||
}
|
||||
|
||||
private void addTableStones(List<Stone> tableStones) {
|
||||
if (turnInfo.getLaidOut()) {
|
||||
for (Pair<StoneSet, Position> entry : turnInfo.getTable()) {
|
||||
for (Stone stone : entry.getFirst()) {
|
||||
tableStones.add(stone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void executeTurn() {
|
||||
if (turnDone) {
|
||||
return;
|
||||
|
@ -143,25 +151,7 @@ public class AIControl extends AbstractTurnControl {
|
|||
if (result != null) {
|
||||
|
||||
if (turnInfo.getLaidOut()) {
|
||||
outerLoop: for (Iterator<Pair<StoneSet, Position>> it = turnInfo
|
||||
.getTable().iterator(); it.hasNext();) {
|
||||
Pair<StoneSet, Position> pair = it.next();
|
||||
setSearch: for (Iterator<StoneSet> it2 = result.iterator(); it2
|
||||
.hasNext();) {
|
||||
StoneSet set = it2.next();
|
||||
if (set.getSize() != pair.getFirst().getSize()) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < set.getSize(); i++) {
|
||||
if (set.get(i) != pair.getFirst().get(i)) {
|
||||
continue setSearch;
|
||||
}
|
||||
}
|
||||
it2.remove();
|
||||
continue outerLoop;
|
||||
}
|
||||
it.remove();
|
||||
}
|
||||
doNotMoveExistingSets(result);
|
||||
}
|
||||
|
||||
for (StoneSet set : result) {
|
||||
|
@ -178,6 +168,29 @@ public class AIControl extends AbstractTurnControl {
|
|||
emitEndOfTurn();
|
||||
}
|
||||
|
||||
private void doNotMoveExistingSets(List<StoneSet> result) {
|
||||
|
||||
outerLoop: for (Iterator<Pair<StoneSet, Position>> it = turnInfo
|
||||
.getTable().iterator(); it.hasNext();) {
|
||||
Pair<StoneSet, Position> pair = it.next();
|
||||
setSearch: for (Iterator<StoneSet> it2 = result.iterator(); it2
|
||||
.hasNext();) {
|
||||
StoneSet set = it2.next();
|
||||
if (set.getSize() != pair.getFirst().getSize()) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < set.getSize(); i++) {
|
||||
if (set.get(i) != pair.getFirst().get(i)) {
|
||||
continue setSearch;
|
||||
}
|
||||
}
|
||||
it2.remove();
|
||||
continue outerLoop;
|
||||
}
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the factory for the base AI control
|
||||
*
|
||||
|
|
Reference in a new issue