CmdrDats / igoki

Clojure Go Kifu recorder and OGS player
Eclipse Public License 1.0
162 stars 15 forks source link

When inference doesn't work with larger updatelist, try break it down #40

Open CmdrDats opened 9 years ago

CmdrDats commented 9 years ago

Try find other possible stable points and look for a possible game sequence where both sides can work.

CmdrDats commented 9 years ago

Here's an edn file that represents a ridiculously fast + complex game where inference has trouble due to captured groups.

It's in a form of a two element vector - the first being the game state and the update list - the last element of the update list is the final game position.

test.txt

CmdrDats commented 9 years ago

My initial attempt is to find 'stable candidates' and try slice things up from there, but I suspect the recursive nature of this solution means it'll take a while to complete? Will have to see, but just leaving this as a note on this issue:

(defn find-stable-candidates
  [game updatelist]
  (let [point-count (fn [b] (frequencies (map #(nth % 2) (point-map b))))
        initial-counts (point-count (:kifu-board game))
        diff-count (fn [u] (merge-with (fnil - 0) (point-count u) initial-counts))
        stable?
        (fn [[_ dc u]]
          (let [{:keys [b w]} dc]
            (< (Math/abs (int (- (or b 0) (or w 0)))) 2)))]
    (filter stable? (map-indexed #(vector %1 (diff-count %2) %2) updatelist)))
  )