home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / prolog / 1600 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  2.8 KB

  1. Path: sparky!uunet!pipex!unipalm!uknet!comlab.ox.ac.uk!oxuniv!popx
  2. From: popx@vax.oxford.ac.uk
  3. Newsgroups: comp.lang.prolog
  4. Subject: Wanted: production system/coroutiner
  5. Message-ID: <1992Aug25.202004.8511@vax.oxford.ac.uk>
  6. Date: 25 Aug 92 19:20:04 GMT
  7. Organization: Oxford University VAX 6620
  8. Lines: 61
  9.  
  10. I'm looking for two Prolog programs:
  11.  
  12.  
  13. 1) An efficient production system, possibly one that works by compiling
  14. into a Rete network. I have written a slow production system that works
  15. in the obvious fashion, to use as part of my
  16. teaching-AI-by-controlling-simulated-animals project. (Shame English
  17. lost the clausal adjective construction: it's handy in Dutch and      
  18. German :-). This slow PS produces a log showing each match-resolve-act
  19. stage as it cycles. What I need now is a fast system that can be used
  20. with big rule-bases/long-running programs, and that I can make
  21. behaviourally identical (apart from logging) with the slow one.
  22.  
  23.  
  24. 2) A meta-interpreter for implementing coroutines. Example:
  25.  
  26.         test :-
  27.             goal_to_coroutine( count(10), C ),
  28.             test_count( C ).
  29.  
  30.  
  31.         test_count( C ) :-
  32.             resume( C, Result ),    % Resume or start C.
  33.                                     % Result will be unified with
  34.                                     % the argument to the next call
  35.                                     % C makes of 'suspend'.
  36.             write( Result ), nl,
  37.             test_count( C ).
  38.  
  39.  
  40.         count( N ) :-
  41.             write( 'Suspending' ), nl,
  42.             suspend( N ),           % Return N as result.
  43.             write( 'Resuming' ), nl,
  44.             Next is N + 1,
  45.             count( Next ).
  46.  
  47. Again, I want this for the animal. My simulation works in a cycle:
  48. update animal's perceptions, call animal's "brain" predicate, act on
  49. result. Many "brains" are easiest to write if control appears to go the
  50. other way: that is, the "brain" is in a continuous loop, and calls
  51. suspend each time it has to return a result to the world simulator. This
  52. saves a lot of nasty program inversion. I was able, for example, to make
  53. the animal crawl in depth-first, breadth-first, and other search
  54. patterns along trees, just by taking the standard code for these, doing
  55. some simple transformations to add the between-node walks, and inserting
  56. calls to 'suspend'.
  57.  
  58. I have implemented coroutines in Poplog: very easy to do, using Pop
  59. processes (bet you can't do that in Quintus without operating-system
  60. support...). However, I'll eventually be publishing this software in my
  61. next book, and I'd like a portable version. (Failing that, does anyone
  62. have a system for automatically inverting coroutined programs?).
  63.  
  64.  
  65. Any other software for animal control, e.g. planners, would also be
  66. welcome. This has to be public domain, since I'll be making all my code
  67. freely available, but I'll acknowledge all donors.
  68.  
  69.  
  70. Jocelyn Paine
  71.