[m-users.] Mercury for Game AI

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu Jan 20 03:12:07 AEDT 2022



On Wed, 19 Jan 2022 17:55:19 +0200, David Epstein <davideps at umich.edu> wrote:
> >>> % Define network for navigation
> > >>> connected(salon,hallway)
> > >>> connected(bedroom,hallway)
> > >>> connected(X,Y) :- connected(Y,X)
> >
> > >This looks fine, except for the rule. Just duplicate the links.
> >
> 
> Is the rule approach actually wrong (won't work) or just slower (an extra
> step) ?

That last rule is an infinite loop. From the salon you can get
to the hallway, from which you can get to the salon, from which
you can get to the hallway, and so on ad infinitum.

You can avoid the loop if you keep track of which nodes you have
visited so far.

> >>> % Assign character status
> > >>> dead(dan)
> >
> > >Depends... but probably not like that. You could have a set of dead
> > >people, or a map from people to status, or something else.
> >
> 
> Yes, I use a lot of dictionaries in Python. However, I thought the
> predicate approach was more native to Mercury/Prolog, no?

It is native to Prolog. It is NOT native to Mercury. In fact, it definitely
would not work in Mercury. Since Mercury does not allow the definition
of a predicate to be modified, you would never be able to update
characters' status.

Zoltan.


More information about the users mailing list