; ; CADDIE - The golf pro's edge at your finger tips! ; ; Charles Weddle at Florida State Univeristy ; copywrite 2004, all rights reserved. ; ; ; *** deftemplates *** ; ; ; control deftemplates ; (deftemplate step-control (slot step)) (deftemplate user-name (slot name)) (deftemplate gc-desc (slot value)) ; ; golf course deftemplates ; (deftemplate gc-desc-length (slot value)) (deftemplate gc-desc-length-ui (slot value)) (deftemplate gc-desc-slope (slot value)) (deftemplate gc-desc-slope-ui (slot value)) (deftemplate gc-desc-pgarate (slot value)) (deftemplate gc-desc-pgarate-ui (slot value)) ; ; environement deftemplates ; (deftemplate gc-env (slot value)) (deftemplate gc-env-raining (slot value)) (deftemplate gc-env-wet-ui (slot value)) ; ; player deftemplates ; (deftemplate gc-player (slot value)) (deftemplate gc-player-hndcp (slot value)) (deftemplate gc-player-hndcp-ui (slot value)) (deftemplate gc-player-play (slot value)) (deftemplate gc-player-play-ui (slot value)) (deftemplate gc-player-avgscr (slot value)) (deftemplate gc-player-avgscr-ui (slot value)) ; ; shot deftemplates ; (deftemplate gc-shot-pos (slot value)) (deftemplate gc-shot-pos-ui (slot value)) (deftemplate gc-shot-dfh (slot value)) (deftemplate gc-shot-dfh-ui (slot value)) (deftemplate gc-shot-dfh-ui2 (slot value)) ; ; *** deffacts *** ; (deffacts initial-step (step-control (step start-1))) ; ; *** defrules - start *** ; (defrule start-up ?current-step <- (step-control (step start-1)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " Welcome to CADDIE!" crlf) (printout t " " crlf) (printout t " The Expert System that gives the golf pro's" crlf) (printout t " edge right at your finger tips! Let's go get" crlf) (printout t " them birdies!" crlf) (printout t " " crlf) (printout t " " crlf) (printout t " What is your name? ") (bind ?response (readline)) (assert (user-name (name ?response))) (assert (step-control (step start-2)))) (defrule start-2 ?current-step <- (step-control (step start-2)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " Ok " ?name ", to be able to give you that perfect golf" crlf) (printout t " shot I have to take some information from you about the" crlf) (printout t " golf course. After that, I will need to take some information" crlf) (printout t " from you about your golfing ability. These two steps are one" crlf) (printout t " time only, the golf shots can be recommended to you one after" crlf) (printout t " the other after this initial setup is complete." crlf) (assert (step-control (step gc-desc-1)))) ; (assert (step-control (step gc-player-1)))) ; ; *** defrules - gc desc questions *** ; (defrule gc-desc-1 ?current-step <- (step-control (step gc-desc-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", what is the total length in yards of the" crlf) (printout t " golf course from the tees you will be playing from? ") (bind ?response (read)) (assert (gc-desc-length-ui (value ?response)))) (defrule invalid-gc-desc-length ?test-gc-desc-length <- (gc-desc-length-ui (value ?value)) (test (or (not (integerp ?value)) (<= ?value 5000) (>= ?value 8000))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid yardage. Golf courses are typically between 5800" crlf) (printout t " to 7200 yards. Look on a score card for the total yards." crlf) (retract ?test-gc-desc-length) (assert (step-control (step gc-desc-1)))) (defrule gc-desc-length-short ?test-gc-desc-length <- (gc-desc-length-ui (value ?value)) (test (and (integerp ?value) (> ?value 5000) (<= ?value 6200))) => (retract ?test-gc-desc-length) (assert (gc-desc-length (value short))) (assert (step-control (step gc-desc-2)))) (defrule gc-desc-length-average ?test-gc-desc-length <- (gc-desc-length-ui (value ?value)) (test (and (integerp ?value) (> ?value 6200) (<= ?value 6800))) => (retract ?test-gc-desc-length) (assert (gc-desc-length (value average))) (assert (step-control (step gc-desc-2)))) (defrule gc-desc-length-long ?test-gc-desc-length <- (gc-desc-length-ui (value ?value)) (test (and (integerp ?value) (> ?value 6800) (< ?value 8000))) => (retract ?test-gc-desc-length) (assert (gc-desc-length (value long))) (assert (step-control (step gc-desc-2)))) (defrule gc-desc-2 ?current-step <- (step-control (step gc-desc-2)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", what is the slope rating of the golf course from" crlf) (printout t " the tees you will be playing from? ") (bind ?response (read)) (assert (gc-desc-slope-ui (value ?response)))) (defrule invalid-gc-desc-slope ?test-gc-desc-slope <- (gc-desc-slope-ui (value ?value)) (test (or (not (integerp ?value)) (<= ?value 50) (>= ?value 150))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid slope rating. Golf course slope ratings are typically" crlf) (printout t " between 70 and 140. Look on a score card for the slope rating." crlf) (retract ?test-gc-desc-slope) (assert (step-control (step gc-desc-2)))) (defrule gc-desc-slope-low ?test-gc-desc-slope <- (gc-desc-slope-ui (value ?value)) (test (and (integerp ?value) (> ?value 50) (<= ?value 90))) => (retract ?test-gc-desc-slope) (assert (gc-desc-slope (value low))) (assert (step-control (step gc-desc-3)))) (defrule gc-desc-slope-average ?test-gc-desc-slope <- (gc-desc-slope-ui (value ?value)) (test (and (integerp ?value) (> ?value 90) (<= ?value 115))) => (retract ?test-gc-desc-slope) (assert (gc-desc-slope (value average))) (assert (step-control (step gc-desc-3)))) (defrule gc-desc-slope-high ?test-gc-desc-slope <- (gc-desc-slope-ui (value ?value)) (test (and (integerp ?value) (> ?value 115) (< ?value 150))) => (retract ?test-gc-desc-slope) (assert (gc-desc-slope (value high))) (assert (step-control (step gc-desc-3)))) (defrule gc-desc-3 ?current-step <- (step-control (step gc-desc-3)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", what's the PGA rating of the golf course from " crlf) (printout t " the tees you will be playing from? ") (bind ?response (read)) (assert (gc-desc-pgarate-ui (value ?response)))) (defrule invalid-gc-desc-pgarate ?test-gc-desc-pgarate <- (gc-desc-pgarate-ui (value ?value)) (test (or (not (integerp ?value)) (<= ?value 50) (>= ?value 85))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid PGA rating. Golf course PGA ratings are typically" crlf) (printout t " between 67 and 75. Look on a score card for the PGA rating." crlf) (retract ?test-gc-desc-pgarate) (assert (step-control (step gc-desc-3)))) (defrule gc-desc-pgarate-easy ?test-gc-desc-pgarate <- (gc-desc-pgarate-ui (value ?value)) (test (and (integerp ?value) (> ?value 50) (<= ?value 68))) => (retract ?test-gc-desc-pgarate) (assert (gc-desc-pgarate (value easy)))) (defrule gc-desc-pgarate-average ?test-gc-desc-pgarate <- (gc-desc-pgarate-ui (value ?value)) (test (and (integerp ?value) (> ?value 68) (<= ?value 72))) => (retract ?test-gc-desc-pgarate) (assert (gc-desc-pgarate (value average)))) (defrule gc-desc-pgarate-hard ?test-gc-desc-pgarate <- (gc-desc-pgarate-ui (value ?value)) (test (and (integerp ?value) (> ?value 72) (< ?value 85))) => (retract ?test-gc-desc-pgarate) (assert (gc-desc-pgarate (value hard)))) ; ; *** defrules - gc desc assertions *** ; (defrule gc-desc-easy1 (and (gc-desc-length (value short)) (gc-desc-slope (value low)) (gc-desc-pgarate (value easy))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short without much slope" crlf) (printout t " that allows for easy scoring." crlf) (assert (gc-desc (value easy))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-easy2 (and (gc-desc-length (value average)) (gc-desc-slope (value low)) (gc-desc-pgarate (value easy))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is average distance without" crlf) (printout t " much slope that allows for easy scoring." crlf) (assert (gc-desc (value easy))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-easy3 (and (gc-desc-length (value short)) (gc-desc-slope (value average)) (gc-desc-pgarate (value easy))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short with some slope" crlf) (printout t " that allows for easy scoring." crlf) (assert (gc-desc (value easy))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-easy4 (and (gc-desc-length (value short)) (gc-desc-slope (value low)) (gc-desc-pgarate (value average))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short without much slope" crlf) (printout t " that allows for moderate scoring." crlf) (assert (gc-desc (value easy))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average1 (and (gc-desc-length (value average)) (gc-desc-slope (value average)) (gc-desc-pgarate (value average))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is average distance with" crlf) (printout t " some slope that allows for moderate scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average2 (and (gc-desc-length (value short)) (gc-desc-slope (value average)) (gc-desc-pgarate (value average))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short with some slope" crlf) (printout t " that allows for moderate scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average3 (and (gc-desc-length (value average)) (gc-desc-slope (value low)) (gc-desc-pgarate (value average))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is average distance without" crlf) (printout t " much slope that allows for moderate scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average4 (and (gc-desc-length (value average)) (gc-desc-slope (value average)) (gc-desc-pgarate (value easy))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is average distance with" crlf) (printout t " some slope that allows for easy scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average5 (and (gc-desc-length (value long)) (or (gc-desc-slope (value average)) (gc-desc-slope (value low))) (or (gc-desc-pgarate (value easy)) (gc-desc-pgarate (value average)))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is long with some or" crlf) (printout t " little slope that allows for easy to moderate scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average6 (and (or (gc-desc-length (value short)) (gc-desc-length (value average))) (gc-desc-slope (value high)) (or (gc-desc-pgarate (value easy)) (gc-desc-pgarate (value average)))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short to medium distance" crlf) (printout t " with a lot of slope that allows for easy to moderate scoring." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-average7 (and (or (gc-desc-length (value short)) (gc-desc-length (value average))) (or (gc-desc-slope (value average)) (gc-desc-slope (value low))) (gc-desc-pgarate (value hard))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short to medium distance" crlf) (printout t " with little to some slope that is difficult to score on." crlf) (assert (gc-desc (value average))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-hard1 (and (gc-desc-length (value long)) (gc-desc-slope (value high)) (gc-desc-pgarate (value hard))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is long with alot of slope" crlf) (printout t " that is difficult to score on. This is a challenging golf course." crlf) (assert (gc-desc (value hard))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-hard2 (and (or (gc-desc-length (value short)) (gc-desc-length (value average))) (gc-desc-slope (value high)) (gc-desc-pgarate (value hard))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is short, medium, or long" crlf) (printout t " distance with a lot of slope that is difficult to score on." crlf) (assert (gc-desc (value hard))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-hard3 (and (gc-desc-length (value long)) (or (gc-desc-slope (value average)) (gc-desc-slope (value low))) (gc-desc-pgarate (value hard))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is long with little to" crlf) (printout t " a lot of slope that is difficult to score on." crlf) (assert (gc-desc (value hard))) (assert (step-control (step gc-env-1)))) (defrule gc-desc-hard4 (and (gc-desc-length (value long)) (gc-desc-slope (value high)) (or (gc-desc-pgarate (value average)) (gc-desc-pgarate (value easy)))) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course you are playing is long with alot of slope" crlf) (printout t " that is easy to difficult to score on." crlf) (assert (gc-desc (value hard))) (assert (step-control (step gc-env-1)))) ; ; *** defrules - gc env questions *** ; (defrule gc-env-1 ?current-step <- (step-control (step gc-env-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", is it raining or is the golf course wet from" crlf) (printout t " a recent rain? [yes | no] ") (bind ?response (read)) (assert (gc-env-wet-ui (value ?response)))) (defrule invalid-gc-env-wet ?test-gc-env-wet <- (gc-env-wet-ui (value ?value)) (test (neq ?value yes no)) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid answer. Answer yes or no. Thanks, Golf Course Management!" crlf) (retract ?test-gc-env-wet) (assert (step-control (step gc-env-1)))) (defrule gc-env-wet-true ?test-gc-env-wet <- (gc-env-wet-ui (value ?value)) (test (eq ?value yes)) => (retract ?test-gc-env-wet) (assert (gc-env-raining (value wet)))) (defrule gc-env-wet-false ?test-gc-env-wet <- (gc-env-wet-ui (value ?value)) (test (eq ?value no)) => (retract ?test-gc-env-wet) (assert (step-control (step gc-player-1)))) ; ; *** defrules - gc env assertions *** ; (defrule gc-env-wet (gc-env-raining (value wet)) => (printout t " " crlf) (printout t " " crlf) (printout t " The golf course is wet, take a wide and open stance on your shots" crlf) (printout t " for extra stability. Keep your club grips dry by placing an open" crlf) (printout t " umbrella in the bag. Take your time on your shots." crlf) (assert (gc-env (value wet))) (assert (step-control (step gc-player-1)))) ; ; *** defrules - gc player questions *** ; (defrule gc-player-1 ?current-step <- (step-control (step gc-player-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", what is your golf handicap? If you don't have an" crlf) (printout t " established handicap, simply answer 0 (zero). ") (bind ?response (read)) (assert (gc-player-hndcp-ui (value ?response)))) (defrule invalid-gc-player-hndcp ?test-gc-player-hndcp <- (gc-player-hndcp-ui (value ?value)) (test (or (not (integerp ?value)) (< ?value 0) (> ?value 36))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid handicap. A golf handicap is between 1 and 36. Maybe" crlf) (printout t " you should answer 0 for this one!?" crlf) (retract ?test-gc-player-hndcp) (assert (step-control (step gc-player-1)))) (defrule gc-player-hndcp-high ?test-gc-player-hndcp <- (gc-player-hndcp-ui (value ?value)) (test (and (integerp ?value) (> ?value 20) (<= ?value 36))) => (retract ?test-gc-player-hndcp) (assert (gc-player (value beginner))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-hndcp-medium ?test-gc-player-hndcp <- (gc-player-hndcp-ui (value ?value)) (test (and (integerp ?value) (> ?value 10) (<= ?value 20))) => (retract ?test-gc-player-hndcp) (assert (gc-player (value intermediate))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-hndcp-low ?test-gc-player-hndcp <- (gc-player-hndcp-ui (value ?value)) (test (and (integerp ?value) (> ?value 0) (<= ?value 10))) => (retract ?test-gc-player-hndcp) (assert (gc-player (value pro))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-hndcp-none ?test-gc-player-hndcp <- (gc-player-hndcp-ui (value ?value)) (test (and (integerp ?value) (= ?value 0))) => (retract ?test-gc-player-hndcp) (assert (gc-player-hndcp (value none))) (assert (step-control (step gc-player-2)))) (defrule gc-player-2 ?current-step <- (step-control (step gc-player-2)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", how often do you play golf? Please select the" crlf) (printout t " number associated with how much you play. " crlf) (printout t " " crlf) (printout t " 1. Once a week." crlf) (printout t " 2. Twice or more a week." crlf) (printout t " 3. Once a month." crlf) (printout t " 4. Twice a month." crlf) (printout t " 5. A couple of times each year." crlf) (printout t " 6. Never played golf before." crlf) (printout t " " crlf) (printout t " Selection: ") (bind ?response (read)) (assert (gc-player-play-ui (value ?response)))) (defrule invalid-gc-player-play ?test-gc-player-play <- (gc-player-play-ui (value ?value)) (test (or (not (integerp ?value)) (< ?value 1) (> ?value 6))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid selection. Answer 1, 2, 3, 4, 5, or 6." crlf) (retract ?test-gc-player-play) (assert (step-control (step gc-player-2)))) (defrule gc-player-play-freq ?test-gc-player-play <- (gc-player-play-ui (value ?value)) (test (and (integerp ?value) (or (= ?value 1) (= ?value 2) (= ?value 4)))) => (retract ?test-gc-player-play) (assert (gc-player-play (value freq))) (assert (step-control (step gc-player-3)))) (defrule gc-player-play-infreq ?test-gc-player-play <- (gc-player-play-ui (value ?value)) (test (and (integerp ?value) (or (= ?value 3) (= ?value 5)))) => (retract ?test-gc-player-play) (assert (gc-player-play (value infreq))) (assert (step-control (step gc-player-3)))) (defrule gc-player-play-never ?test-gc-player-play <- (gc-player-play-ui (value ?value)) (test (and (integerp ?value) (= ?value 6))) => (retract ?test-gc-player-play) (assert (gc-player-play (value never))) (assert (step-control (step gc-player-3)))) (defrule gc-player-3 ?current-step <- (step-control (step gc-player-3)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", what is your average score for the last ten times" crlf) (printout t " you have played golf? If you have not played golf ten times, just " crlf) (printout t " average your scores from when you have played. ") (bind ?response (read)) (assert (gc-player-avgscr-ui (value ?response)))) (defrule invalid-gc-player-avgscr ?test-gc-player-avgscr <- (gc-player-avgscr-ui (value ?value)) (test (or (not (integerp ?value)) (< ?value 66) (> ?value 144))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid average score. Let's be honest, an average score can" crlf) (printout t " range between 66 and 144. Give it another shot!" crlf) (retract ?test-gc-player-avgscr) (assert (step-control (step gc-player-3)))) (defrule gc-player-avgscr-less80 ?test-gc-player-avgscr <- (gc-player-avgscr-ui (value ?value)) (test (and (integerp ?value) (>= ?value 66) (< ?value 80))) => (retract ?test-gc-player-avgscr) (assert (gc-player-avgscr (value less80)))) (defrule gc-player-avgscr-btwn80n95 ?test-gc-player-avgscr <- (gc-player-avgscr-ui (value ?value)) (test (and (integerp ?value) (>= ?value 80) (< ?value 95))) => (retract ?test-gc-player-avgscr) (assert (gc-player-avgscr (value btwn80n95)))) (defrule gc-player-avgscr-abv95 ?test-gc-player-avgscr <- (gc-player-avgscr-ui (value ?value)) (test (and (integerp ?value) (>= ?value 95) (<= ?value 144))) => (retract ?test-gc-player-avgscr) (assert (gc-player-avgscr (value abv95)))) ; ; *** defrules - gc player assertions *** ; (defrule gc-player-beginner-1 (and (gc-player-hndcp (value none)) (gc-player-play (value never))) => (printout t " " crlf) (printout t " " crlf) (printout t " You're a beginner golfer. Remember, most importantly, enjoy" crlf) (printout t " your golf game." crlf) (assert (gc-player (value beginner))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-beginner-2 (and (gc-player-hndcp (value none)) (gc-player-play (value infreq)) (gc-player-avgscr (value abv95))) => (printout t " " crlf) (printout t " " crlf) (printout t " You're a beginner golfer. Remember, most importantly, enjoy" crlf) (printout t " your golf game." crlf) (assert (gc-player (value beginner))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-intermediate-1 (and (gc-player-hndcp (value none)) (gc-player-play (value infreq)) (or (gc-player-avgscr (value btwn80n95)) (gc-player-avgscr (value less80)))) => (printout t " " crlf) (printout t " " crlf) (printout t " You're a intermediate golfer. To improve your game, learn from" crlf) (printout t " your mistakes and be patient." crlf) (assert (gc-player (value intermediate))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-intermediate-2 (and (gc-player-hndcp (value none)) (gc-player-play (value freq)) (or (gc-player-avgscr (value btwn80n95)) (gc-player-avgscr (value abv95)))) => (printout t " " crlf) (printout t " " crlf) (printout t " You're a intermediate golfer. To improve your game, learn from" crlf) (printout t " your mistakes and be patient." crlf) (assert (gc-player (value intermediate))) (assert (step-control (step gc-shot-start-1)))) (defrule gc-player-pro-1 (and (gc-player-hndcp (value none)) (gc-player-play (value freq)) (gc-player-avgscr (value less80))) => (printout t " " crlf) (printout t " " crlf) (printout t " You're a pro golfer. I can see you've played this game before." crlf) (printout t " I'll keep the golf advice short and to the point." crlf) (assert (gc-player (value pro))) (assert (step-control (step gc-shot-start-1)))) ; ; *** defrules - gc shot pos questions *** ; (defrule gc-shot-start-1 ?current-step <- (step-control (step gc-shot-start-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " Very good, we are done with that. I have gathered information " crlf) (printout t " about the golf course you're playing, the weather, and your playing " crlf) (printout t " ability. I will use this information to give shot selection advice " crlf) (printout t " to you. " crlf) (printout t " " crlf) (printout t " From this point forward, I will just ask you questions regarding " crlf) (printout t " your current shot. I will give you a shot selection and then be ready " crlf) (printout t " to take information about your next current shot. Let's begin." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-shot-pos-1 ?current-step <- (step-control (step gc-shot-pos-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", Where are you on the golf course? " crlf) (printout t " " crlf) (printout t " 1. Tee" crlf) (printout t " 2. Fairway" crlf) (printout t " 3. Green" crlf) (printout t " 4. Rough" crlf) (printout t " 5. Fringe" crlf) (printout t " 6. Sand Bunker" crlf) (printout t " 7. Trees" crlf) (printout t " 8. Quit CADDIE" crlf) (printout t " " crlf) (printout t " Selection: ") (bind ?response (read)) (assert (gc-shot-pos-ui (value ?response)))) (defrule invalid-gc-shot-pos ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (or (not (integerp ?value)) (< ?value 1) (> ?value 8))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid selection. Answer 1, 2, 3, 4, 5, 6, 7 or 8." crlf) (retract ?test-gc-shot-pos) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-shot-pos-tee ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 1))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value tee))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-fairway ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 2))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value fairway))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-green ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 3))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value green))) (assert (step-control (step gc-shot-dfh-2)))) (defrule gc-shot-pos-rough ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 4))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value rough))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-fringe ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 5))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value fringe))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-sandbunker ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 6))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value sandbunker))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-trees ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 7))) => (retract ?test-gc-shot-pos) (assert (gc-shot-pos (value trees))) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-pos-quit ?test-gc-shot-pos <- (gc-shot-pos-ui (value ?value)) (test (and (integerp ?value) (= ?value 8))) => (retract ?test-gc-shot-pos) (assert (step-control (step gc-quit)))) (defrule gc-shot-dfh-1 ?current-step <- (step-control (step gc-shot-dfh-1)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " In yards, how far are you from the green? If you do not have" crlf) (printout t " a clear shot to the green, because of a dogleg, etc., how many yards" crlf) (printout t " are available for a clear, unobstructed shot? ") (bind ?response (read)) (assert (gc-shot-dfh-ui (value ?response)))) (defrule invalid-gc-shot-dfh-1 ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (or (not (integerp ?value)) (<= ?value 1) (>= ?value 700))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid distance. Try again." crlf) (retract ?test-gc-shot-dfh) (assert (step-control (step gc-shot-dfh-1)))) (defrule gc-shot-dfh-less10y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (> ?value 1) (< ?value 10))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value less10y)))) (defrule gc-shot-dfh-10y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 10) (< ?value 20))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 10y)))) (defrule gc-shot-dfh-20y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 20) (< ?value 30))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 20y)))) (defrule gc-shot-dfh-30y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 30) (< ?value 40))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 30y)))) (defrule gc-shot-dfh-40y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 40) (< ?value 50))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 40y)))) (defrule gc-shot-dfh-50y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 50) (< ?value 60))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 50y)))) (defrule gc-shot-dfh-60y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 60) (< ?value 70))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 60y)))) (defrule gc-shot-dfh-70y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 70) (< ?value 80))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 70y)))) (defrule gc-shot-dfh-80y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 80) (< ?value 90))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 80y)))) (defrule gc-shot-dfh-90y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 90) (< ?value 100))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 90y)))) (defrule gc-shot-dfh-100y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 100) (< ?value 110))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 100y)))) (defrule gc-shot-dfh-110y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 110) (< ?value 120))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 110y)))) (defrule gc-shot-dfh-120y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 120) (< ?value 130))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 120y)))) (defrule gc-shot-dfh-130y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 130) (< ?value 140))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 130y)))) (defrule gc-shot-dfh-140y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 140) (< ?value 150))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 140y)))) (defrule gc-shot-dfh-150y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 150) (< ?value 160))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 150y)))) (defrule gc-shot-dfh-160y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 160) (< ?value 170))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 160y)))) (defrule gc-shot-dfh-170y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 170) (< ?value 180))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 170y)))) (defrule gc-shot-dfh-180y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 180) (< ?value 190))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 180y)))) (defrule gc-shot-dfh-190y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 190) (< ?value 200))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 190y)))) (defrule gc-shot-dfh-200y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 200) (< ?value 210))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 200y)))) (defrule gc-shot-dfh-210y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 210) (< ?value 220))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 210y)))) (defrule gc-shot-dfh-220y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 220) (< ?value 230))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 220y)))) (defrule gc-shot-dfh-230y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 230) (< ?value 240))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 230y)))) (defrule gc-shot-dfh-240y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 240) (< ?value 250))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 240y)))) (defrule gc-shot-dfh-250y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 250) (< ?value 260))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 250y)))) (defrule gc-shot-dfh-abv250y ?test-gc-shot-dfh <- (gc-shot-dfh-ui (value ?value)) (test (and (integerp ?value) (>= ?value 260) (< ?value 700))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value abv250y)))) (defrule gc-shot-dfh-2 ?current-step <- (step-control (step gc-shot-dfh-2)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " In feet, how far are you from the hole? ") (bind ?response (read)) (assert (gc-shot-dfh-ui2 (value ?response)))) (defrule invalid-gc-shot-dfh-2 ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (or (not (integerp ?value)) (< ?value 1) (> ?value 200))) => (printout t " " crlf) (printout t " " crlf) (printout t " Invalid distance. Try again." crlf) (retract ?test-gc-shot-dfh) (assert (step-control (step gc-shot-dfh-2)))) (defrule gc-shot-dfh-less5f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 1) (< ?value 5))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value less5f)))) (defrule gc-shot-dfh-5f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 5) (< ?value 10))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 5f)))) (defrule gc-shot-dfh-10f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 10) (< ?value 15))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 10f)))) (defrule gc-shot-dfh-15f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 15) (< ?value 20))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 15f)))) (defrule gc-shot-dfh-20f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 20) (< ?value 25))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 20f)))) (defrule gc-shot-dfh-25f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 25) (< ?value 30))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value 25f)))) (defrule gc-shot-dfh-abv25f ?test-gc-shot-dfh <- (gc-shot-dfh-ui2 (value ?value)) (test (and (integerp ?value) (>= ?value 30) (< ?value 200))) => (retract ?test-gc-shot-dfh) (assert (gc-shot-dfh (value abv25f)))) ; ; golf shot recommendations ; (defrule gc-rec-1w (and (gc-shot-pos (value tee)) (or (gc-shot-dfh (value 230y)) (gc-shot-dfh (value 240y)) (gc-shot-dfh (value 250y)) (gc-shot-dfh (value abv250y))) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " You have been on the tee before. Use your experience to" crlf) (printout t " your advantage. Play your one wood with a full swing. There" crlf) (printout t " is a lot of yardage to cover so don't hold back!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-3w (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway))) (or (gc-shot-dfh (value 210y)) (gc-shot-dfh (value 220y))) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " This shot requires your three wood. Shots from this" crlf) (printout t " distance can be trickey because there is the danger of hitting" crlf) (printout t " the ball too far. Use a full swing and no more." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-5w-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway))) (gc-shot-dfh (value 200y)) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Well, for this shot use your five wood. If your target" crlf) (printout t " is uphill, you may want to consider using your three wood instead." crlf) (printout t " In either case, take a full swing and aim dead on to the target." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-5w-2 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway))) (or (gc-shot-dfh (value 190y)) (gc-shot-dfh (value 200y)) (gc-shot-dfh (value 210y)) (gc-shot-dfh (value 220y)) (gc-shot-dfh (value 230y)) (gc-shot-dfh (value 240y)) (gc-shot-dfh (value 250y)) (gc-shot-dfh (value abv250y))) (gc-player (value beginner))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Ok rookie, you have got a lot of yardage in front of you." crlf) (printout t " Use your five wood and take a full swing and follow through" crlf) (printout t " the ball. Don't swing overly aggressive, instead swing freely" crlf) (printout t " through the ball. Aim at your target by visualizing a line from" crlf) (printout t " your ball to your target. Don't use your one or three wood because" crlf) (printout t " those clubs are more difficult to hit. You'll get more yardage" crlf) (printout t " with your five wood." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-3i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 190y)) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " This shot requires a long iron. Use your three iron and take" crlf) (printout t " a full swing. Long irons are sensitive clubs and require carefully" crlf) (printout t " attention to a properly executed swing. But you know that already." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-3i-2 (and (gc-shot-pos (value rough)) (or (gc-shot-dfh (value 200y)) (gc-shot-dfh (value 210y)) (gc-shot-dfh (value 220y)) (gc-shot-dfh (value 230y)) (gc-shot-dfh (value 240y)) (gc-shot-dfh (value 250y)) (gc-shot-dfh (value abv250y))) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Your in the rough and far from your target. Take the safe" crlf) (printout t " shot. Use your three iron and take a full swing. If the rough" crlf) (printout t " is long, you will need to power through the ball by coming out" crlf) (printout t " of your swing (and out of your shoes) on your follow-threw for" crlf) (printout t " extra power. If you need to do this, aim clear of any hazards" crlf) (printout t " because the ball can come out hot and off course if not struck" crlf) (printout t " perfectly." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-3i-3 (gc-shot-pos (value trees)) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Your in the trees. You will need to "punch" the ball out" crlf) (printout t " back onto the fairway or the green. Use your three iron and take" crlf) (printout t " a punch swing. To execute a punch swing, grip down on the shaft" crlf) (printout t " and take an abbreviated yet swift swing through the ball towards" crlf) (printout t " your target. The ball will come off the club head low and fast." crlf) (printout t " Aim at your target considering that the ball will be rolling towards" crlf) (printout t " it. Good Luck!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-4i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 180y)) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " A long iron shot can make or break par. When aiming at" crlf) (printout t " your target, consider where you want the ball to land knowing" crlf) (printout t " that a long iron shot will roll the ball forward several yards." crlf) (printout t " For this distance use your four iron and take a full swing." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-5i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 170y)) (or (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " From this distance use a five iron and take a full swing." crlf) (printout t " This distance is still a lengthy shot, especially if there is a" crlf) (printout t " water hazard in play. Aim dead on your target and play the fade" crlf) (printout t " or draw if needed. The five iron is one of those clubs that allow" crlf) (printout t " the player to be creative." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-5i-2 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 170y)) (gc-shot-dfh (value 180y))) (gc-player (value beginner))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " REC: 5i-2, t|f|r, 170|180, beg" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-5i-3 (and (gc-shot-pos (value rough)) (or (gc-shot-dfh (value 190y)) (gc-shot-dfh (value 200y)) (gc-shot-dfh (value 210y)) (gc-shot-dfh (value 220y)) (gc-shot-dfh (value 230y)) (gc-shot-dfh (value 240y)) (gc-shot-dfh (value 250y)) (gc-shot-dfh (value abv250y))) (gc-player (value beginner))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Ok rookie, your in the rough but do not despair. At least" crlf) (printout t " your not in the trees! Play the safe shot and don't try too hard." crlf) (printout t " Aim for the fairway, your still a good distance from the green so" crlf) (printout t " don't even think about it. Take a full swing and make sure to make" crlf) (printout t " solid contact with the ball. The ball may come out low and fast, plan" crlf) (printout t " for this when you aim. Use your five iron." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-6i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 160y)) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your six iron from this distance. Take dead aim and go" crlf) (printout t " for the green! The approach shot can make or break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-7i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 150y)) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your seven iron from this distance. Take dead aim and go" crlf) (printout t " for the green! The approach shot can make or break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-8i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (gc-shot-dfh (value 140y)) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your eight iron from this distance. Take dead aim and go" crlf) (printout t " for the green! The approach shot can make or break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-9i-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 110y)) (gc-shot-dfh (value 120y)) (gc-shot-dfh (value 130y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your nine iron from this distance. Take dead aim and go" crlf) (printout t " for the green! The approach shot can make or break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-pw-1 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 90y)) (gc-shot-dfh (value 100y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your pitching wedge with a full swing from this distance." crlf) (printout t " Take dead aim and go for the green! The approach shot can make or" crlf) (printout t " break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-pw-2 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 70y)) (gc-shot-dfh (value 80y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your pitching wedge with a three-quarter swing from this distance." crlf) (printout t " Take dead aim and go for the green! The approach shot can make or" crlf) (printout t " break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-pw-3 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 50y)) (gc-shot-dfh (value 60y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your pitching wedge with a one-half swing from this distance." crlf) (printout t " Take dead aim and go for the green! The approach shot can make or" crlf) (printout t " break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-pw-4 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value 20y)) (gc-shot-dfh (value 30y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your pitching wedge with a one-quarter swing from this distance." crlf) (printout t " Take dead aim and go for the green! The approach shot can make or" crlf) (printout t " break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-pw-5 (and (or (gc-shot-pos (value tee)) (gc-shot-pos (value fairway)) (gc-shot-pos (value rough))) (or (gc-shot-dfh (value less10y)) (gc-shot-dfh (value 10y)) (gc-shot-dfh (value 20y))) (or (gc-player (value beginner)) (gc-player (value intermediate)) (gc-player (value pro)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Use your pitching wedge with a one-quarter swing from this distance." crlf) (printout t " Take dead aim and go for the hole! The approach shot can make or" crlf) (printout t " break par!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-ptr-1 (and (gc-shot-pos (value green)) (gc-shot-dfh (value less5f))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " On the green with only a short putt left. Don't be careless," crlf) (printout t " these short putts can be missed. Make sure to pay attention to the" crlf) (printout t " break of the green. Whatever you do, don't leave the ball short of" crlf) (printout t " the hole. No putt will go in if it never gets to the hole!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-ptr-2 (and (gc-shot-pos (value green)) (or (gc-shot-dfh (value 5f)) (gc-shot-dfh (value 10f)) (gc-shot-dfh (value 15f)) (gc-shot-dfh (value 20f)) (gc-shot-dfh (value 25f)))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " On the green with a middle distance putt. Be carefull to find" crlf) (printout t " the break of the green. Aim enough outside the hole to the left or" crlf) (printout t " right to cover the break. Most middle distance putts are missed because" crlf) (printout t " not enough break was taken. Don't be stingy when aiming to cover the break." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-ptr-3 (and (gc-shot-pos (value green)) (gc-shot-dfh (value abv25f))) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " This putt is in another area code! This is a LONG putt. With a" crlf) (printout t " long putt, try and lag the ball close to the hole. Try and leave yourself" crlf) (printout t " with a putt that you can easily make. One long putt is enough!" crlf) (printout t " As with any putt, find the break of the green. Also, pay attention to" crlf) (printout t " the speed of the greens and play enough power to get the ball close. Good Luck!" crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-frng (gc-shot-pos (value fringe)) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " Chip shots from the fringe of the green can go in the hole" crlf) (printout t " when properly executed. Use your pitching wedge and chip the ball" crlf) (printout t " onto the green. To execute a chip shot, keep your wrists and arms" crlf) (printout t " firm and follow threw the ball as if you were putting. Judge how" crlf) (printout t " much back swing is required based on your distance from the hole" crlf) (printout t " and if the hole is above or below your feet. Make sure to play the" crlf) (printout t " break of the green just like you would a putt." crlf) (assert (step-control (step gc-shot-pos-1)))) (defrule gc-rec-sw (gc-shot-pos (value sandbunker)) ?fact-gc-shot-pos <- (gc-shot-pos (value ?pos-value)) ?fact-gc-shot-dfh <- (gc-shot-dfh (value ?dfh-value)) => (retract ?fact-gc-shot-pos) (retract ?fact-gc-shot-dfh) (printout t " " crlf) (printout t " " crlf) (printout t " CADDIE SHOT RECOMMENDATION:" crlf) (printout t " " crlf) (printout t " In the sand bunker! From a green side bunker, use your sand wedge" crlf) (printout t " with a full swing if more than 10 yards from the hole. Adjust your swing" crlf) (printout t " accordingly if your closer. If in a fairway bunker, club up two clubs from" crlf) (printout t " a normal fairway shot from the same distance. Most importantly, make sure you" crlf) (printout t " have good footing in the bunker. Also, don't let your club head touch the sand" crlf) (printout t " until you actual swing at the ball otherwise this is a one stroke penalty!" crlf) (assert (step-control (step gc-shot-pos-1)))) ; ; *** defrules - quit CADDIE *** ; (defrule gc-quit ?current-step <- (step-control (step gc-quit)) (user-name (name ?name)) => (retract ?current-step) (printout t " " crlf) (printout t " " crlf) (printout t " " ?name ", Thanks for using CADDIE! Remember to keep your" crlf) (printout t " head down and follow through the ball! Good Luck!" crlf) (printout t " " crlf) (printout t " " crlf))