'AI_Story 24 Reviewed 5/25/05
'Simple Working Version
'Multiple working stories included now for study
'Top of Tree is right below. REM (') out DATA line to simplify stories

DATA Z.Story
'DATA Z.Laura.Story
DATA Z.Big.Kent.Story
DATA Z.Story0
DATA Z.Story2
DATA Z.Story4
DATA Z.Story.Sarah
DATA

DATA Z.Big.Kent.Story
DATA Z.Many.Kent.Stories Z.Many.Kent.Stories Z.Many.Kent.Stories 
Z.Many.Kent.Stories Z.Many.Kent.Stories Z.Many.Kent.Stories 
Z.Many.Kent.Stories Z.Many.Kent.Stories
DATA

DATA Z.Many.Kent.Stories
DATA Kent likes to play Z.Kent.PlayStation.Games and Z.Kent.Computer.Games
DATA Kent is Z.Kent.Positive.Adjective and Z.Kent.Negative.Adjective
DATA Kent likes to Z.Kent.Father.Things with his father
DATA Kent dreams of Z.Kent.Dreams .
DATA Kent likes to play Z.Kent.Father.Games and 
Z.Kent.Father.Board.Games.C14 with his father .
DATA Kent likes to talk to his friend Z.Kent.Friends
DATA Z.Spanish.Person tu tocar la guitarra?
DATA

DATA Z.Kent.Positive.Adjective
DATA street smart
DATA good-looking
DATA cool
DATA musical
DATA Sexy
DATA amusing
DATA hairy
DATA funny
DATA

DATA Z.Kent.Negative.Adjective
DATA angry
DATA depressed
DATA bored
DATA scared
DATA forgetful
DATA hairy
DATA


DATA Z.Kent.Friends
DATA Alberto
DATA Janelle
DATA Ashley
DATA Erica
DATA Jason
DATA Kevin
DATA India
DATA Danielle
DATA Mike
DATA Christine
DATA

DATA Z.Kent.Occupations
DATA singer
DATA actor
DATA trumpet player
DATA game player
DATA agitator
DATA son
DATA brother
DATA bother
DATA

DATA Z.Kent.College.Locations
DATA Connecticut
DATA New York
DATA New Jersey
DATA New England
DATA

DATA Z.Kent.Jobs.at.home
DATA cooking
DATA shoveling
DATA taking out the trash
DATA washing and drying dishes
DATA vacuuming
DATA dusting
DATA folding laundry
DATA

DATA Z.Kent.Dreams
DATA fame
DATA "love getting and making
DATA getting money
DATA a career
DATA

DATA Z.Kent.Classes
DATA history
DATA theatre
DATA psychology
DATA

DATA Z.Kent.Computer.Games
DATA Ripper
DATA Wing Commander IV The Price of Freedom
DATA Solitare
DATA MineSweeper
DATA Hearts
DATA FreeCell
DATA Freelancer
DATA Painkiller
DATA Warcraft III Reign of Chaos
DATA Warcraft III The Frozen Throne
DATA Alien vs. Predator 2
DATA Alien vs. Predator 2 Primal Hunt
DATA Final Doom
DATA

DATA Z.Kent.PlayStation.Games
DATA the entire 'Resident Evil' series
DATA Final Fantasy VIII
DATA Doom
DATA the entire 'Jet Moto' series
DATA Crash Bandicoot
DATA Wing Commander IV The Price of Freedom
DATA the entire 'Tekken' series
DATA Wing Commander III Heart of the Tiger
DATA

DATA Z.Kent.Father.Things
DATA watch movies
DATA go to the arcade
DATA go duckpin bowling
DATA "play Z.Kent.Father.Board.Games.C14
DATA play basketball
DATA

DATA Z.Kent.Father.Board.Games.C14
DATA Monopoly
DATA Risk
DATA Sorry
DATA "Battleship-electronic or regular
DATA Star Wars Episode I The Phantome Menace edition of Monopoly
DATA

DATA Z.Kent.Father.Games
DATA Jitters
DATA Life
DATA Uno
DATA

DATA Z.Spanish.Person
DATA Marcos
DATA Ramon
DATA Claudia
DATA Anita
DATA Ada
DATA Alberto
DATA


DATA Z.Story4
DATA Z.Story.Article in your article
DATA

