summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/ai/fdsolver/Var.java
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-06-14 17:48:22 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-06-14 17:48:22 +0200
commit7568f3782466531fe04fc14a40dc4d3a393c1fb9 (patch)
tree7778b598da5b698c35189234fe3a9dd58ae82913 /src/jrummikub/ai/fdsolver/Var.java
parent79767f762e39eac3a0247b9ee75b24258790e0de (diff)
downloadJRummikub-7568f3782466531fe04fc14a40dc4d3a393c1fb9.tar
JRummikub-7568f3782466531fe04fc14a40dc4d3a393c1fb9.zip
Added TurnLogic with rule variables and constraints
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@436 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/ai/fdsolver/Var.java')
-rw-r--r--src/jrummikub/ai/fdsolver/Var.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/jrummikub/ai/fdsolver/Var.java b/src/jrummikub/ai/fdsolver/Var.java
index e023f34..3124e8b 100644
--- a/src/jrummikub/ai/fdsolver/Var.java
+++ b/src/jrummikub/ai/fdsolver/Var.java
@@ -38,7 +38,7 @@ public class Var<T> implements Comparable<Var<T>> {
this.solver.dirtyVars.add(this);
}
- void invalidate(T value) {
+ public void invalidate(T value) {
range.remove(value);
solver.logInvalidation(this, value);
makeDirty();
@@ -92,19 +92,25 @@ public class Var<T> implements Comparable<Var<T>> {
}
private int neighborCount() {
- int count = 0;
+ /* int count = 0;
for (Constraint constraint : constraints) {
count += constraint.getWatchedVars().size();
- }
- return count;
+ } */
+ return constraints.size();
+ }
+
+ private double fitness() {
+ return range.size();//neighborCount();
}
@Override
public int compareTo(Var<T> other) {
+ return ((Double)fitness()).compareTo(other.fitness());
+ /*
int rangeCompare = ((Integer)range.size()).compareTo(other.range.size());
if (rangeCompare != 0)
return rangeCompare;
- return ((Integer)neighborCount()).compareTo(other.neighborCount());
+ return -((Integer)neighborCount()).compareTo(other.neighborCount());*/
}
}