Refactor decide_what_to_do_about() to be independent of dead bodies.
Cat's Eye Technologies
11 years ago
338 | 338 | # this should really be *derived* from having a recent memory |
339 | 339 | # of seeing a dead body in the bathroom. but for now, |
340 | 340 | self.nerves = 'calm' |
341 | # this, too, should be more general and sophisticated. | |
341 | # this, too, should be more sophisticated. | |
342 | 342 | # it is neither a memory, nor a belief, but a judgment, and |
343 | 343 | # eventually possibly a goal. |
344 | self.what_to_do_about_the_body = None | |
345 | self.other_decision_about_the_body = None | |
344 | # hash maps Actors to strings | |
345 | self.what_to_do_about = {} | |
346 | self.other_decision_about = {} | |
346 | 347 | |
347 | 348 | def animate(self): |
348 | 349 | return True |
780 | 781 | # this should probably be affected by whether this |
781 | 782 | # character has, oh, i don't know, put the other at |
782 | 783 | # gunpoint yet, or not, or something |
783 | if self.what_to_do_about_the_body is None: | |
784 | if self.what_to_do_about.get(thing) is None: | |
784 | 785 | if random.randint(0, 1) == 0: |
785 | self.what_to_do_about_the_body = 'call' | |
786 | self.what_to_do_about[thing] = 'call' | |
786 | 787 | else: |
787 | self.what_to_do_about_the_body = 'dispose' | |
788 | if self.other_decision_about_the_body == self.what_to_do_about_the_body: | |
789 | if self.what_to_do_about_the_body == 'call': | |
788 | self.what_to_do_about[thing] = 'dispose' | |
789 | if self.other_decision_about.get(thing, None) == self.what_to_do_about[thing]: | |
790 | if self.what_to_do_about[thing] == 'call': | |
790 | 791 | self.question(other, "'So we're agreed then, we should call the police?' asked <1>", |
791 | 792 | [self, other, thing]) |
792 | 793 | # the other party might not've been aware that they agree |
793 | other.other_decision_about_the_body = \ | |
794 | self.what_to_do_about_the_body | |
795 | elif self.what_to_do_about_the_body == 'dispose': | |
794 | other.other_decision_about[thing] = \ | |
795 | self.what_to_do_about[thing] | |
796 | elif self.what_to_do_about[thing] == 'dispose': | |
796 | 797 | self.question(other, "'So we're agreed then, we should try to dispose of <3>?' asked <1>", |
797 | 798 | [self, other, thing]) |
798 | other.other_decision_about_the_body = \ | |
799 | self.what_to_do_about_the_body | |
799 | other.other_decision_about[thing] = \ | |
800 | self.what_to_do_about[thing] | |
800 | 801 | else: |
801 | 802 | raise ValueError("damn") |
802 | elif self.what_to_do_about_the_body == 'call': | |
803 | elif self.what_to_do_about[thing] == 'call': | |
803 | 804 | self.speak_to(other, "'I really think we should call the police, <2>,' said <1>", |
804 | 805 | [self, other, thing]) |
805 | other.other_decision_about_the_body = \ | |
806 | self.what_to_do_about_the_body | |
807 | elif self.what_to_do_about_the_body == 'dispose': | |
806 | other.other_decision_about[thing] = \ | |
807 | self.what_to_do_about[thing] | |
808 | elif self.what_to_do_about[thing] == 'dispose': | |
808 | 809 | self.speak_to(other, "'I think we should try to dispose of <3>, <2>,' said <1>", |
809 | 810 | [self, other, thing]) |
810 | other.other_decision_about_the_body = \ | |
811 | self.what_to_do_about_the_body | |
811 | other.other_decision_about[thing] = \ | |
812 | self.what_to_do_about[thing] | |
812 | 813 | else: |
813 | 814 | raise ValueError("damn") |
814 | 815 |