Category : Miscellaneous Language Source Code
Archive   : OPS5PC36.ZIP
Filename : BAGGER.OPS

 
Output of file : BAGGER.OPS contained in archive : OPS5PC36.ZIP

(literal process
step)

(literal item
name
container
size
frozen
bagged
bag-id
listed)

(literal bag
count
id-number
size
insulated
full)

(literal pepsi-flag
value)


(p welcome-to-BAGGER
(start)
-->
(write (crlf) (crlf) (crlf) (crlf) (tabto 10)
|Welcome to BAGGER, a program to illustrate the use of OPS5|
(crlf) (tabto 10)
|to write a simple rule-based system. BAGGER bags groceries|
(crlf) (tabto 10)
|after checking that there's Pepsi to go with the rest|
(crlf) (tabto 10)
|of the junk and/or squirrel food. [The example is adapted |
(crlf) (tabto 10)
|from Winston, Artificial Intelligence.]|
(crlf) (tabto 10)
| ---------- ------------ |
(crlf) (crlf) (crlf) (crlf) (crlf))
(write (tabto 10) |Would you like to include Pepsi in the order? Y/N |)
(make process ^step initial)
(make pepsi-flag ^value (accept))
(remove 1)
)

(p load-general-groceries
{ (process ^step initial) }
-->
(make item
^name bread
^container plastic_bag
^size medium
^frozen no
^bagged no)
(make item
^name glop
^container jar
^size medium
^frozen no
^bagged no)
(make item
^name granola
^container cardboard_box
^size large
^frozen no
^bagged no)
(make item
^name coffee
^container paper_bag
^size small
^frozen no
^bagged no)
(make item
^name ice_cream
^container cardboard_carton
^size medium
^frozen yes
^bagged no)
(make item
^name potato_chips
^container plastic_bag
^size medium
^frozen no
^bagged no)
(modify ^step check-order))

(p initialize-items-with-pepsi
{ (pepsi-flag ^value << y Y ye yE YE Ye yes yEs yeS YEs YES >>) }
-->
(modify ^value enter))

(p put-in-pepsi
{ (pepsi-flag ^value enter) }
-->
(make item
^name pepsi
^container bottle
^size large
^frozen no
^bagged no)
(modify ^value done))

(p add-pepsi-for-free
(process ^step check-order)
(item ^name potato_chips)
- (item ^name pepsi)
{ (pepsi-flag ^value <> enter) }
-->
(write (crlf) (crlf) (crlf) (crlf) (tabto 10)
|What, no Pepsi? With all that salty stuff? |
(crlf) (tabto 10)
|Let's add some, on the house.|
(crlf) (crlf))
(modify ^value enter))

(p move-from-check:order-to-bag:large:items-step
{ (process ^step check-order) }
(item ^size medium ^frozen no ^bagged no)
-->
(make bag
^size large
^count 0
^id-number 1
^full no)
(modify ^step bag-large-items))

;(p put-large-bottles-in-available-bag
; (process ^step bag-large-items)
; { (item ^name ^container bottle ^size large ^bagged no) }
; { (bag ^size large ^count { < 4 } ^id-number ) }
;-->
; (modify ^bagged yes ^bag-id )
; (modify ^count (compute + 1)))

(p put-other-large-items-in-available-bag
(process ^step bag-large-items)
{ (item ^name ^size large ^bagged no) }
{ (bag ^size large ^count ^id-number ^full no) }
-->
(modify ^bagged yes ^bag-id )
(modify ^count (compute + 1 )))

(p mark-large-bag-as-full
(process ^step bag-large-items)
{ (bag ^size large ^count 5 ^full no) }
-->
(modify ^full yes))

(p get-another-large-bag
(process ^step bag-large-items)
(item ^size large ^bagged no)
- (bag ^size large ^full no)
(bag ^id-number )
(bag ^id-number { >= })
-->
(make bag
^size large
^count 0
^id-number (compute + 1)
^full no))

