Diction will get worse before it gets better. Add 'place_in'.
Cat's Eye Technologies
11 years ago
24 | 24 | # would be nicer in Prolog. |
25 | 25 | # DRAMATIC IRONY would be really nice, but hard to pull off. |
26 | 26 | # "it was so nice" -- actually *have* memories of locations, and feelings |
27 | # (good/bad, 0 to 10 or something) about memories | |
27 | # (good/bad, 0 to 10 or something) about memories | |
28 | 28 | # anxiety memory = the one they're most recently panicked about |
29 | 29 | # memory of objects -> memory of hiding them somewhere |
30 | 30 | # bullets for the revolver |
236 | 236 | def threaten(self, other, phrase, participants=None, subject=None): |
237 | 237 | self.address(other, ThreatTopic(self, subject=subject), phrase, participants) |
238 | 238 | |
239 | # self.location=None implies this is just an initial move | |
240 | def move_to(self, location): | |
241 | initial = (self.location is None) | |
242 | if not initial: | |
243 | for x in self.location.contents: | |
244 | # otherwise we get "Bob saw Bob leave the room", eh? | |
245 | if x is self: | |
246 | continue | |
247 | if x.animate(): | |
248 | x.emit("<1> saw <2> leave the room", [x, self]) | |
239 | def place_in(self, location): | |
240 | # like move_to but quieter; for setting up scenes etc | |
241 | if self.location is not None: | |
249 | 242 | self.location.contents.remove(self) |
250 | 243 | self.location = location |
251 | 244 | self.location.contents.append(self) |
252 | verb = pick(['went to', 'walked to', 'moved to']) | |
253 | if initial: | |
254 | verb = 'was in' | |
255 | self.emit("<1> %s <2>" % verb, [self, self.location]) | |
245 | self.emit("<1> was in <2>", [self, self.location]) | |
246 | for x in self.location.contents: | |
247 | if x == self: | |
248 | continue | |
249 | if x.notable(): | |
250 | self.emit("<1> saw <2>", [self, x]) | |
251 | self.memory[x.name] = Memory(x, self.location) | |
252 | ||
253 | ||
254 | def move_to(self, location): | |
255 | assert(location != self.location) | |
256 | assert(location is not None) | |
257 | for x in self.location.contents: | |
258 | # otherwise we get "Bob saw Bob leave the room", eh? | |
259 | if x is self: | |
260 | continue | |
261 | if x.animate(): | |
262 | x.emit("<1> saw <2> leave the room", [x, self]) | |
263 | if self.location is not None: | |
264 | self.location.contents.remove(self) | |
265 | self.location = location | |
266 | self.location.contents.append(self) | |
267 | self.emit("<1> went to <2>", [self, self.location]) | |
256 | 268 | if random.randint(0, 10) == 0: |
257 | 269 | self.emit("It was so nice being in <2> again", |
258 | 270 | [self, self.location], excl=True) |
273 | 285 | elif x.animate(): |
274 | 286 | other = x |
275 | 287 | self.emit("<1> saw <2>", [self, other]) |
276 | if not initial: | |
277 | other.emit("<1> saw <2> walk into the room", [other, self]) | |
288 | other.emit("<1> saw <2> walk into the room", [other, self]) | |
278 | 289 | self.memory[x.name] = Memory(x, self.location) |
279 | 290 | self.greet(x, "'Hello, <2>,' said <1>") |
280 | 291 | for y in other.contents: |
397 | 408 | if choice == 0: |
398 | 409 | self.question(other, "'Lovely weather we're having, isn't it?' asked <1>") |
399 | 410 | if choice == 1: |
400 | self.speak_to(other, "'I was wondering where you were.' said <1>") | |
411 | self.speak_to(other, "'I was wondering where you were,' said <1>") | |
401 | 412 | elif isinstance(topic, QuestionTopic): |
402 | 413 | if topic.subject is not None: |
403 | 414 | choice = random.randint(0, 1) |
562 | 573 | ### main ### |
563 | 574 | |
564 | 575 | friffery = False |
565 | debug = True | |
576 | debug = False | |
566 | 577 | |
567 | 578 | print "Swallows and Sorrows (DRAFT)" |
568 | 579 | print "============================" |
584 | 595 | for paragraph in range(1, 30): |
585 | 596 | alice.collector = alice_collector |
586 | 597 | bob.collector = bob_collector |
587 | pov_actor = pick([alice, bob]) | |
588 | c = pov_actor.collector | |
598 | ||
599 | # we could do this randomly... | |
600 | #pov_actor = pick([alice, bob]) | |
601 | # but, we could also alternate. They ARE Alice and Bob, after all. | |
602 | pov_actor = (alice, bob)[(paragraph - 1) % 2] | |
589 | 603 | |
590 | 604 | for actor in (alice, bob): |
591 | 605 | if actor.location is None: |
592 | actor.move_to(pick(house)) | |
593 | ||
594 | while len(c.events) < 20: | |
606 | actor.place_in(pick(house)) | |
607 | else: | |
608 | self = actor | |
609 | self.emit("<1> was in <2>", [self, self.location]) | |
610 | ||
611 | while len(pov_actor.collector.events) < 20: | |
595 | 612 | alice.live() |
596 | 613 | bob.live() |
597 | 614 | |
629 | 646 | print "- - - - -" |
630 | 647 | |
631 | 648 | else: |
632 | for event in c.events: | |
649 | for event in pov_actor.collector.events: | |
633 | 650 | sys.stdout.write(str(event) + " ") |
634 | 651 | #sys.stdout.write("\n") |
635 | 652 |