summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/ai/fdsolver/Var.java
diff options
context:
space:
mode:
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());*/
}
}