Fork me on GitHub
#core-logic
<
2017-10-26
>
bbss04:10:13

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

bbss04:10:45

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

bbss04:10:20

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

bbss05:10:23

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

bbss05:10:31

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

bbss07:10:15

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

xtreak2920:10:01

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])))

xtreak2920:10:36

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)))))

hiredman20:10:37

you don't need a macro

hiredman20:10:09

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