DATA Z.Story.Article
DATA Discuss Z.Part1.C10 Z.Part2.C11 Z.Part3.C12 Z.Part4.C13 Z.Part5.C14
DATA Discuss Z.Part2.C11 Z.Part2.C11 Z.Part3.C12 Z.Part4.C13 Z.Part5.C14
DATA Discuss Z.Part3.C12 Z.Part2.C11 Z.Part3.C12 Z.Part4.C13 Z.Part5.C14
DATA Discuss Z.Part4.C13 Z.Part2.C11 Z.Part3.C12 Z.Part4.C13 Z.Part5.C14
DATA Discuss Z.Part5.C14 Z.Part2.C11 Z.Part3.C12 Z.Part4.C13 Z.Part5.C14
DATA

DATA Z.Part1.C10
DATA AI
DATA Schank, Yale, Zoo
DATA Lisp, Logo
DATA Stories
DATA Articles
DATA

DATA Z.Part2.C11
DATA Symbols
DATA Recursion
DATA QBasic
DATA One File
DATA Data Abstraction (Script)
DATA

DATA Z.Part3.C12
DATA PDOS Programming
DATA Five Parts of Five
DATA Intro, Input, Work, Output, Move On
DATA Articles, Programs, Data
DATA

DATA Z.Part4.C13
DATA Children
DATA Articles
DATA Adults Goals
DATA Adult Stories
DATA

DATA Z.Part5.C14
DATA Future
DATA Information Powers
DATA Web Scripts
DATA Contribution, ideas, stories, scripts, subroutines, articles
DATA

DATA Z.Story.Sarah
DATA Z.Sarah.Story Z.Sarah.Story Z.Sarah.Story Z.Sarah.Story Z.Sarah.Story 
Z.Sarah.Story
DATA

DATA Z.Sarah.Story
DATA Sarah is Z.Sarah.Positive.Adjective.C11 and 
Z.Sarah.Negative.Adjective.C13 .
DATA Sarah likes to Z.Sarah.Daughter.Things.C10 with her daughter .
DATA Sarah dreams of Z.Sarah.Dreams
DATA Dora likes to play Z.Sarah.Daughter.Games
DATA

DATA Z.Sarah.Positive.Adjective.C11
DATA street smart
DATA good-looking
DATA sense of humor
DATA kind
DATA giving
DATA
DATA Z.Sarah.Negative.Adjective.C13
DATA angry
DATA bored
DATA scared
DATA forgetful
DATA
DATA Z.Sarah.Occupations
DATA receptionist
DATA mother
DATA dancer
DATA caregiver
DATA
DATA Z.Sarah.Dreams
DATA great family life
DATA rockettes
DATA being rich
DATA a career
DATA big Wedding
DATA nice house
DATA
DATA Z.Sarah.Classes
DATA spanish I
DATA intermediate algebra 2
DATA senior comp
DATA keyboarding
DATA band
DATA psychology
DATA
DATA Z.Sarah.Daughter.Things.C10
DATA play Elmo games
DATA go sledding
DATA go bowling
DATA
DATA Z.Sarah.Daughter.Games
DATA Tickle me Elmo
DATA Limbo Elmo
DATA Wonderball
DATA Patty Cake
DATA

DATA Z.Story0
DATA Z.Intro0 Z.Middle0 Z.End0
DATA
DATA Z.Intro0
DATA Hi There .
DATA Hello .
DATA What's the Story ?
DATA
DATA Z.Middle0
DATA Here's the Story .
DATA Here's What's happening .
DATA
DATA Z.End0
DATA Bye now .
DATA GoodBye .
DATA Get a Life .
DATA
DATA
DATA Z.Laura.Story
DATA I love Z.Laura.Adjectives Laura and all her Z.Laura.Things
DATA
DATA Z.Laura.Things
DATA family
DATA friends
DATA parts
DATA hats and coats
DATA arms and legs
DATA
DATA Z.Laura.Adjectives
DATA sweet
DATA Sexy
DATA super and slender
DATA
DATA
DATA
DATA Z.Toni
DATA beautiful
DATA charming
DATA Hard working
DATA Determined
DATA

DATA Z.Toni.Friends
DATA Heather
DATA Jason
DATA Gina
DATA Ashley
DATA

DATA Z.Toni.Trip
DATA Tennessee
DATA Wedding
DATA Church Friends
DATA

DATA Z.Toni.Job
DATA recruting
DATA telephone Marketing
DATA associates
DATA

DATA Z.Toni.Dreams
DATA marriage
DATA children
DATA money
DATA career
DATA

DATA Z.Toni.College
DATA English
DATA Marketing
DATA Business
DATA
DATA

DATA Z.Bob
DATA smart
DATA
DATA

DATA Z.Story2
'DATA Hi There You devil you.
DATA Z.Intro Z.First Z.Second Z.Sentence.List Z.Sentence.List 
Z.Sentence.List Z.End
'DATA Z.First
'DATA Z.Second
DATA

