From ac3c13c50b87abfc6e4959fabd5107990d1eb417 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sat, 18 Jun 2011 16:19:20 +0200 Subject: =?UTF-8?q?Ca.=20150=20Zeilen=20=C3=BCberfl=C3=BCssigen=20Code=20e?= =?UTF-8?q?ntfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@463 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/turn/AIControl.java | 71 ++++++++++++++++++------------- 1 file changed, 42 insertions(+), 29 deletions(-) (limited to 'src/jrummikub/control/turn') diff --git a/src/jrummikub/control/turn/AIControl.java b/src/jrummikub/control/turn/AIControl.java index 324c8d7..7784d7f 100644 --- a/src/jrummikub/control/turn/AIControl.java +++ b/src/jrummikub/control/turn/AIControl.java @@ -85,17 +85,9 @@ public class AIControl extends AbstractTurnControl { List tableStones = new ArrayList(); List handStones = new ArrayList(); - for (Pair entry : turnInfo.getHand()) { - handStones.add(entry.getFirst()); - } + addHandStones(handStones); - if (turnInfo.getLaidOut()) { - for (Pair 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 handStones) { + for (Pair entry : turnInfo.getHand()) { + handStones.add(entry.getFirst()); + } + } + + private void addTableStones(List tableStones) { + if (turnInfo.getLaidOut()) { + for (Pair 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> it = turnInfo - .getTable().iterator(); it.hasNext();) { - Pair pair = it.next(); - setSearch: for (Iterator 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 result) { + + outerLoop: for (Iterator> it = turnInfo + .getTable().iterator(); it.hasNext();) { + Pair pair = it.next(); + setSearch: for (Iterator 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 * -- cgit v1.2.3