Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;======================================================
- ;;; Mobile Architecture Expert Systems
- ;;;
- ;;; This expert system diagnoses some simple
- ;;; problems with a car.
- ;;;
- ;;; CLIPS Version 6.3 Example
- ;;;
- ;;; To execute, merely load, reset and run.
- ;;;======================================================
- ;;****************
- ;;* DEFFUNCTIONS *
- ;;****************
- (deffunction ask-question (?question $?allowed-values)
- (printout t ?question)
- (bind ?answer (read))
- (if (lexemep ?answer)
- then (bind ?answer (lowcase ?answer)))
- (while (not (member ?answer ?allowed-values)) do
- (printout t ?question)
- (bind ?answer (read))
- (if (lexemep ?answer)
- then (bind ?answer (lowcase ?answer))))
- ?answer)
- (deffunction yes-or-no-p (?question)
- (bind ?response (ask-question ?question yes no y n))
- (if (or (eq ?response yes) (eq ?response y))
- then yes
- else no))
- ;;;***************
- ;;;* QUERY RULES *
- ;;;***************
- ;;; LEVEL 1
- (defrule determine-customer-facing ""
- (not (customer-facing ?))
- (not (repair ?))
- =>
- (assert (customer-facing (yes-or-no-p "System : Is your app customer facing? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- ;;; LEVEL 2
- (defrule determine-screen ""
- (customer-facing yes)
- (not (repair ?))
- =>
- (assert (single-screen (yes-or-no-p "System : Is your app single screen with lots of animations or sounds? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- (defrule determine-sensor ""
- (customer-facing no)
- (not (repair ?))
- =>
- (assert (sensor (yes-or-no-p "System : Do you need to access the device's sensors? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- ;;; LEVEL 3
- (defrule determine-multi-screen ""
- (customer-facing yes)
- (single-screen no)
- (not (repair ?))
- =>
- (assert (multi-screen (yes-or-no-p "System : Do you need a few screens with lots of animations or sounds? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- (defrule determine-native-function ""
- (or(or(or(appstore yes)(sensor yes))(multi-os yes))(multi-screen no))
- (not (repair ?))
- =>
- (assert (native-function (yes-or-no-p "System : Do you need access to customer native functionality? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- (defrule determine-appstore ""
- (customer-facing no)
- (sensor no)
- (not (repair ?))
- =>
- (assert (appstore (yes-or-no-p "System : Do you need your app on the store? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- ;;; LEVEL 4
- (defrule determine-poor-performance ""
- (customer-facing yes)
- (single-screen no)
- (multi-screen yes)
- (not (repair ?))
- =>
- (assert (poor-performance (yes-or-no-p "System : Do you need to support devices with poor performance? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- (defrule determine-multi-os ""
- (customer-facing yes)
- (single-screen no)
- (multi-screen yes)
- (poor-performance no)
- (not (repair ?))
- =>
- (assert (multi-os (yes-or-no-p "System : Do you need to support multiple operating systems? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- (defrule determine-branded ""
- (native-function no)
- (not (repair ?))
- =>
- (assert (branded (yes-or-no-p "System : Do you need your app branded? (yes/no)?
- User : ")))
- (printout t "=======================================================")
- (printout t crlf crlf))
- ##CONCLUSIONS
- (defrule single-screen-conclusions ""
- (customer-facing yes)
- (single-screen yes)
- (not (repair ?))
- =>
- (assert (repair "[Native]
- A native app is designed to run on one specic mobile operating system, such as
- iOS, Android or Windows Phone. It is built using the operating system vendor’s
- technology and, typically, using development tools supplied by that vendor.")))
- (defrule hybrid-mixed ""
- (or(or(poor-performance yes)(multi-os no))(native-function yes))
- (not (repair ?))
- =>
- (assert (repair "[Hybrid Mixed]
- A hybrid mixed app is similar to a hybrid web app but more code is written
- natively to take full advantage of device features and capabilities. Like
- hybrid web apps, hybrid mixed apps are primarily built with standard
- web technologies.")))
- (defrule hybrid-web ""
- (branded yes)
- (not (repair ?))
- =>
- (assert (repair "[Hybrid Web]
- A hybrid web application combines the best attributes of native and mobile web
- apps. The vast majority of the app is built using mobile web standards – HTML5,
- CSS and JavaScript – that are either served from an application server or are
- distributed with the app.")))
- (defrule packaged-hybrid ""
- (branded no)
- (not (repair ?))
- =>
- (assert (repair "[Packaged Hybrid]
- A packaged hybrid app consists of a native shell and a mobile web app very much
- like a hybrid web architecture. The dierence is that the native shell is maintained
- by a third-party vendor, further reducing the need for in-house maintenance work
- on the native code bases.")))
- (defrule mobile-web-conclusions ""
- (customer-facing no)
- (sensor no)
- (appstore no)
- (not (repair ?))
- =>
- (assert (repair "[Mobile web]
- A mobile web app can be accessed from any device running a web browser
- regardless of its underlying operating system. Mobile web apps are built
- using standard Web technologies such as HTML5, JavaScript and CSS.")))
- ;;;********************************
- ;;;* STARTUP AND CONCLUSION RULES *
- ;;;********************************
- (defrule system-banner ""
- =>
- (printout t crlf crlf)
- (printout t "Mobile Architecture Expert System")
- (printout t crlf crlf))
- (defrule print-repair ""
- (repair ?item)
- =>
- (printout t crlf crlf)
- (printout t "Suggested Architecture:")
- (printout t crlf crlf)
- (format t " %s%n%n%n" ?item))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement