Bläddra i källkod

Commit old experimental strategy change to not lose it

Taddeus Kroes 2 veckor sedan
förälder
incheckning
08fdbd345d
1 ändrade filer med 9 tillägg och 0 borttagningar
  1. 9 0
      strategy.py

+ 9 - 0
strategy.py

@@ -81,6 +81,8 @@ class State:
         return 0
 
     def holes(self):
+        #return self.imbalance()
+
         start_row = self.empty_rows()
         score = 0
         for col in range(COLUMNS):
@@ -232,6 +234,13 @@ class State:
 
         return -points
 
+    def imbalance(self):
+        colsizes = tuple(self.nrows - skip
+                         for col, skip in enumerate(self.colskip))
+                         #if not self.colbusy(col))
+        mean = sum(colsizes) / len(colsizes)
+        return sum((size - mean) ** 2 for size in colsizes)
+
     def gen_moves(self):
         if self.held == NOBLOCK:
             yield self