Added the inverse diagonal winning path (#136)

This commit is contained in:
Marduk Bolaños 2025-09-09 19:00:04 +02:00 committed by GitHub
parent f2517187bf
commit cc09c6eb59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,10 +13,13 @@
path)) path))
(defn get-winning-path [{:keys [size tics]} y x] (defn get-winning-path [{:keys [size tics]} y x]
(let [flip-y (fn [y] (- size 1 y))]
(or (winner? tics (mapv #(vector y %) (range 0 size))) (or (winner? tics (mapv #(vector y %) (range 0 size)))
(winner? tics (mapv #(vector % x) (range 0 size))) (winner? tics (mapv #(vector % x) (range 0 size)))
(when (= y x) (when (= y x)
(winner? tics (mapv #(vector % %) (range 0 size)))))) (winner? tics (mapv #(vector % %) (range 0 size))))
(when (= (flip-y y) x)
(winner? tics (mapv #(vector (flip-y %) %) (range 0 size)))))))
(defn maybe-conclude [game y x] (defn maybe-conclude [game y x]
(if-let [path (get-winning-path game y x)] (if-let [path (get-winning-path game y x)]