core-logic

2017-10-26T04:58:13.000137Z

I'm getting errors when using fd example:

(run* [q]
  (fresh [x y]
    (fd/in x y (fd/interval 1 10))
    (fd/+ x y 10)
    (== q [x y]))) ; => ([1 9] [2 8] [3 7] [4 6] [5 5] [6 4] [7 3] [8 2] [9 1])
Gives
Exception Constrained variable <lvar:q__50256> without domain  clojure.core.logic/verify-all-bound/verify-all-bound*--48690 (logic.clj:2136)
from: https://github.com/clojure/core.logic/wiki/Features

2017-10-26T04:58:45.000054Z

some of the fd examples from the test namespace also fail. using 0.8.11

2017-10-26T04:59:20.000104Z

it seems perfect for the problem I want to solve, finding build orders in StarCraft II 🙂

2017-10-26T05:12:23.000090Z

I think in general core.logic would make for a useful tool in an RTS AI. What do people here think?

2017-10-26T05:13:31.000153Z

Maybe generate data to help train a neural net, or help it make decisions, that could then more easily be visualized.

2017-10-26T07:34:15.000006Z

figured out I was importing wrong, got it working now 🙂

xtreak29 2017-10-26T20:16:01.000386Z

Is there a way to generate the constraints in a macro. I need the following :

(pldb/with-db db (run 1 [q]
                     (fresh [x y z a b c]
                       (foo x y)
                       (foo a b)
                       (foo b c)
                       ;; more constraints
                       (== q [x y z a b c])))

xtreak29 2017-10-26T20:22:36.000612Z

I can have many number of vars to fresh and also a lot of foo constraints. I have the following macro but it's not working.

(defmacro my-fresh
  [db districts res]
  `(pldb/with-db ~db (run 1 [q]
                       (fresh ~districts
                         (map (fn [[x y]] ('foo x y)) ~res)
                         (== q ~districts)))))

2017-10-26T20:41:37.000175Z

you don't need a macro

2017-10-26T20:42:09.000585Z

there is a goal that will combine a sequence of goals in to a single goal (via conjunction)