[m-users.] Mercury for Game AI
Zoltan Somogyi
zoltan.somogyi at runbox.com
Fri Jan 21 03:51:00 AEDT 2022
2022-01-20 04:02 GMT+11:00 "David Epstein" <davideps at umich.edu>:
>>>>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.
>>
>
> I've been told this several times, but apparently the lesson hasn't sunk in
> completely. I thought the definition of a predicate was the "pred" and
> "mode" lines and that "dead(dan)" was...
No. The lines starting with ":- pred" and ":- mode" are a predicate's
*declaration*. The *definition* of a predicate consists of its clauses.
> I'm unsure of the correct
> words...like *assigning* the name "dan" to the predicate.
If you use the word "assign" in the same sense as imperative
programming languages use that word, then Mercury does
not allow assignments of any kind. In an imperative language,
you can assign one value to a variable now and assign a different
value to the same variable later. In Mercury, once you say
"the definition of this predicate is this sequence of clauses",
you can never change that. (Short of modifying and recompiling
the program, of course, which creates a new, different program.)
> But, you are
> saying that each invocation of the predicate is part of its definition?
No, I am not saying that. I don't even know what that sentence
is intended to mean.
> Let me ask a different question. Based on my description of the project, do
> you think Mercury is a good fit--better than C# alone? I ask because there
> are many game AI, NLP, and other libraries available for C#.
I have worked on game programs once upon a time, and I think Mercury
is a good language for them. Just the presence of algebraic data types
makes so many problems easier to solve.
However, a language being a good fit for an application area is not enough;
it has to be a good fit for the programmer as well. Whether it is a good fit for you
is a question that only you can answer.
> But, I saw how
> Prolog handles things, fell in love, and starting searching for a version
> of Prolog compatible with C#.
Mercury is NOT Prolog, and it does many, maybe even most things
differently than Prolog. Many typical Prolog programming techniques
rely on nonlogical features of Prolog. Since these don't exist in Mercury,
if you try to shoehorn those techniques into Mercury code, the result
will not be pretty.
> Regardless, I'm super impressed with
> how Mercury can produce C# assemblies that work on multiple .NET platforms.
On behalf of the rest of the Mercury team, thanks. (I was not among
the people who wrote Mercury's C# backend.)
Zoltan.
More information about the users
mailing list