Added the inverse diagonal winning path (#136)
This commit is contained in:
parent
f2517187bf
commit
cc09c6eb59
1 changed files with 7 additions and 4 deletions
|
|
@ -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)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue