Hacker News new | ask | show | jobs
by exDM69 5025 days ago
I suggested using Prolog in the comments. His problem description was not quite good enough for me to assess whether or not Prolog will be a good choice, but at least it's a candidate.

A Prolog program is essentially a list of rules that are written as an implication. Something like:

  moves_to(Cow, Location) :-
    hungry(Cow),
    current_location(Cow, OldLoc),
    food_in(OldLoc, OldFood), food_in(Location, Food),
    Food > OldFood.
In human language: a cow moves to a location if it's hungry and there's more food in that location than in current location.

I should probably write a proper answer.

edit: Added a proper answer to the stackoverflow with an almost complete introductory Prolog example. It's waiting for your upvotes :)

2 comments

Good answer. Nice to see the original questioner accepted it. To take it a bit further, so-called "answer set solvers" like clasp (http://potassco.sourceforge.net/) provide a fast way to run these kinds of logic programs.
And we're waiting for a link.