-
Notifications
You must be signed in to change notification settings - Fork 1
/
ScientificJurySelectionFinal.clp
804 lines (695 loc) · 23.8 KB
/
ScientificJurySelectionFinal.clp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
;**************************************************
; file: ScientificJurySelection.clp
; description: An expert system that uses social science techniques
; and expertise to choose
; favorable jurors during a criminal or civil trial.
;********************************************
;*******************
;DEFTEMPLATES
;*******************
;TEMPLATE: The characteristics fact specifies the options you can input
;we left possible ones commented out incase we want to add them in at a later date
(deftemplate characteristics
(slot gender) ; gender
(slot income) ; income category
(slot education) ; education level
(slot religion) ; religion practiced
(slot sexual_orientation) ; which side they like
(slot occupation) ; working society class
(slot lifestyle) ; how they live
(slot age) ; which age category
(slot marital_status) ; state recognized marital status
(slot living_situation) ; housing situation
;(slot siblings) ; brothers, sisters, & how many
;(slot smokers) ; smoke or not
;(slot transportation) ; vehicle you own
;(slot clothing) ;category
;(slot size_of_family) ; size of your family
;(slot pets) ; pets & how many
;(slot criminal_record) ; history of past charges
;(slot car_type) ; type of car you drive
;(slot body) ; body type
)
;TEMPLATE: How many potential jurors
(deftemplate option
(slot number) ; How many potential jurors
)
;****************************
;DEFGLOBALS
;****************************
;GLOBAL VARIABLE: help track the inputed data throughout for the weighted value
(defglobal ?*gray-code* = 0)
(defglobal ?*tally-code* = 0)
(defglobal ?*presentage-code* = 0)
;*******************
;DEFFACTS
;*******************
;FACT: init_facts will be the first fact always
(deffacts init_facts
(task user_prompt) ; this will trigger menu to be printed
)
;*********************
;RULES
;********************
;RULE: jurors is the first prompt you will see asking how many potential jurors
(defrule jurors
?f1 <- (task user_prompt)
=>
(printout t "What characteristics do you want:" crlf)
(printout t "#1 Gender:" crlf)
(printout t "#2 Income:" crlf)
(printout t "#3 Education:" crlf)
(printout t "#4 Religion:" crlf)
(printout t "#5 Sexual Orientation:" crlf)
(printout t "#6 Occupation:" crlf)
(printout t "#7 Lifestyle:" crlf)
(printout t "#8 Age:" crlf)
(printout t "#9 Material Status:" crlf)
(printout t "#10 Living Situation:" crlf)
(printout t "#11 No more characteristics:" crlf)
(assert (option (number (read)))) ; stores the user's selection
(assert (task need_to_check)) ;asserts the validity check
(retract ?f1)
)
;RULE: check to see if inputed juror option makes sense
(defrule check_juror_option_validity
?f1 <- (task need_to_check)
?f2 <- (option (number ?input))
(test (or (not (integerp ?input)) ;default in clips to check if integer or not: integerp
(< ?input 1)
(> ?input 11)
))
=>
(printout t crlf crlf crlf "Invalid ammount of potential Jurors. Please try again." crlf crlf)
(retract ?f1)
(retract ?f2)
(assert (task user_prompt)); brings you back to user prompt if not a valid option
)
;RULE: end-program
(defrule end-program ;rule to end program from the prompt
(option (number 11))
=>
(bind ?percentage (/ ?*tally-code* ?*gray-code*)) ; does the statistical straight-line percentage
(printout t "The likelyhood of this person voting guilty (closer to 0) or innocent(closer to 100) " ?percentage crlf);prints out the likelyhood of the verdict to the user
(printout t "Ending" crlf)
(halt) ;ends the program again
)
;RULE: ask-prompt-again
(defrule ask-prompt-again ;allows for loop of the characteristics
?f1 <- (task ask-again) ; sets the task as a fact
=>
(printout t "Are there more characteristics you need to list \(y for yes, n for no\)?" crlf) ;asks if there are more transactions requires y for yes n for no
(bind ?answer (read)) ; sets the value to answer
(assert (ask-again ?answer)) ; sets the answer as a fact
(retract ?f1)
)
;RULE: end-program
(defrule end-program1 ;rule to end program from ask again
(ask-again n)
=>
(bind ?percentage (/ ?*tally-code* ?*gray-code*)) ; does the statistical analysis
(printout t "The likelyhood of this person voting guilty (closer to 0) or innocent(closer to 100) " ?percentage crlf); prints out to the user the likelyhood of the verdict
(halt); ends the program
)
;RULE: redo-program
(defrule redo-program ;rule to ask the main menu again
?f80<- (ask-again y); if ask again is yes then this fires
=>
(retract ?f80) ;retracts the rule
(assert (task user_prompt)) ; fires the menu
)
;RULE: gender
(defrule gender ;rule to add statistical data for gender
(option (number 1)) ; fires if the user selects option 1
=>
(printout t "Please enter the gender:" crlf); prints out to the user the gender menu
(printout t "#1 Male:" crlf)
(printout t "#2 Female:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (gender ?answer))) ; stores the user's selection
)
;RULE: male
(defrule male ;rule to to add the statistical analysis for the male classification
(characteristics (gender 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 80))
(assert (task ask-again))
)
;RULE: female
(defrule female ;rule to to add the statistical analysis for the female classification
(characteristics (gender 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 40))
(assert (task ask-again))
)
;RULE: income
(defrule income ;prints out to the user the income level menu
(option (number 2))
=>
(printout t "Please enter the income:" crlf); prints out to the user the income level menu
(printout t "#1 lower:" crlf)
(printout t "#2 middle:" crlf)
(printout t "#3 upper:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (income ?answer))) ; stores the user's selection
)
;RULE: lower-income
(defrule lower-income ;rule to to add the statistical analysis for the low income classification
(characteristics (income 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 95))
(assert (task ask-again))
)
;RULE: middle-income
(defrule middle-income ;rule to to add the statistical analysis for the middle income classification
(characteristics (income 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 40))
(assert (task ask-again))
)
;RULE: upper-income
(defrule upper-income ;rule to to add the statistical analysis for the upper income classification
(characteristics (income 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 5))
(assert (task ask-again))
)
;RULE: education
(defrule education ; prints out to the user the education level menu
(option (number 3))
=>
(printout t "Please enter the education level:" crlf)
(printout t "#1 some high school:" crlf)
(printout t "#2 high school or equivalant:" crlf)
(printout t "#3 some college:" crlf)
(printout t "#4 associates degree:" crlf)
(printout t "#5 bachlors degree:" crlf)
(printout t "#6 masters degree:" crlf)
(printout t "#7 certification of advanced study:" crlf)
(printout t "#8 doctorate:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (education ?answer))) ; stores the user's selection
)
;RULE: some-high-school
(defrule some-high-school ;rule to to add the statistical analysis for the some high school classification
(characteristics (education 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 100))
(assert (task ask-again))
)
;RULE: high-school
(defrule high-school ;rule to to add the statistical analysis for the high school classification
(characteristics (education 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 87.6))
(assert (task ask-again))
)
;RULE: some-college
(defrule some-college ;rule to to add the statistical analysis for the some college classification
(characteristics (education 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 75.2))
(assert (task ask-again))
)
;RULE: associates-degree
(defrule associates-degree ;rule to to add the statistical analysis for the associates classification
(characteristics (education 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 62.8))
(assert (task ask-again))
)
;RULE: bachlors-degree
(defrule bachlors-degree ;rule to to add the statistical analysis for the bacholors degree classification
(characteristics (education 5))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50.4))
(assert (task ask-again))
)
;RULE: masters-degree
(defrule masters-degree ;rule to to add the statistical analysis for the masters degree classification
(characteristics (education 6))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 38))
(assert (task ask-again))
)
;RULE: advanced-study
(defrule advanced-study ;rule to to add the statistical analysis for the advanced study classification
(characteristics (education 7))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 25.6))
(assert (task ask-again))
)
;RULE: doctorate
(defrule doctorate ;rule to to add the statistical analysis for the doctorate classification
(characteristics (education 8))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 13.2))
(assert (task ask-again))
)
;RULE: religion
(defrule religion ; prints out to the user the religious affiliation menu
(option (number 4))
=>
(printout t "Please enter the religious affiliation:" crlf)
(printout t "#1 Christianity:" crlf)
(printout t "#2 Islam:" crlf)
(printout t "#3 Unaffiliated:" crlf)
(printout t "#4 Hinduism:" crlf)
(printout t "#5 Buddhism:" crlf)
(printout t "#6 Folk religions:" crlf)
(printout t "#7 Other:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (religion ?answer))) ; stores the user's selection
)
;RULE: christianity:
(defrule christianity ;rule to to add the statistical analysis for the christianity classification
(characteristics (religion 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: islam
(defrule islam ;rule to to add the statistical analysis for the islam classification
(characteristics (religion 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 30))
(assert (task ask-again))
)
;RULE: unaffiliated
(defrule unaffiliated ;rule to to add the statistical analysis for the unaffiliated classification
(characteristics (religion 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: hinduism
(defrule hinduism ;rule to to add the statistical analysis for the hinduism classification
(characteristics (religion 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 14))
(assert (task ask-again))
)
;RULE: buddhism
(defrule buddhism ;rule to to add the statistical analysis for the buddhism classification
(characteristics (religion 5))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 75))
(assert (task ask-again))
)
;RULE: folk
(defrule folk ;rule to to add the statistical analysis for the folk classification
(characteristics (religion 6))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 43))
(assert (task ask-again))
)
;RULE: other
(defrule other ;rule to to add the statistical analysis for the other classification
(characteristics (religion 7))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: sexual-oriantation
(defrule sexual-oriantation ; prints out to the user the sexual oriantation menu
(option (number 5))
=>
(printout t "Please enter the sexual oriantation:" crlf)
(printout t "#1 Straight" crlf)
(printout t "#2 Gay:" crlf)
(printout t "#3 Lesbian:" crlf)
(printout t "#4 Bi-sexual:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (sexual_orientation ?answer))) ; stores the user's selection
)
;RULE: straight:
(defrule straight ;rule to to add the statistical analysis for the straight classification
(characteristics (sexual_orientation 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: gay
(defrule gay ;rule to to add the statistical analysis for the gay classification
(characteristics (sexual_orientation 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: lesbian
(defrule lesbian ;rule to to add the statistical analysis for the lesbian classification
(characteristics (sexual_orientation 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: bi-curious
(defrule bi-curious ;rule to to add the statistical analysis for the bi-curiouse classification
(characteristics (sexual_orientation 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: occupation
(defrule occupation ; prints out to the user the occupation level menu
(option (number 6))
=>
(printout t "Please enter the Occupation:" crlf)
(printout t "#1 White-collar" crlf)
(printout t "#2 Blue-collar:" crlf)
(printout t "#3 Farmer:" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (occupation ?answer))) ; stores the user's selection
)
;RULE: white-collar:
(defrule white-collar ;rule to to add the statistical analysis for the white collar classification
(characteristics (occupation 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: blue-collar
(defrule blue-collar ;rule to to add the statistical analysis for the blue collar classification
(characteristics (occupation 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: farmer
(defrule farmer ;rule to to add the statistical analysis for the farmer classification
(characteristics (occupation 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: lifestyle
(defrule lifestyle ; prints out to the user the lifestyle option menu
(option (number 7))
=>
(printout t "Please enter the lifestyle:" crlf)
(printout t "#1 Athletic" crlf)
(printout t "#2 Business" crlf)
(printout t "#3 Goth" crlf)
(printout t "#4 Emo" crlf)
(printout t "#5 Nerd" crlf)
(printout t "#6 Overweight" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (lifestyle ?answer))) ; stores the user's selection
)
;RULE: athletic:
(defrule athletic ;rule to to add the statistical analysis for the athletic classification
(characteristics (lifestyle 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: business
(defrule business ;rule to to add the statistical analysis for the business classification
(characteristics (lifestyle 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: goth
(defrule goth ;rule to to add the statistical analysis for the goth classification
(characteristics (lifestyle 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: emo
(defrule emo ;rule to to add the statistical analysis for the emo classification
(characteristics (lifestyle 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: nerd
(defrule nerd ;rule to to add the statistical analysis for the nerd classification
(characteristics (lifestyle 5))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: overweight
(defrule overweight ;rule to to add the statistical analysis for the overweight classification
(characteristics (lifestyle 6))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: age
(defrule age ; prints out to the user the age group menu
(option (number 8))
=>
(printout t "Please enter the age group:" crlf)
(printout t "#1 Ages 18-25" crlf)
(printout t "#2 Ages 26-30" crlf)
(printout t "#3 Ages 31-35" crlf)
(printout t "#4 Ages 36-40" crlf)
(printout t "#5 Ages 41-45" crlf)
(printout t "#6 Ages 46-50" crlf)
(printout t "#7 Ages 51-55" crlf)
(printout t "#8 Ages 56-60" crlf)
(printout t "#9 Ages 61-65" crlf)
(printout t "#10 Ages 66-70" crlf)
(printout t "#11 Ages 71-75" crlf)
(printout t "#12 Ages 76-80" crlf)
(printout t "#13 Ages 81-85" crlf)
(printout t "#14 Ages 86-90" crlf)
(printout t "#15 Ages 91-95" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (age ?answer))) ; stores the user's selection
)
;RULE: ages-18-25:
(defrule ages-18-25 ;rule to to add the statistical analysis for the ages 18-25 classification
(characteristics (age 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-26-30
(defrule ages-26-30 ;rule to to add the statistical analysis for the ages 26 - 30 classification
(characteristics (age 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-31-35
(defrule ages-31-35 ;rule to to add the statistical analysis for the ages 31-35 classification
(characteristics (age 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-36-40
(defrule ages-36-40 ;rule to to add the statistical analysis for the ages 36-40 classification
(characteristics (age 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-41-45
(defrule ages-41-45 ;rule to to add the statistical analysis for the ages 41-45 classification
(characteristics (age 5))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-46-50
(defrule ages-46-50 ;rule to to add the statistical analysis for the ages 46-50 classification
(characteristics (age 6))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-51-55
(defrule ages-51-55 ;rule to to add the statistical analysis for the ages 51-55 classification
(characteristics (age 7))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-56-60
(defrule ages-56-60 ;rule to to add the statistical analysis for the ages 56-50 classification
(characteristics (age 8))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-61-65
(defrule ages-61-65 ;rule to to add the statistical analysis for the ages 61-65 classification
(characteristics (age 9))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-66-70
(defrule ages-66-70 ;rule to to add the statistical analysis for the ages 66-70 classification
(characteristics (age 10))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-71-75
(defrule ages-71-75 ;rule to to add the statistical analysis for the ages 71-75 classification
(characteristics (age 11))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-76-80
(defrule ages-76-80 ;rule to to add the statistical analysis for the ages 76-80 classification
(characteristics (age 12))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-81-85
(defrule ages-81-85 ;rule to to add the statistical analysis for the ages 81-85 classification
(characteristics (age 13))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-86-90
(defrule ages-86-90 ;rule to to add the statistical analysis for the ages 86-90 classification
(characteristics (age 14))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: ages-91-95
(defrule ages-91-95 ;rule to to add the statistical analysis for the ages 91-95 classification
(characteristics (age 15))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: material-status
(defrule material-status ; prints out to the user the material status menu
(option (number 9))
=>
(printout t "Please enter the lifestyle:" crlf)
(printout t "#1 Single" crlf)
(printout t "#2 Married" crlf)
(printout t "#3 Seperated" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (marital_status ?answer))) ; stores the user's selection
)
;RULE: single:
(defrule single ;rule to to add the statistical analysis for the single classification
(characteristics (marital_status 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: married
(defrule married ;rule to to add the statistical analysis for the married classification
(characteristics (marital_status 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: seperated
(defrule seperated ;rule to to add the statistical analysis for the seperated classification
(characteristics (marital_status 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: living-situation
(defrule living-situation ; prints out to the user the living situations menu
(option (number 10))
=>
(printout t "Please enter the Living Situation:" crlf)
(printout t "#1 Rent" crlf)
(printout t "#2 Homeless" crlf)
(printout t "#3 Own" crlf)
(printout t "#4 Financed" crlf)
(bind ?answer (read)) ; sets the value to answer
(assert (characteristics (living_situation ?answer))) ; stores the user's selection
)
;RULE: rent:
(defrule rent ;rule to to add the statistical analysis for the rent classification
(characteristics (living_situation 1))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: homeless
(defrule homeless;rule to to add the statistical analysis for the homeless classification
(characteristics (living_situation 2))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: own
(defrule own ;rule to to add the statistical analysis for the own classification
(characteristics (living_situation 3))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)
;RULE: financed
(defrule financed ;rule to to add the statistical analysis for the financed classification
(characteristics (living_situation 4))
=>
(bind ?*gray-code* (+ ?*gray-code* 1))
(bind ?*tally-code* (+ ?*tally-code* 50))
(assert (task ask-again))
)