DATA Z.Intro
DATA You are in Z.Place.C12 .
DATA

DATA Z.First
DATA Z.Treasure Z.Is.verb Z.Treasure.Doers
DATA
DATA Z.Second
DATA Z.Monster Z.Monster.Doers .
DATA
DATA Z.End
DATA What now mighty adventurer ?
DATA
DATA Z.LoveLetters
DATA Love Poetry
DATA Love Letters
DATA Adventures
DATA Ideas
DATA Stories
DATA Thoughts
DATA

DATA Z.Benefits
DATA Sell the benefits
DATA save the new versions
DATA

DATA Z.Explainations
DATA Explain it to Laura
DATA Explain it to Kent
DATA

DATA Z.NewScripts
DATA Try it on all the computer around
DATA get new scripts working each day
DATA spend a lot of time on scripts
DATA

DATA Z.FoodDiary
DATA Do food diary
DATA Make sandwich suggestions
DATA

DATA Z.Other
DATA make the computer games stories work
DATA make toy story work
DATA make a list of all the characters
DATA make childrens stories from the movie stories
DATA find the movies you like
DATA organize this scripts with big word processor stuff
DATA check the spelling
DATA

DATA Z.Mentor.C11
DATA Donald Trump
DATA Isaac Azimov
DATA Sam Keen
DATA Roger Schank
DATA Bernie Siegle
DATA

DATA Z.Mentor.C13
DATA Sharon
DATA Margaret
DATA Susan
DATA Bob
DATA

DATA Z.Exclamation.C12
DATA "Get that program working
DATA "Send those letters out
DATA "Start communicating with people
DATA "Network
DATA "Organize small project teams
DATA "Write a program!"
DATA "Edit a Script"
DATA

DATA Z.Parents
DATA Bernie Siegle
DATA Mary Kelly
DATA

DATA Z.Is.verb
DATA is
DATA

DATA Z.Person.Verb
DATA talked to
DATA saw
DATA heard
DATA listened to
DATA rescued
DATA helped
DATA

DATA Z.Motion.Verb
DATA moved to
DATA went to
DATA ran into
DATA
DATA Z.Speak.Verb
DATA cried
DATA said
DATA yelled
DATA
DATA Z.Place.C12
DATA Z.Proper.Place.C12
DATA Z.Article.A Z.Place.Adjective Z.Inanimate.Place.C12
DATA
DATA Z.Sentence.List
DATA Z.Sentence Z.Sentence.List
DATA Z.Sentence
DATA

DATA Z.Sentence
DATA Write up some Z.LoveLetters .
DATA Z.Exclamation.C12 Z.Speak.Verb Z.Subject
DATA Z.Monster Z.Motion.Verb Z.Place.C12
DATA Z.Subject Z.Person.Verb Z.Person.Object
DATA Z.Mentor.C13 and Z.Mentor.C11 Z.Duo.Play.Verb Z.Video.Game.C13 .
DATA
DATA Z.Ghost.C14
DATA Stay-Puft
DATA Gozer the Gozarian
DATA Slimer
DATA Skeleton
DATA Slime
DATA Spud
DATA

DATA Z.Video.Game.C13
DATA Jump Man
DATA Pole Position
DATA Wizard
DATA Pit Stop
DATA Speed Buggy
DATA Commando
DATA The Last Ninja
DATA

DATA Z.Solo.Play.Verb
DATA is playing
DATA is loosing
DATA is winning
DATA wants to know how to play
DATA doesn't know how to play
DATA
DATA Z.Duo.Play.Verb
DATA are playing
DATA are loosing
DATA are winning
DATA want to know how to play
DATA don't know how to play
DATA

DATA Z.Subject
'DATA Z.Monster
DATA Z.Mentor.C13
DATA Z.Mentor.C11
DATA Z.Mentor.C13
DATA

DATA Z.Person.Object
DATA Z.Mentor.C13
DATA Z.Mentor.C11
DATA

DATA Z.Monster
DATA Z.Ghost.C14
DATA Z.Warm.Monster.C14
DATA
DATA Z.Cold.Monster
DATA Muscle men
DATA Thunder cat monster
DATA Skeletor
DATA Snake men
DATA Squeese
DATA Battle Beast
DATA

DATA Z.Warm.Monster.C14
DATA Charlie Brown
DATA Snoopy
DATA He Man
DATA She Ra
DATA Popeye
DATA Brutus
DATA

DATA Z.Treasure.Doers
DATA hidden
DATA under a monster
DATA in plain view
DATA in the chest
DATA in the sack
DATA in a secret place
DATA buried
DATA

