home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
hc
/
hyperx11.sit
/
HyperX
/
stack.txt
< prev
Wrap
Text File
|
1988-02-25
|
7KB
|
219 lines
-- stack: in
-- format: 8 (HyperCard 1)
-- flags: 0x0 (none)
-- protect password hash: 0
-- maximum user level: 5 (scripting)
-- window: Rect(x1=0, y1=0, x2=0, y2=0)
-- screen: Rect(x1=0, y1=0, x2=0, y2=0)
-- card dimensions: w=0 h=0
-- scroll: x=0 y=0
-- background count: 5
-- first background id: 2636
-- card count: 44
-- first card id: 3058
-- list block id: 2246
-- print block id: 3652
-- font table block id: 0
-- style table block id: 0
-- free block count: 21
-- free size: 15776 bytes
-- total size: 122880 bytes
-- stack block size: 6144 bytes
-- created by hypercard version: 0x00000000
-- compacted by hypercard version: 0x00000000
-- modified by hypercard version: 0x00000000
-- opened by hypercard version: 0x00000000
-- patterns[0]: 0x0000000000000000
-- patterns[1]: 0x8000000008000000
-- patterns[2]: 0x8800220088002200
-- patterns[3]: 0x8888222288882222
-- patterns[4]: 0x88AA22AA88AA22AA
-- patterns[5]: 0xCCAA33AACCAA33AA
-- patterns[6]: 0xEEAABBAAEEAABBAA
-- patterns[7]: 0xEEBBBBEEEEBBBBEE
-- patterns[8]: 0xFFBBFFEEFFBBFFEE
-- patterns[9]: 0xFFBBFFFFFFBBFFFF
-- patterns[10]: 0x8010022001084004
-- patterns[11]: 0xFFFFFFFFFFFFFFFF
-- patterns[12]: 0x8822882288228822
-- patterns[13]: 0x1122448811224488
-- patterns[14]: 0xC4800C6843023026
-- patterns[15]: 0xB130031BD8C00C8D
-- patterns[16]: 0xAA00AA00AA00AA00
-- patterns[17]: 0x8822552288225522
-- patterns[18]: 0x8855225588552255
-- patterns[19]: 0x77DD77DD77DD77DD
-- patterns[20]: 0x8000000000000000
-- patterns[21]: 0xAA55AA55AA55AA55
-- patterns[22]: 0x038448300C020101
-- patterns[23]: 0x8244394482010101
-- patterns[24]: 0x8814224188412214
-- patterns[25]: 0x8080413E080814E3
-- patterns[26]: 0x22048C7422179810
-- patterns[27]: 0xBE808808EB088880
-- patterns[28]: 0x25C8328964244C92
-- patterns[29]: 0xA29C41BE2AC914EB
-- patterns[30]: 0x40A00000040A0000
-- patterns[31]: 0x8040200002040800
-- patterns[32]: 0xAA00800088008000
-- patterns[33]: 0xFF80808080808080
-- patterns[34]: 0x081C22C180010204
-- patterns[35]: 0xFF808080FF080808
-- patterns[36]: 0xF87422478F172271
-- patterns[37]: 0xBF00BFBFB0B0B0B0
-- patterns[38]: 0xFF7FBE5DA2418000
-- patterns[39]: 0xFAF5FAF5A050A050
-- checksum: 0x0
----- HyperTalk script -----
-------------------------------
-- HyperX inference engine --
-- Written by Ron Evans --
-- ©1987 All Rights Reserved --
-- Leave this notice intact --
-------------------------------
on openStack
hide menuBar
go card "Title"
push this card
visual effect dissolve
go to card "HyperX Info"
end openStack
on arrowKey
pass arrowKey
end arrowKey
function testFact theFact
push this card
visual effect barn door close
go card "smart"
put "Testing Fact..." into card field "Status"
show card field "Status"
put find(card field "Facts",theFact) into theResult
put item 1 of theResult into theLIne
if theLine <> 0
then put item 2 of line theLine of card field "Facts" into theResult
else put empty into theResult
visual effect barn door open
pop card
return theResult
end testFact
function testRule theRule
push this card
visual effect barn door close
go card "Smart"
put "Testing Rule..." into card field "Status"
show card field "Status"
put find(card field "Rules",theRule) into theResult
put item 1 of theResult into theLine
if theLine <> 0
then put item 2 of line theLine of card field "Rules" into theResult
else put empty into theResult
visual effect barn door open
pop card
return theResult
end testRule
function forChain theFact
put empty into theResult
put empty into theList
put card field "Rules" of card "Smart" into theList
put "Forward Chaining..." into card field "Status" of card "Smart"
go card "Rule 1"
repeat with thisRule=1 to card field "Rule Count" of card "Smart"
visual effect scroll left very fast
find theFact in bkgnd field "Assertions"
put find(field "Assertions",theFact) into looking
put testRule(field "Rule Number") into statRule
if item 1 of looking<>0 and statRule is empty
then
put the number of lines in card field "Goal Trail" of card "Smart" into theLine
put theLine+1 into theLine
put field "Rule Number" into line theLine of card field "Goal Trail" of card "Smart"
put "found" into theResult
exit repeat
end if
if item 1 of find(theList,field "Rule Number")<>0
then exit repeat
else
put the number of lines in theList into temp
put field "Rule Number" into line temp of theList
end if
end repeat
return theResult
end forChain
function backChain
put "Backward Chaining..." into card field "Status" of card "Smart"
push this card
put the param of 1 into theRule
put the param of 2 into theFact
put card field "Rules" of card "Smart" into Tested
go card "Rule 1"
visual effect scroll left very fast
find theFact in bkgnd field "Conclusion"
if theFact=field "Conclusion" and item 1 of find(Tested,field "Rule Number")=0
then
put field "Rule Number" into theResult
visual effect scroll down
pop card
return theResult
end if
visual effect scroll down
pop card
return empty
end backChain
function proveRule theRule
repeat with theLine=1 to the number of lines in bkgnd field "Assertions"
put line theLine of bkgnd field "Assertions" into theFact
put testFact(theFact) into theResult
if theResult=true then next repeat
if theResult=false
then return "fail"
put backChain(theRule,theFact) into theResult
if theResult is not empty
then
put the number of lines in card field "Goal Trail" of card "Smart" into theLine
put theLine+1 into theLine
put theResult into line theLine in card field "Goal Trail" of card "Smart"
return "*"
end if
push this card
visual effect barn door close
go card "Smart"
put "Looking up Question..." into card field "Status"
show card field "Status"
put find(card field "Questions",theFact) into theQuest
if item 1 of theQuest=0
then
visual effect wipe up
go card "Question"
put theFact into field "Fact"
return "?"
else
put item 1 of theQuest into theQuest
put item 2 of line theQuest of card field "Questions" into theQuest
visual effect wipe up
go theQuest
return "?"
end if
end repeat
put "Passing Rule..." into card field "Status" of card "Smart"
put field "Conclusion" into card field "Conclusion" of card "Smart"
put the number of lines in card field "Facts" of card "Smart" into numLines
put numLines+1 into theLine
put field "Conclusion" into line theLine of card field "Facts" of card "Smart"
put true into item 2 of line theLine of card field "Facts" of card "Smart"
put the number of lines in card field "Rules" of card "Smart" into theLine
put theLine+1 into theLine
put theRule into line theLine of card field "Rules" of card "Smart"
put "pass" into item 2 of line theLine of card field "Rules" of card "Smart"
return "pass"
end proveRule