Comment by veqq
3 days ago
MTG: Arena uses a rules engine CLIPS (a s-expr expert system based on the RETE engine), which an acquaintance wrote a course for: https://ryjo.codes/tour-of-clips.html and even a declarative chat server: https://ryjo.codes/articles/a-simple-tcp-server-written-in-g...
(defrule connection
(connection ?id)
=>
(println "User " ?id " connected")
(printout ?id "Welcome to the chatroom from CLIPS!" crlf)
(do-for-all-facts ((?f connection)) (neq ?id (nth$ 1 ?f:implied))
(printout (nth$ 1 ?f:implied) "User " ?id " connected" crlf)))
(defrule say
(connection ?id)
?f <- (message-buffered ?id)
?ff <- (message ?id ~/me ?message)
=>
(retract ?f ?ff)
(printout ?id "You: " ?message crlf)
(do-for-all-facts ((?f connection)) (neq ?id (nth$ 1 ?f:implied))
(printout (nth$ 1 ?f:implied)
?id ": " ?message crlf)))
I was about to ask why someone would reach for CLIPS over implementing their own rules engine in the language of the rest of the application (I did this once).
It’s answered on the same site. https://ryjo.codes/articles/forgoing-implicity-using-abstrac...
Thank you for sharing! A lot of good stuff here!