DATA Z.Monster.Doers
DATA sits there
DATA plays baseball
DATA runs away
DATA jumps up
DATA plays the piano
DATA disappears
DATA

DATA Z.Treasure
DATA 100.00 dollars
DATA A remote control car
DATA A Lego Shell Station
DATA A door that goes to the next level
DATA A mad scientist
DATA Some magic
DATA A Nintendo
DATA A new Commodore
DATA

DATA Z.Proper.Place.C12
DATA Tony's room
DATA Bob's room
DATA Bobby's room
DATA
DATA Z.Inanimate.Place.C12
DATA room
DATA store
DATA house
DATA yard
DATA office
DATA garage
DATA bus
DATA space ship
DATA

DATA Z.Article
DATA the
DATA
DATA Z.Person.Adjective
DATA big
DATA beautiful
DATA strong
DATA smart
DATA tough and good looking
DATA mysterious
DATA big bad
DATA healthy
DATA handsome
DATA
DATA Z.Place.Adjective
DATA big
DATA beautiful
DATA well lit
DATA mysterious
DATA charming
DATA well organized
DATA clean
DATA strange
DATA Z.Color1.C10
DATA

DATA Z.Color1.C10
DATA red
DATA yellow
DATA green
DATA blue
DATA orange
DATA hot pink
DATA purple
DATA brown
DATA black
DATA

DATA Z.Article.A
DATA a
DATA

DATA END OF DATA



DECLARE SUB StoryProgram ()
CALL StoryProgram
END

SUB StoryProgram

DIM WorkPhrase$(40): 'Current Limit for Levels of Abstraction
DIM A$(1000): 'Current Data Line Limit
DIM b$(100), b(100): 'Curremt Symbol Limit
DIM C$(30): 'Current Maximum Number of Lines per Symbol


1 'GOTO 9:
2 '(c) Robert G. Hambly
3 '2340 Whitney Ave
4 'Hamden, CT  06514,  (203) 248-8142
5 GOSUB 20: 'Setup Top of Story Tree
7 GOSUB 40: 'Initialize Data Array
9 RANDOMIZE TIMER:


10 REM CHECK FOR EMPTY LEVEL
'Level= array level counter,
'WorkPhrase$(Level) = array
   'PRINT level
13 IF WorkPhrase$(level) = "" THEN level = level - 1: COLOR 7: 'Go back to 
prior level
15 IF level = 0 THEN GOTO 90: 'We are at the end
17 IF WorkPhrase$(level) = "" THEN GOTO 13:  'Keep checking
19 GOTO 30

20 REM INITIALIZE TOP OF STORY TREE
21 level = 1:  IF FirstPass = 1 THEN GOTO 25
23 CLS : PRINT : LINE INPUT "Type in the Name of Your Story, or press 
<Enter> "; Temp$
   FirstPass = 1
25 IF Temp$ = "" THEN
        WorkPhrase$(1) = "Z.Story"
        ELSE
        WorkPhrase$(1) = Temp$
   END IF
27 CLS : PRINT
29 RETURN


30 REM GET FIRST WORD (WString$) or symbol (a word containing  'z.')
31 WString$ = WorkPhrase$(level):  'Get sentence from current level
35 GOSUB 80:  'Extract off first word
37 WorkPhrase$(level) = Butfirst$:  'Save remainder (butfirst) at current 
level (as WorkPhrase$(Level))
   'PRINT WString$, WorkPhrase$(Level)
   ' WString$ is now the first word
39 GOTO 50

40 REM READ IN DATA ARRAYS, a$() = Full Data Array, B$() Symbol Array, and 
B() index array
41 RESTORE: AIndex = 0: BIndex = 0
43 AIndex = AIndex + 1: READ A$(AIndex): 'PRINT a$(AIndex)
   IF UCASE$(A$(AIndex)) = "END OF DATA" GOTO 49
   IF LEFT$(A$(AIndex), 2) = "Z." OR LEFT$(A$(AIndex), 2) = "z." THEN
         BIndex = BIndex + 1: b$(BIndex) = A$(AIndex): b(BIndex) = AIndex
45       AIndex = AIndex + 1: READ A$(AIndex):
         IF UCASE$(A$(AIndex)) = "END OF DATA" GOTO 49
         IF A$(AIndex) = "" THEN GOTO 47
         GOTO 45: 'Skip over Detail data for now (Avoiding Z. in Data)
47   END IF: GOTO 43

49 'FOR j = 1 TO Bindex: PRINT "j = "; j, "B$(J) = "; b$(j); TAB(40);
   '     PRINT "A$(b(j)) = "; A$(b(j)); TAB(70); "b(j) = "; b(j)
   '      cou = cou + 1: IF cou = 10 THEN LINE INPUT q$: cou = 0
   'NEXT j
   AIndexFinal = AIndex: BIndexFinal = BIndex: RETURN


