예제 #1
0
def related_to_sentence(concept, subject, person=None):
    relation = random.choice((' was ', ' was related to ', ' was kind of like ', ' was similar to '))
    if person is None:
        sentence = "The " + concept + relation + aOrAn.aOrAn(subject) + " " + subject + "."
    else:
        sentence = person + ' thought about how a ' + concept + relation + aOrAn.aOrAn(subject) + " " + subject + '.'
    return sentence
예제 #2
0
 def discover_prop(self, char, prop, setting):
     self.props.remove(prop)
     self.known_props.append(prop)
     if char != None:
         return char + " " + random.choice(
             ["discovered", "found", "noticed"]) + " " + aOrAn.aOrAn(
                 prop) + " " + prop + " inside the " + setting + "."
     else:
         return "There was " + aOrAn.aOrAn(
             prop) + " " + prop + " inside the " + setting + "."
예제 #3
0
 def discover_prop(self, char, prop, setting):
     self.props.remove(prop)
     self.known_props.append(prop)
     if char != None:
         return char + " " + random.choice(["discovered", "found", "noticed"]) + " " + aOrAn.aOrAn(prop) + " " + prop + " inside the " + setting + "."
     else:
         return "There was " + aOrAn.aOrAn(prop) + " " + prop + " inside the " + setting + "."
예제 #4
0
def is_a_sentence(concept, subject, person=None):
    if person is None:
        sentence = "The " + concept + " was " + aOrAn.aOrAn(subject) + " " + subject + "."
    else:
        relation_verb = random.choice(('is', 'can be'))
        sentence =  person + ' considered how a ' + concept + ' ' + relation_verb + ' '  + aOrAn.aOrAn(subject) + " " + subject + '.'
    return sentence
예제 #5
0
    def __init__(self, character, cause):
        self.character = character
        self.description = random.choice([
            "broken rib", "shattered sternum", "broken leg", "bruised face",
            "broken arm", "broken nose", "concussion", "herniated disc",
            "bruised skull", "shattered elbow", "injured spine",
            "sliced hamstring", "torn spleen", "pierced guts"
        ])

        if (cause == None):
            md_writer.print_chapter_sentence(
                character.get_description().title() + " was injured with " +
                aOrAn(self.description) + " " + self.description + ".")
        else:
            md_writer.print_chapter_sentence(cause.get_description().title() +
                                             "'s attack caused " +
                                             self.character.get_description() +
                                             " to have " +
                                             aOrAn.aOrAn(self.description) +
                                             " " + self.description + ".")
예제 #6
0
def random_rhyme():
    while True:
        adj2 = string.lower(wordLists.WordLists().get_adj())
        adj2_rhymes = rhymes.rhyme(adj2)
        if adj2_rhymes:
            for adj2_rhyme in adj2_rhymes:
                if adj2_rhyme in wordLists.WordLists.nouns:
                    noun2 = adj2_rhyme
                    try:
                        noun2_synset = wn.synset(noun2 + ".n.01").lemma_names()
                        random.shuffle(noun2_synset)
                        for noun_syn in noun2_synset:
                            noun1 = string.lower(noun_syn)
                            adj2_synset = wn.synset(adj2 + ".a.02").lemma_names()
                            random.shuffle(adj2_synset)
                            for adj2_syn in adj2_synset:
                                adj1 = adj2_syn
                                if noun2 != noun1 and adj2 != adj1:
                                    x = "What do you call " + aOrAn(adj1) + " " + adj1.replace('_',' ') + " " + noun1.replace('_', ' ') + "?\n" + aOrAn(adj2).title() + " " + adj2.replace('_',' ') + " " + noun2.replace('_', ' ') + "!\n"
                                    return x
                    except nltk.corpus.reader.wordnet.WordNetError:
                        continue
예제 #7
0
def used_for_sentence(concept, subject, person=None):
    if person is None:
        sentence = "The " + concept + " was used for " + aOrAn.aOrAn(subject) + " " + subject + "."
    else:
        sentence = person + ' considered using the ' + concept + " to " + subject + "."
    return sentence
