git @ Cat's Eye Technologies NaNoGenLab / 65f83d5
I am quite impressed with these results. Chris Pressey 10 years ago
2 changed file(s) with 34 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
00 selfref-timeline
11 ================
2
3 _in progress_
42
53 Hypothesis
64 ----------
75
86 We hypothesize that we ought to generate some kind of dialogue based on
9 characters' hopes and memories.
7 characters' wonderings about the future and memories of the past.
108
119 Apparatus
1210 ---------
2725 Observations
2826 ------------
2927
30 Still has significant bugs, but shows promise.
28 It still has some fudgy areas (like when there is a PREDICTION of a MEMORY
29 of that selfsame PREDICTION, with no SIGHTINGs involved), but otherwise,
30 I think it works quite well. Here is the output of `./selfref-timeline.py 10`:
3131
32 > Alice turned to Bob and asked, "Bob, do you think we will ever remember that time when see a UFO ranting obnoxiously?"
32 > Alice and Bob saw a ghost looking pensive.
3333 >
34 > Bob turned to Alice and said, "Alice, do you remember that one time when we wonder if we'd ever remember that time when see a UFO ranting obnoxiously?"
34 > Then one day, Alice turned to Bob and said, "Bob, do you remember that one time when we saw a ghost looking pensive?" Alice smiled. "Of course I do, Bob."
3535 >
36 > Alice turned to Bob and asked, "Bob, do you think we will ever see a UFO ranting obnoxiously?"
36 > Then one day, Bob turned to Alice and said, "Alice, do you remember that one time when we remembered that time when we saw a ghost looking pensive?" Bob smiled. "Of course I do, Alice."
3737 >
38 > Alice and Bob saw a UFO ranting obnoxiously.
38 > Then one day, Bob turned to Alice and asked, "Alice, do you think that one day we will wonder if we'd ever remember that time when we remembered that time when we remembered that time when we remembered that time when we saw a ghost looking pensive?" "I don't know, Bob," said Alice.
39 >
40 > Then one day, Bob turned to Alice and asked, "Alice, do you think that one day we will remember that time when we remembered that time when we remembered that time when we remembered that time when we saw a ghost looking pensive?" "I don't know, Bob," said Alice.
41 >
42 > Then one day, Bob turned to Alice and said, "Alice, do you remember that one time when we remembered that time when we remembered that time when we saw a ghost looking pensive?" Bob smiled. "Of course I do, Alice."
43 >
44 > Then one day, Alice turned to Bob and said, "Bob, do you remember that one time when we remembered that time when we remembered that time when we remembered that time when we saw a ghost looking pensive?" Alice smiled. "Of course I do, Bob."
3838
3939
4040 def render_toplevel(event):
41 # so much for object-orientation!
4142 starting_at = event
4243 mentioned = set([starting_at])
4344
4647 if isinstance(event, Prediction):
4748 return (
4849 '%s turned to %s and asked, '
49 '"%s, do you think we will ever %s?" '
50 '"%s, do you think that one day we will %s?" '
5051 '"I don\'t know, %s," said %s.' % (
5152 a, b, b,
5253 render(event.target_event, starting_at, mentioned, tense='future'),
7071
7172
7273 def render(event, starting_at, mentioned, tense='past'):
73 # so much for object-orientation
74 if not event:
75 return 'nothing at all'
76
77 if starting_at == event:
78 return 'this moment'
79
80 if event in mentioned:
81 return 'that moment' # hard to be more specific!
82
83 mentioned = mentioned | set([event]) # note that we do not modify the shared set
74 assert event, "you should have filtered these out already you nincompoop"
8475
8576 wonder = 'wondered' if tense == 'past' else 'wonder'
8677 remember = 'remembered' if tense == 'past' else 'remember'
8778 see = 'saw' if tense == 'past' else 'see'
79 experience = 'experienced' if tense == 'past' else 'experience'
80
81 # this is kind of a bodge to deal with NON-TERMINATING RECURSIVE DEJA VU
82 if starting_at == event:
83 return '%s this moment' % experience
84 if event in mentioned:
85 # hard to be more specific than this!
86 return '%s that moment' % experience
87
88 mentioned = mentioned | set([event]) # note that we do not modify the shared set
8889
8990 if isinstance(event, Prediction):
9091 return (
107108
108109
109110 def main(argv):
111 length = int(argv[1])
112
110113 possibilities = (
111114 Prediction, Prediction, Memory, Memory, Sighting
112115 )
113 timeline = [random.choice(possibilities)() for x in xrange(0, 50)]
114
116 timeline = [random.choice(possibilities)() for x in xrange(0, length)]
117
118 # FOR TESTING
119 # timeline = [Prediction(), Memory()]
120
115121 while isinstance(timeline[0], Memory):
116122 timeline = timeline[1:]
117123