50 REM CHECK FOR 'Z.' in word (WString$)
  'If not found then just print WString$
  'If found then look it up in symbol table, and work on it
51 IF LEFT$(WString$, 2) = "Z." OR LEFT$(WString$, 2) = "z." THEN
        GOTO 53
        ELSE
        GOTO 70: 'If no 'z.' go to print
   END IF
53 CurrentSymbol$ = WString$: 'PRINT "53 CurrentSymbol$ = "; CurrentSymbol$
   IF LEN(WString$) > 4 THEN
        Temp$ = RIGHT$(WString$, 4)
        ELSE
        GOTO 55
   END IF

'Color Routines
   Temp = INSTR(Temp$, ".C"):
    IF Temp > 0 THEN
      Temp1 = LEN(Temp$) - Temp - 1: COLOR VAL(RIGHT$(Temp$, Temp1))
      ELSE
      COLOR 7
    END IF

55 GOSUB 60

57 level = level + 1: WorkPhrase$(level) = WString$: 'PRINT level

'PRINT WString$
59 GOTO 10



60 'Special Table lookup, Receives CurrentSymbol$, Returns Random WString$ 
word or sentence

    'PRINT "***"; CurrentSymbol$; "***", level: LINE INPUT Temp$

       BIndex = 0

61 'Find Symbol (CurrentSymbol$) in Symbol Index Array
'IF CurrentSymbol$ = "Z.Color1" THEN STOP

BIndex = BIndex + 1: IF BIndex > BIndexFinal THEN GOTO 67
IF b$(BIndex) = "END OF DATA" THEN GOTO 67
IF b$(BIndex) = CurrentSymbol$ THEN
        CIndex = 1: AIndex = b(BIndex) + 1: GOTO 63
END IF
   'PRINT b$(BIndex); "**": cou = cou + 1: IF cou = 10 THEN LINE INPUT q$: 
cou = 0
GOTO 61

63 'Read C$() array until blank line
'IF CurrentSymbol$ = "Z.Color1" THEN STOP
'COLOR 7: PRINT "hillo"

C$(CIndex) = A$(AIndex):
'PRINT "C$(CIndex) = "; C$(CIndex); : '"   A$(AIndex) = "; A$(AIndex);
'PRINT "   Cindex ="; CIndex: ' "   AIndex = "; AIndex
IF C$(CIndex) = "" THEN GOTO 65
CIndex = CIndex + 1: AIndex = AIndex + 1
GOTO 63

65 'Determine Random Selection
'PRINT "CIndex = "; CIndex
'FOR j = 1 TO CIndex: PRINT C$(j): NEXT j
CIndex = CIndex - 1: RandomIndex = INT(RND * CIndex) + 1
'PRINT "RanInd = "; RandomIndex
GOTO 69


67 REM Can't find symbol
PRINT : PRINT "Error found"
PRINT "I can't find   ***"; CurrentSymbol$; "***   in your script.  Sorry!":
PRINT "Program stopped"
END


69 'Finish Up Random Selection
WString$ = C$(RandomIndex)
'PRINT WString$
RETURN





70
IF WString$ = "." OR WString$ = "?" THEN
   COLOR 7: PRINT WString$
   ELSE
   PRINT " "; WString$;
END IF
79 GOTO 10



80 REM REMOVE WORD, receives WString$ as word or sentence
81 'Returns WString$ as First: ButFirst$ as Rest of Segment (ButFirst) : 
Uses Temp
83 Butfirst$ = "": IF LEN(WString$) = 0 THEN GOTO 89: 'Empty String
85 Temp = INSTR(WString$, " "): IF Temp = 0 THEN GOTO 89: 'Only One Word
87 Butfirst$ = RIGHT$(WString$, LEN(WString$) - Temp): WString$ = 
LEFT$(WString$, Temp - 1)
89
'PRINT "  Len BF = "; LEN(Butfirst$), "  Len F = "; LEN(WString$); WString$
RETURN



90 '
91 PRINT : PRINT : PRINT "For more stories, press <ENTER>"
93 LINE INPUT "To stop, Press any Key then <ENTER> "; Temp$
95 IF Temp$ = "" THEN GOTO 1
97 PRINT
   PRINT "AIndexFinal = "; AIndexFinal; " = Total Data Lines"
   PRINT "BIndexFinal = "; BIndexFinal; " = Total Symbols Declared"
   '      cou = cou + 1: IF cou = 10 THEN LINE INPUT q$: cou = 0
99 END

END SUB