예제 #8
0
def has_a_sentence(concept, subject, person=None):
    if person is None:
        sentence = "The " + concept + " had " + aOrAn.aOrAn(subject) + " " + subject + "."
    else:
        sentence = person + ' noticed the ' + concept + ' had ' + aOrAn.aOrAn(subject) + ' ' + subject + '.'
    return sentence
예제 #9
0
def part_of_sentence(concept, subject, person=None):
    if person is None:
        sentence = "The " + concept + " was part of " + aOrAn.aOrAn(subject) + " " + subject + "."
    else:
        sentence =  person + ' noticed the ' + concept + ' was part of ' +  aOrAn.aOrAn(subject) + ' ' + subject + '.'
    return sentence 
예제 #10
0
    def __init__(self, character, cause):
        self.character = character
        self.description = random.choice(["broken rib", "shattered sternum", "broken leg",
                                          "bruised face", "broken arm", "broken nose",
                                          "concussion", "herniated disc", "bruised skull",
                                          "shattered elbow", "injured spine", "sliced hamstring",
                                          "torn spleen", "pierced guts"])

        if (cause == None):
            md_writer.print_chapter_sentence(character.get_description().title() + " was injured with " + aOrAn(self.description) + " " + self.description + ".")
        else:
            md_writer.print_chapter_sentence(cause.get_description().title() + "'s attack caused " + self.character.get_description() + " to have " + aOrAn.aOrAn(self.description) + " " + self.description + ".")
