Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I am trying to implement some AI planning algorithms in C, but got stuck with the basic concept :)

Before jumping to the main problem, I tried implementing some small framework that would support propositional logic:

FORMULA f = PROPOSITION(a + 3 > 0);

FORMULA g = PROPOSITION(is_smaller_than(b, c));

f = AND(NOT(f), g);

Now, the problem is that I would like not to evaluate expressions like 'a + 3 > 0' at the moment of defining the formula, but in some later phase:

bool res = EVALUATE(f);

I guess closures would have been handy in this case, but unfortunately, I also like to stick to C99.

Any idea?

How about extending this to predicate logic?

The final goal (ideally) would be to build an AI planning library, which can be directly plugged-in to the application, and not to receive the problem as STRIPS program strings.

Thanks

1 Answer

0 votes
by (108k points)

You can solve the issue by using a structure with a method pointer and data in it. This is the most common way of simulating closures in C.

The implementation is available here: https://github.com/pmilosev/clumsy

Browse Categories

...