summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/control/RoundControl.java2
-rw-r--r--src/jrummikub/control/turn/BaseAIControl.java20
2 files changed, 12 insertions, 10 deletions
diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java
index 67c177f..40894eb 100644
--- a/src/jrummikub/control/RoundControl.java
+++ b/src/jrummikub/control/RoundControl.java
@@ -88,7 +88,7 @@ public class RoundControl {
view.enableThinkPanel(true);
}
- view.getTablePanel().setStoneSets(clonedTable);
+ view.getTablePanel().setStoneSets(clonedTable.clone());
view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings()
.getName());
view.setCurrentPlayerColor(roundState.getActivePlayer().getPlayerSettings()
diff --git a/src/jrummikub/control/turn/BaseAIControl.java b/src/jrummikub/control/turn/BaseAIControl.java
index 55cece8..b02c127 100644
--- a/src/jrummikub/control/turn/BaseAIControl.java
+++ b/src/jrummikub/control/turn/BaseAIControl.java
@@ -75,13 +75,14 @@ public class BaseAIControl extends AbstractTurnControl {
}
private Stone findMatchingStone(Stone target) {
- for(Pair<Stone, Position> entry : hand){
+ for (Pair<Stone, Position> entry : hand) {
Stone stone = entry.getFirst();
- if (stone.getValue() == target.getValue() && stone.getColor() == target.getColor()) {
+ if (stone.getValue() == target.getValue()
+ && stone.getColor() == target.getColor()) {
return stone;
}
}
- for(Pair<Stone, Position> entry : hand){
+ for (Pair<Stone, Position> entry : hand) {
Stone stone = entry.getFirst();
if (stone.isJoker()) {
return stone;
@@ -95,7 +96,7 @@ public class BaseAIControl extends AbstractTurnControl {
hand.pickUp(match);
return match;
}
-
+
private void turn() {
List<Stone> stones = new ArrayList<Stone>();
@@ -109,20 +110,21 @@ public class BaseAIControl extends AbstractTurnControl {
AIUtil aiUtil = new AIUtil(settings);
Pair<List<StoneSet>, Integer> result = aiUtil.findSetsWithTotalPoints(
- Integer.MAX_VALUE, counts.getFirst(), counts.getSecond());
+ Math.max(30, settings.getInitialMeldThreshold() * 2),
+ counts.getFirst(), counts.getSecond());
if (!player.getLaidOut()
&& result.getSecond() < settings.getInitialMeldThreshold()) {
emitEndOfTurn();
return;
}
-
+
for (StoneSet set : result.getFirst()) {
List<Stone> handStones = new ArrayList<Stone>();
for (Stone stone : set) {
handStones.add(pickUpMatchingStone(stone));
}
- table.drop(new StoneSet(handStones), new Position(0, 0));
+ table.drop(new StoneSet(handStones), new Position((float)Math.random() * 30 - 15, (float)Math.random() * 6 - 3));
}
emitEndOfTurn();
@@ -142,8 +144,8 @@ public class BaseAIControl extends AbstractTurnControl {
private void emitEndOfTurn() {
long timeElapsed = System.currentTimeMillis() - startTime;
- long timeNeeded = Math.min((long) (1000 + Math.random() * hand.getSize()
- * 100), 50000);
+ long timeNeeded = Math.min(
+ (long) (1000 + Math.random() * hand.getSize() * 100), 50000);
long waitTime = timeNeeded - timeElapsed;
if (waitTime > 0) {