2 ms·
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-cli
by veqq 4mo 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 https://ryjo.codes/tour-of-clips.html and even a declarative chat server: https://ryjo.codes/articles/a-simple-tcp-server-written-in-go-and-clips.html 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)))
- josh_p 4mo agoI 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-abstractions-clips.html https://ryjo.codes/articles/forgoing-implicity-using-abstrac... Thank you for sharing! A lot of good stuff here!