(p move-from-bag:large:items-to-bag:medium:items-step
{ (process ^step bag-large-items) }
- (item ^size large ^bagged no)
(item ^size medium ^frozen no ^bagged no)
(bag ^id-number )
(bag ^id-number { >= })
-->
(make bag
^size medium
^count 0
^id-number (compute + 1)
^insulated no
^full no)
(modify ^step bag-medium-items))

(p put-medium-frozen-items-in-insulated-bag
(process ^step bag-medium-items)
{ (item ^size medium ^frozen yes ^bagged no) }
{ (bag ^size medium ^count ^id-number
^insulated yes ^full no) }
-->
(modify ^bagged yes ^bag-id )
(modify ^count (compute + 1)))

;; 12

(p put-other-medium-items-in-available-bag
(process ^step bag-medium-items)
{ (item ^size medium ^frozen no ^bagged no) }
{ (bag ^size medium ^count ^id-number ^insulated no
^full no) }
-->
(modify ^bagged yes ^bag-id )
(modify ^count (compute + 1)))

(p mark-medium-insulated-bag-as-full
(process ^step bag-medium-items)
{ (bag ^size medium ^count 2 ^insulated yes ^full no) }
-->
(modify ^full yes))

(p mark-medium-regular-bag-as-full
(process ^step bag-medium-items)
{ (bag ^size medium ^insulated no ^count 6 ^full no) }
-->
(modify ^full yes))

;; 15

(p get-another-insulated-medium-bag
(process ^step bag-medium-items)
(item ^size medium ^frozen yes ^bagged no)
- (bag ^size medium ^insulated yes ^full no)
(bag ^id-number )
(bag ^id-number { >= })
-->
(make bag
^size medium
^count 0
^id-number (compute + 1)
^insulated yes
^full no))

(p get-another-regular-medium-gag
(process ^step bag-medium-items)
(item ^size medium ^frozen no ^bagged no)
- (bag ^size medium ^insulated no ^full no)
(bag ^id-number )
(bag ^id-number { >= })
-->
(make bag
^size medium
^count 0
^id-number (compute + 1)
^insulated no
^full no))

(p move-from-bag:medium:items-to-bag:small:items-step
{ (process ^step bag-medium-items) }
- (item ^size medium ^bagged no)
-->
(modify ^step bag-small-items))

(p put-small-items-in-available-bag
(process ^step bag-small-items)
{ (item ^size small ^bagged no) }
{ (bag ^count ^id-number ^full no) }
- (item ^container bottle ^bag-id )
- (item ^frozen yes ^bag-id )
-->
(modify ^bagged yes ^bag-id )
(modify ^count (compute + 1)))

(p put-small-items-in-any-available-bag
(process ^step bag-small-items)
{ (item ^size small ^bagged no) }
{ (bag ^count ^id-number ^full no) }
-->
(modify ^bagged yes ^bag-id )
(modify ^count (compute + 1)))

(p check-if-bag-has-been-filled
(process ^step bag-small-items)
- (bag ^full no)
(bag ^id-number )
(bag ^id-number { >= })
-->
(make bag
^size medium
^count 0
^id-number (compute + 1)
^insulated no
^full no))

(p move-from-bag:small:items-to-wrap:up-step
{ (process ^step bag-small-items) }
- (item ^size small ^bagged no)
-->
(modify ^step prepare-for-wrapup))

(p prepare-for-wrap-up
{ (process ^step prepare-for-wrapup) }
-->
(write (crlf) (crlf) (tabto 25) |Here's a list of your groceries and |
(crlf) (tabto 25) |the bag that holds each.|)
(write (crlf) (crlf) (tabto 25) |ITEM| (tabto 45) |BAG|
(crlf) (tabto 25) |----| (tabto 45) |---|
(crlf))
(modify ^step wrap-up))

(p print-out-items-and-their-bag
(process ^step wrap-up)
{ (item ^name ^bag-id ^listed nil) }
-->
(write (crlf) (tabto 25) (tabto 45) )
(modify ^listed yes))

(startup
(make start))


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : OPS5PC36.ZIP
Filename : BAGGER.OPS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/