[m-users.] Mercury for Game AI

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Jan 23 22:46:59 AEDT 2022


2022-01-23 22:32 GMT+11:00 "David Epstein" <davideps at umich.edu>:
> For me, the attraction of Prolog (and perhaps of Mercury) for game AI is
> resolution via unification over a complex set of rules and facts. For
> example, say bob is a person who is hiding. If he stops hiding, he will
> become vulnerable:
> 
> person(bob)
> hiding(bob)
> vulnerable(Person) :- not(hiding(Person))

:- type person
 ---> bob
;   ...

:- pred vulnerable(set(person)::in, person::in) is semidet.

vulnerable(Hiding, Person) :-
   not set.member(Person, Hiding).

The logic of the vulnerable predicate here is exactly the same,
but the set of people hiding is expressed as a data structure
(which have different versions over time in Mercury) and not
as the definition of a predicate (which cannot be changed
after compilation).

You may also wish to look at the mercury-users thread about
"inferring over dynamic data" for more examples.

Zoltan.


More information about the users mailing list