예제 #11
0
    def generate_sentences(self):
        md_writer.print_chapter_sentence(self.state.character_list() +
                                         " made camp.")

        energy = 0

        cs = self.state.get_characters()
        random.shuffle(cs)
        c1 = cs[0]
        c2 = cs[1]
        c3 = cs[2]

        sentences = []

        if random.random() < 0.05:
            md_writer.print_chapter_sentence(
                self.state.get_current_setting().mood_sentence())

        md_writer.print_chapter_sentence(c1.get_name() +
                                         ' searched for dry wood for a fire.')
        if c1.challenge('survival'):
            wood_found = random.choice([
                'dry ash kindling', ' birch twigs', 'large dried mushrooms',
                'grassy dried reeds', 'dessicated cow dung'
            ])
            location = random.choice([
                'in a nearby copse', 'inside a hollow log',
                'beneath a spindly pine', 'along the ' +
                self.state.get_current_setting().get_name() + ' floor'
            ])
            md_writer.print_chapter_sentence(c1.get_pronoun().title() +
                                             ' found ' + wood_found + ' ' +
                                             location + '.')
            fire_sound = random.choice(['roaring', 'crackling', 'hissing'])
            fire_type = random.choice(['campfire', 'blaze', 'bonfire'])
            md_writer.print_chapter_sentence(c2.get_name() + ' started a ' +
                                             fire_sound + ' ' + fire_type +
                                             '.')
            energy += 5
            md_writer.print_chapter_sentence('While ' + c1.get_name() +
                                             ' and ' + c2.get_name() +
                                             ' made a fire, ' + c3.get_name() +
                                             ' scouted around the campsite.')
        else:
            md_writer.print_chapter_sentence(
                c1.get_pronoun().title() +
                ' searched for an hour, but all the wood was wet, and ' +
                c1.get_pronoun() + ' gave up' + '.')
            md_writer.print_chapter_sentence('Meanwhile, ' + c3.get_name() +
                                             ' went scouting.')

        if random.random() < 0.05:
            md_writer.print_chapter_sentence(
                self.state.get_current_setting().mood_sentence())

        if c3.challenge('survival'):
            sense = random.choice(
                ['saw', 'heard', 'spotted', 'noticed', 'observed'])
            grouping = random.choice(['band', 'family', 'patrol'])
            race = random.choice(self.words.fantasy_races)
            critter = copy.copy(race)
            critter = pattern.en.pluralize(critter)
            md_writer.print_chapter_sentence(c3.get_pronoun().title() + ' ' +
                                             sense + ' a ' + grouping +
                                             ' of ' + critter + '.')
            characteristic = Npc(race).characteristic
            md_writer.print_chapter_sentence('One of the ' + critter +
                                             ' had ' +
                                             aOrAn.aOrAn(characteristic) +
                                             " " + characteristic + ".")
            watching_adj = random.choice(
                ['quietly', 'patiently', 'tirelessly'])
            md_writer.print_chapter_sentence(c3.get_pronoun().title() + ' ' +
                                             watching_adj + ' watched the ' +
                                             critter + '.')
            if (len(self.state.get_current_setting().get_known_props()) > 0):
                prop = random.choice(
                    self.state.get_current_setting().get_known_props())
                md_writer.print_chapter_sentence(
                    'The ' + critter + ' took the ' + prop + ' from the ' +
                    self.state.get_current_setting().get_name() + '.')
            md_writer.print_chapter_sentence(
                'But the ' + critter + ' soon left the ' +
                self.state.get_current_setting().get_name() + '.')
            energy += 5
        else:
            critter = random.choice(self.words.fantasy_races)
            self.state.add_enemy_patrol(critter)
            critter_description = c3.get_pronoun().title(
            ) + " thought " + c3.get_pronoun(
            ) + ' saw ' + pattern.en.pluralize(critter) + ' in the distance.'
            md_writer.print_chapter_sentence(critter_description)
            failure = random.choice([
                'fell in a hidden gorge', 'loudly broke a branch',
                'accidentally knocked over a boulder', 'fell asleep',
                'walked into a tree'
            ])
            md_writer.print_chapter_sentence("Suddenly, " + c3.get_pronoun() +
                                             " " + failure + '.')

        night_description = random.choice(
            ['inky', 'black', 'moonlit', 'silent', 'calm'])
        md_writer.print_chapter_sentence(night_description.title() +
                                         ' darkness fell over the camp.')

        c = random.choice(self.state.get_characters())
        if random.random() < 0.5:
            md_writer.print_chapter_sentence(c.get_name() + ' told a story.')
        else:
            md_writer.print_chapter_sentence(c.get_name() +
                                             ' sang a song from ' +
                                             c.get_possessive_pronoun() +
                                             ' childhood.')

        sleep_opening = random.choice([
            'As the fire crackled', 'While the wind gusted',
            'As gentle rain fell', 'As the leaves rustled',
            'As howls were heard in the distance',
            'As the moon shone overhead', 'Although sadness washed over them'
        ])
        md_writer.print_chapter_sentence(sleep_opening + ',' +
                                         ' they all fell asleep.')

        c = random.choice(self.state.get_characters())
        md_writer.print_chapter_sentence(
            c.get_name() + ' dreamt of a ' + self.words.get_fantasy_place() +
            ', ' + self.words.get_fantasy_occupation() + ', and ' +
            self.words.get_living_thing_adj() + ' ' +
            pattern.en.pluralize(self.words.get_living_thing()) + '.')
        energy += 5

        self.state.add_energy(energy)
    def generate_sentences(self):
        md_writer.print_chapter_sentence(self.state.character_list() + " made camp.")

        energy = 0

        cs = self.state.get_characters()
        random.shuffle(cs)
        c1 = cs[0]
        c2 = cs[1]
        c3 = cs[2]

        sentences = []

        if random.random() < 0.05:
            md_writer.print_chapter_sentence(self.state.get_current_setting().mood_sentence())

        md_writer.print_chapter_sentence(c1.get_name() + ' searched for dry wood for a fire.')
        if c1.challenge('survival'):
            wood_found = random.choice(['dry ash kindling', ' birch twigs', 'large dried mushrooms', 'grassy dried reeds', 'dessicated cow dung'])
            location = random.choice(['in a nearby copse', 'inside a hollow log', 'beneath a spindly pine', 'along the ' + self.state.get_current_setting().get_name() + ' floor'])
            md_writer.print_chapter_sentence(c1.get_pronoun().title() + ' found ' + wood_found + ' ' + location + '.')
            fire_sound = random.choice(['roaring', 'crackling', 'hissing'])
            fire_type = random.choice(['campfire', 'blaze', 'bonfire'])
            md_writer.print_chapter_sentence(c2.get_name() + ' started a ' + fire_sound + ' ' + fire_type + '.')
            energy += 5
            md_writer.print_chapter_sentence('While ' + c1.get_name() + ' and ' + c2.get_name() + ' made a fire, ' + c3.get_name() + ' scouted around the campsite.')
        else:
            md_writer.print_chapter_sentence(c1.get_pronoun().title() + ' searched for an hour, but all the wood was wet, and ' + c1.get_pronoun() + ' gave up' + '.')
            md_writer.print_chapter_sentence('Meanwhile, ' + c3.get_name() + ' went scouting.')

        if random.random() < 0.05:
            md_writer.print_chapter_sentence(self.state.get_current_setting().mood_sentence())

        if c3.challenge('survival'):
            sense = random.choice(['saw', 'heard', 'spotted', 'noticed', 'observed'])
            grouping = random.choice(['band', 'family', 'patrol'])
            race = random.choice(self.words.fantasy_races)
            critter = copy.copy(race)
            critter = pattern.en.pluralize(critter)
            md_writer.print_chapter_sentence(c3.get_pronoun().title() + ' ' + sense + ' a ' + grouping + ' of ' + critter + '.')
            characteristic = Npc(race).characteristic
            md_writer.print_chapter_sentence('One of the ' + critter + ' had ' + aOrAn.aOrAn(characteristic) + " " + characteristic + ".")
            watching_adj = random.choice(['quietly', 'patiently', 'tirelessly'])
            md_writer.print_chapter_sentence(c3.get_pronoun().title() + ' ' + watching_adj + ' watched the ' + critter +'.')
            if (len(self.state.get_current_setting().get_known_props()) > 0):
                prop = random.choice(self.state.get_current_setting().get_known_props())
                md_writer.print_chapter_sentence('The ' + critter + ' took the ' + prop + ' from the ' + self.state.get_current_setting().get_name() + '.')
            md_writer.print_chapter_sentence('But the ' + critter + ' soon left the ' + self.state.get_current_setting().get_name() + '.')
            energy += 5
        else:
            critter = random.choice(self.words.fantasy_races)
            self.state.add_enemy_patrol(critter)
            critter_description = c3.get_pronoun().title() + " thought " + c3.get_pronoun() + ' saw ' + pattern.en.pluralize(critter) + ' in the distance.'
            md_writer.print_chapter_sentence(critter_description)
            failure = random.choice(['fell in a hidden gorge', 'loudly broke a branch', 'accidentally knocked over a boulder', 'fell asleep', 'walked into a tree'])
            md_writer.print_chapter_sentence("Suddenly, " + c3.get_pronoun() + " " + failure + '.')

        night_description = random.choice(['inky', 'black', 'moonlit', 'silent', 'calm'])
        md_writer.print_chapter_sentence(night_description.title() + ' darkness fell over the camp.')

        c = random.choice(self.state.get_characters())
        if random.random() < 0.5:
            md_writer.print_chapter_sentence(c.get_name() + ' told a story.')
        else:
            md_writer.print_chapter_sentence(c.get_name() + ' sang a song from ' + c.get_possessive_pronoun() + ' childhood.')

        sleep_opening = random.choice(['As the fire crackled', 'While the wind gusted', 'As gentle rain fell', 'As the leaves rustled', 'As howls were heard in the distance', 'As the moon shone overhead', 'Although sadness washed over them'])
        md_writer.print_chapter_sentence(sleep_opening + ',' + ' they all fell asleep.')

        c = random.choice(self.state.get_characters())
        md_writer.print_chapter_sentence(c.get_name() + ' dreamt of a ' + self.words.get_fantasy_place() + ', ' + self.words.get_fantasy_occupation() + ', and ' + self.words.get_living_thing_adj() + ' ' + pattern.en.pluralize(self.words.get_living_thing()) + '.')
        energy += 5

        self.state.add_energy(energy)