🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #724

Wanted: production system/coroutiner

#724
From: popx
Date: Tue, 25 Aug 1992 19:20
61 lines
2926 bytes
I'm looking for two Prolog programs:


1) An efficient production system, possibly one that works by compiling
into a Rete network. I have written a slow production system that works
in the obvious fashion, to use as part of my
teaching-AI-by-controlling-simulated-animals project. (Shame English
lost the clausal adjective construction: it's handy in Dutch and      
German :-). This slow PS produces a log showing each match-resolve-act
stage as it cycles. What I need now is a fast system that can be used
with big rule-bases/long-running programs, and that I can make
behaviourally identical (apart from logging) with the slow one.


2) A meta-interpreter for implementing coroutines. Example:

        test :-
            goal_to_coroutine( count(10), C ),
            test_count( C ).


        test_count( C ) :-
            resume( C, Result ),    % Resume or start C.
                                    % Result will be unified with
                                    % the argument to the next call
                                    % C makes of 'suspend'.
            write( Result ), nl,
            test_count( C ).


        count( N ) :-
            write( 'Suspending' ), nl,
            suspend( N ),           % Return N as result.
            write( 'Resuming' ), nl,
            Next is N + 1,
            count( Next ).

Again, I want this for the animal. My simulation works in a cycle:
update animal's perceptions, call animal's "brain" predicate, act on
result. Many "brains" are easiest to write if control appears to go the
other way: that is, the "brain" is in a continuous loop, and calls
suspend each time it has to return a result to the world simulator. This
saves a lot of nasty program inversion. I was able, for example, to make
the animal crawl in depth-first, breadth-first, and other search
patterns along trees, just by taking the standard code for these, doing
some simple transformations to add the between-node walks, and inserting
calls to 'suspend'.

I have implemented coroutines in Poplog: very easy to do, using Pop
processes (bet you can't do that in Quintus without operating-system
support...). However, I'll eventually be publishing this software in my
next book, and I'd like a portable version. (Failing that, does anyone
have a system for automatically inverting coroutined programs?).


Any other software for animal control, e.g. planners, would also be
welcome. This has to be public domain, since I'll be making all my code
freely available, but I'll acknowledge all donors.


Jocelyn Paine
Technical Details
Message-ID: <1992Aug25.202004.8511@vax.oxford.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!comlab.ox.ac.uk!oxuniv!popx

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!unipalm!uknet!comlab.ox.ac.uk!oxuniv!popx
From: popx@vax.oxford.ac.uk
Newsgroups: comp.lang.prolog
Subject: Wanted: production system/coroutiner
Message-ID: <1992Aug25.202004.8511@vax.oxford.ac.uk>
Date: 25 Aug 92 19:20:04 GMT
Organization: Oxford University VAX 6620
Lines: 61