Exemple #1
0
def genname(filename):
	files = os.listdir('./Languages')
	exit = False
	generator = NameGen('Languages/' + filename)
	for i in range(20):
		print generator.gen_word()
	print '\nPress Enter to continue.'
	try:
		raw_input()
	except EOFError:
		pass
Exemple #2
0
class Hero():
	def __init__(self, hero_type, level):
		self.generator = NameGen('name_gen_file.txt')
		self.name = self.generate_name(hero_type) + " (Lvl " + str(level) + ")"
		self.level = level
		if hero_type == 'fighter':
			self.small_img = load_image(CHARACTERS, 'small_fighter')
			self.hp = level * 3 + randrange(0, level)
			self.max_hp = self.hp
			self.defense = level*1.5
		self.loot = []
		self.gold = random.randrange(1, level*2)
		self.hero_type = hero_type
		self.pos = (16, 8)
		self.path = deque()

	def generate_name(self, hero_type):
		return self.generator.gen_word()
	
	def add_loot(self, loot):
		self.loot.extend(loot)
		msg = []
		for l in loot:
			msg.append( self.name  + " looted " + str(l.quantity) + " " + str(l.name))
			if l.name == 'gold':
				self.gold += l.quantity
		return msg
	
		
	def get_action(self):
		return {'action' : 'attack', 'value' : random.randrange(self.level, self.level*3)}
	def gold(self):
		self.current_bet = self.gold_opts[self.choice]
		generator = NameGen('name_gen_file.txt')
		heroes = []
		for i in range(0,4):

			hero = Hero('fighter', randrange(1,int(max(3, self.current_bet/1000))))
			hero.name = generator.gen_word()
			heroes.append(hero)
			
		self.step2_choices = [
				{ 'name' : heroes[0].name + '(lvl ' + str(heroes[0].level) + ')', 'method' : self.hero},
				{ 'name' : heroes[1].name + '(lvl ' + str(heroes[1].level) + ')', 'method' : self.hero},
				{ 'name' : heroes[2].name + '(lvl ' + str(heroes[2].level) + ')', 'method' : self.hero},
				{ 'name' : heroes[3].name + '(lvl ' + str(heroes[3].level) + ')', 'method' : self.hero},
			]
		self.heroes = heroes
		self.model.bet = self.current_bet
Exemple #4
0
def main():
    parser = OptionParser(usage="Generate N random student records in " + "CSV format.\nUsage: %prog [options] n")
    parser.add_option("-n", "--normal-student-id", action="store_false", dest="compress_sid", default=True)
    (options, args) = parser.parse_args()

    # load generator data from language file
    generator = NameGen("name_gen/Languages/japanese.txt")

    os.chdir(compressor_dir)

    # compile the compressor which is written in C++
    compile_compressor()

    compress_if_needed = (lambda sid: compress_sid(sid)) if options.compress_sid else (lambda sid: sid)
    for i in range(int(args[0])):  # generate a few words
        print "%s,%s,%s %s,%.1f" % (
            compress_if_needed(gen_id()),
            gen_fac(),
            generator.gen_word(),
            generator.gen_word(),
            gen_gpa(),
        )
Exemple #5
0
	def __init__(self, hero_type, level):
		self.generator = NameGen('name_gen_file.txt')
		self.name = self.generate_name(hero_type) + " (Lvl " + str(level) + ")"
		self.level = level
		if hero_type == 'fighter':
			self.small_img = load_image(CHARACTERS, 'small_fighter')
			self.hp = level * 3 + randrange(0, level)
			self.max_hp = self.hp
			self.defense = level*1.5
		self.loot = []
		self.gold = random.randrange(1, level*2)
		self.hero_type = hero_type
		self.pos = (16, 8)
		self.path = deque()
Exemple #6
0
    def passTime(self, autoDateIncrease=True):
        '''
		Passes time, updating things in this order:
			1. Increase date
			2. Update moods (remove expired modifiers)
			3. Decide season events
			4. Pass time in families (subroutine).
			5. Social interactions including on-the-fly mood changes
		'''

        if autoDateIncrease:
            self.date += 1
            self.mayorTime += 1

        for p in self.allPeople():
            if autoDateIncrease:
                p.age += 1
            p.log("== {} ==".format(p.ageToString()))

        # update modifiers before everything else, to prevent added modifiers from being
        # immediately decreased in duration
        for p in self.allPeople():
            p.updateModifiers()

        self.log("==== {} ====".format(self.dateToString().upper()))
        if self.season() == 3:
            # harsh winter
            if random.randint(1, HARSH_WINTER_CHANCE) == 1:
                self.log("The winter is a harsh one")
                self.harshWinter = True
                for p in self.allPeople():
                    p.addModifier(12)  # add 'cold' modifier
            else:
                self.harshWinter = False

        if self.season() == ELECTION_SEASON and (
                self.mayorTime >= MAYOR_TERM_LENGTH or self.mayor is None):
            self.log("An election is occuring")

            # Work out who can stand for election
            # Max 3 candidates are chosen
            # Everyone recieves a suitability rating, based on their extroversion + agreeableness

            allP = self.allPeople()
            candidates = []
            lowestRating = -1
            for p in allP:
                rating = p.mayoralSuitability()
                if (rating > lowestRating
                        or len(candidates) < 3) and p.age >= MIN_MAYOR_AGE:
                    candidates.append(p)
                    candidates = sorted(candidates,
                                        key=lambda x: x.mayoralSuitability(),
                                        reverse=True)
                    if len(candidates) > 3:
                        del candidates[-1]
                    lowestRating = candidates[-1].mayoralSuitability()

            if len(candidates) < 3:
                self.log(
                    "There are not enough eligible candidates to hold an election."
                )
            else:
                # We now have the top three candidates.
                # Commence voting!
                self.log("The candidates standing are: {}, {} and {}".format(
                    candidates[0].printableFullName(),
                    candidates[1].printableFullName(),
                    candidates[2].printableFullName()))

                votes = {c: 0 for c in candidates}
                for p in allP:
                    if p.age >= MIN_VOTING_AGE:
                        lowestDiff = 1
                        chosen = None
                        for c in candidates:
                            if p == c:
                                # Always choose yourself if possible
                                lowestDiff = -1000
                                chosen = p
                            else:
                                orientationDiff = abs(
                                    p.politicalOrientation() -
                                    c.politicalOrientation())
                                # Modify by rapport
                                orientationDiff -= p.getRapport(
                                    c) * RAPPORT_VOTING_MODIFIER
                                if orientationDiff < lowestDiff:
                                    chosen = c
                                    lowestDiff = orientationDiff

                        if chosen is not None:
                            votes[chosen] += 1
                            p.log("I voted for {}".format(
                                chosen.printableFullName()))

                candidatesByVotes = sorted(votes.keys(),
                                           key=lambda x: votes[x],
                                           reverse=True)

                if votes[candidatesByVotes[0]] == votes[candidatesByVotes[1]]:
                    # Deal with a hung election
                    self.log("{} and {} are tied on {} votes".format(
                        candidatesByVotes[0].printableFullName(),
                        candidatesByVotes[1].printableFullName(),
                        votes[candidatesByVotes[0]]))

                    if self.mayor is not None:
                        self.log(
                            "{} leaves office after {} years as mayor, due to a hung election"
                            .format(self.mayor.printableFullName(),
                                    self.mayorTotalTime()))
                        self.mayor.log(
                            "I left mayoral office after a hung election".
                            format(self.mayor.printableFullName()))
                        self.mayor.logKeyEvent("left mayoral office")

                        self.mayor.isMayor = False
                        self.mayor = None
                        self.mayorFamily = None
                        self.mayorTime = 0
                        self.mayorTerms = 0
                        # Set end date for this person
                        self.endMayorTime()
                    else:
                        self.log("No mayor has been elected.")
                else:
                    # We have a winner! It doesn't need to be a majority, just the highest vote count.
                    winner = candidatesByVotes[0]

                    # Add lost election modifiers
                    candidatesByVotes[1].addModifier(19)
                    candidatesByVotes[2].addModifier(19)

                    if self.mayor is not winner:
                        self.log("{} wins with {} votes".format(
                            winner.printableFullName(), votes[winner]))
                        winner.logKeyEvent("became mayor")
                        winner.log("I became mayor")
                        winner.addModifier(18)
                    else:
                        self.log("{} continues in office with {} votes".format(
                            winner.printableFullName(), votes[winner]))
                        self.mayorTerms += 1

                    self.log("2nd: {} with {} votes".format(
                        candidatesByVotes[1].printableFullName(),
                        votes[candidatesByVotes[1]]))
                    self.log("3rd: {} with {} votes".format(
                        candidatesByVotes[2].printableFullName(),
                        votes[candidatesByVotes[2]]))

                    if self.mayor is not None:
                        if self.mayor is not winner:
                            self.log(
                                "{} leaves office after {} years as mayor".
                                format(self.mayor.printableFullName(),
                                       self.mayorTotalTime()))
                            self.mayor.log(
                                "I left mayoral office, beaten by {}".format(
                                    winner.printableFullName()))
                            self.mayor.logKeyEvent("left mayoral office")
                            # Set end date for this person
                            self.endMayorTime()
                        self.mayor.isMayor = False

                    if self.mayor is not winner:
                        # Set start date for this person
                        self.startMayorTime(winner)
                        self.mayorTerms = 0

                    # Actally set the mayor variables
                    self.mayor = winner
                    self.mayorTime = 0
                    self.mayorFamily = self.mayor.family
                    self.mayor.isMayor = True

        # Decide whether to trigger 'invading army' event
        if len(self.families
               ) > COMMUNITY_FAMILY_LIMIT and COMMUNITY_FAMILY_LIMIT != 0:
            namegen = NameGen()
            factionName = namegen.factionName()
            self.log("An invading army, {}, is passing through the community".
                     format(factionName))
            for i in range(ATTACK_KILL_AMOUNT):
                fInd = random.randint(0, len(self.families) - 1)
                f = self.families[fInd]
                self.log("The {} family is wiped out by the attack".format(
                    f.familyName))
                for p in f.people:
                    p.die()
                self.removeFamily(f)
                self.deadFamilies.append(f)

        # Decide whether to trigger 'family joins event'
        if len(self.families) < COMMUNITY_FAMILY_MIN:
            for i in range(COMMUNITY_FAMILY_JOIN):
                # generate family
                tempFam = Family(self)
                p1 = Person([None, None],
                            gender="male",
                            age=random.randint(18 * 4, 25 * 4),
                            married=True)
                p2 = Person([None, None],
                            gender="female",
                            age=random.randint(18 * 4, 25 * 4),
                            married=True)
                p1.partner = p2
                p2.partner = p1
                p1.updateRapport(p2, START_RELATIVE_RAPPORT)
                p2.updateRapport(p1, START_RELATIVE_RAPPORT)
                tempFam.addPerson(p1)
                tempFam.addPerson(p2)

                for j in range(random.randint(2, 4)):
                    child = tempFam.generatePerson([p1, p2],
                                                   age=random.randint(
                                                       0,
                                                       START_CHILDREN_MAX_AGE))
                    p1.children.append(child)
                    p2.children.append(child)
                    p1.updateRapport(child, START_RELATIVE_RAPPORT)
                    p2.updateRapport(child, START_RELATIVE_RAPPORT)

                self.addFamily(tempFam)
                self.log(
                    "The {} family, a family of {}s has joined the community".
                    format(tempFam.familyName, tempFam.profession))

        for f in self.families:
            if len(f.people) == 0:
                # everyone's died
                self.log(
                    "The old house of the {} family is left deserted".format(
                        f.familyName))
                self.removeFamily(f)
                self.deadFamilies.append(f)
            else:
                f.passTime(self.date % 4, self.harshWinter)

        for p in self.allPeople(minAge=START_INTERACTION_MIN_AGE):
            # A person interacts with 0-10 people per day, based on extroversion
            interactions = math.ceil(p.getAttr("e") * 10)
            if p.isMayor:
                interactions = math.ceil(interactions * MAYOR_INTERACTIONS_MOD)
            for i in range(math.ceil(p.getAttr("e") * 10)):
                # This next bit works by mapping by rapport. Basically,
                # a person will be more likely to initiate social interactions
                # with someone who they have more rapport with.
                mappedByRapport = {}
                totalRapport = 0
                for i in self.allPeople():
                    if i == p:
                        continue

                    mappedByRapport[i] = p.getRapport(
                        i) + 1  # +1 to make positive

                    # Younger people will want to talk to people of their own age.
                    # So, decrease the mapping by a number based on age.
                    # How does the formula work? Black magic and duct tape.
                    # Of course, this doesn't apply to family.
                    # This assumes that there is no age prejudice above 16 - TODO?
                    if i not in p.family.people:
                        addition = (8 - abs((i.age - p.age) // 4)) * max(
                            0, ((16 * 4 - p.age) / 16 * 4))
                        mappedByRapport[i] = max(0,
                                                 mappedByRapport[i] + addition)

                    totalRapport += mappedByRapport[i]

                # Choose a person to interact with randomly, but weighted by rapport
                chosenNum = random.uniform(0, totalRapport)
                currentNum = 0
                for b in mappedByRapport.keys():
                    if currentNum + mappedByRapport[b] >= chosenNum:
                        # we have our person!
                        # Interactions produce rapport. The person initating the
                        # conversation gains more rapport for that person than the
                        # person does for the initiator.
                        if p.likes(b) and b.likes(p):
                            if random.randint(
                                    1, DT_CHANCE
                            ) == 1 and p.age > DT_MIN_AGE and b.age > DT_MIN_AGE:
                                # deep talk
                                p.updateRapport(
                                    b,
                                    DT_RAPPORT_GAIN *
                                    (p.calculateCap(b) / CAP_MODIFIER))
                                b.updateRapport(
                                    p,
                                    DT_RAPPORT_GAIN *
                                    (b.calculateCap(p) / CAP_MODIFIER) *
                                    INTERACTED_WITH_MOD)
                                p.log("I had a deep talk with {}".format(
                                    b.printableFullName()))
                                b.log("{} had a deep talk with me".format(
                                    p.printableFullName()))

                                # For now, this can lead to a partnership
                                # TODO change wording and other stuff for existing partner
                                if p.romanticallyLikes(b) and p.age >= MIN_ASKOUT_AGE\
                                 and b.age >= MIN_ASKOUT_AGE and not p.married and not b.married\
                                 and not p.isRelative(b) and p.gender != b.gender\
                                 and ((p.timeWithPartner >= 2 and b.timeWithPartner >= 2) or
                                  (p.partner is None and b.partner is None)):
                                    cont = True
                                    # A person will only abandon a partner if the romantic interest
                                    # to a new person is higher
                                    if p.partner is not None:
                                        if p.calculateRomanticInterest(
                                                p.partner
                                        ) >= p.calculateRomanticInterest(b):
                                            cont = False
                                    if b.partner is not None:
                                        if b.calculateRomanticInterest(
                                                b.partner
                                        ) >= b.calculateRomanticInterest(p):
                                            cont = False

                                    if cont:
                                        p.log("I asked out {}".format(
                                            b.printableFullName()))
                                        b.log("{} asked me out".format(
                                            p.printableFullName()))
                                        if b.romanticallyLikes(p):
                                            b.log("I accepted {}'s proposal".
                                                  format(p.firstName()))
                                            p.log("{} accepted my proposal".
                                                  format(b.firstName()))
                                            self.log(
                                                "{} and {} are now going out".
                                                format(p.printableFullName(),
                                                       b.printableFullName()))

                                            if b.partner is not None:
                                                b.breakUp()
                                            if p.partner is not None:
                                                p.breakUp()

                                            b.partner = p
                                            p.partner = b
                                            b.addModifier(4)
                                            p.addModifier(4)
                                        else:
                                            b.log("I declined {}'s proposal".
                                                  format(p.firstName()))
                                            p.log("{} rebuffed me".format(
                                                b.firstName()))
                                            p.addModifier(
                                                16)  # add rebuffed modifier
                            else:
                                # quick chat
                                p.updateRapport(
                                    b,
                                    CHAT_RAPPORT_GAIN *
                                    (p.calculateCap(b) / CAP_MODIFIER))
                                b.updateRapport(
                                    p,
                                    CHAT_RAPPORT_GAIN *
                                    (b.calculateCap(p) / CAP_MODIFIER) *
                                    INTERACTED_WITH_MOD)
                                p.log("I had a quick chat with {}".format(
                                    b.printableFullName()))
                                b.log("{} had a quick chat with me".format(
                                    p.printableFullName()))
                        else:
                            if p.isRelative(b):
                                famMod = FAMILY_ARGUMENT_MOD
                            else:
                                famMod = 1

                            # Decide whether to initiate a fight
                            fought = False
                            if p.getRapport(
                                    b
                            ) <= FIGHT_MAX_RAPPORT and p.age > FIGHT_MIN_AGE:
                                chance = max(
                                    2, FIGHT_BASE_CHANCE -
                                    (p.getAttr("e") * 2 + p.getAttr("n") * 2))

                                if random.uniform(0, chance) <= 1:
                                    p.updateRapport(
                                        b, FIGHT_RAPPORT_GAIN *
                                        INTERACTED_WITH_MOD * famMod)
                                    b.updateRapport(
                                        p, FIGHT_RAPPORT_GAIN * famMod)
                                    p.log("I started a fight with {}".format(
                                        b.printableFullName()))
                                    b.log("{} started a fight with me".format(
                                        p.printableFullName()))
                                    if random.randint(1,
                                                      FIGHT_DEATH_CHANCE) == 1:
                                        if random.randint(1, 2) == 1:
                                            self.log(
                                                "{} killed {} after {} started a fight"
                                                .format(
                                                    p.printableFullName(),
                                                    b.printableFullName(),
                                                    p.firstName()))
                                            b.die()
                                            if p.sociopathy(
                                            ) >= SOCIOPATH_THRESH:
                                                p.log(
                                                    "I killed {}, but feel no remorse."
                                                    .format(b.firstName()))
                                            else:
                                                p.log(
                                                    "I killed {}. I feel terrible."
                                                    .format(b.firstName()))
                                                p.addModifier(21)
                                        else:
                                            self.log(
                                                "{} killed {} in self-defence after {} started a fight"
                                                .format(
                                                    b.printableFullName(),
                                                    p.printableFullName(),
                                                    p.firstName()))
                                            p.die()
                                            if b.sociopathy(
                                            ) >= SOCIOPATH_THRESH:
                                                b.log(
                                                    "I killed {} in self-defence, but feel no remorse."
                                                    .format(p.firstName()))
                                            else:
                                                b.log(
                                                    "I killed {} in self-defence."
                                                    .format(p.firstName()))
                                                b.addModifier(22)
                                    fought = True

                            if not fought:
                                if b.age > MIN_ARGUMENT_AGE and p.age > MIN_ARGUMENT_AGE:
                                    p.updateRapport(
                                        b, ARGUMENT_RAPPORT_GAIN *
                                        INTERACTED_WITH_MOD * famMod)
                                    b.updateRapport(
                                        p, ARGUMENT_RAPPORT_GAIN * famMod)
                                    p.log("I had an argument with {}".format(
                                        b.printableFullName()))
                                    b.log("{} had an argument with me".format(
                                        p.printableFullName()))
                                else:
                                    p.updateRapport(
                                        b, ANGRY_LOOK_RAPPORT_GAIN *
                                        INTERACTED_WITH_MOD * famMod)
                                    b.updateRapport(
                                        p, ANGRY_LOOK_RAPPORT_GAIN * famMod)
                                    p.log("I gave {} an angry look".format(
                                        b.printableFullName()))
                                    b.log("{} gave me an angry look".format(
                                        p.printableFullName()))

                        break
                    else:
                        currentNum += mappedByRapport[b]
Exemple #7
0
#get all available language files
files = os.listdir('./Languages')

exit = False
while not exit:
    print 'Select a language file: (any other input to quit)\n'

    #present all available files as options
    for (id, file) in enumerate(files):
        print id, ': ', file

    #interpret option number, if anything goes wrong quit
    try:
        filename = files[int(raw_input())]
    except ValueError or IndexError:
        break

    #load generator data from language file
    generator = NameGen('Languages/' + filename)

    #generate a few words
    for i in range(20):
        print generator.gen_word()

    #pause (wait for some input)
    print '\nPress Enter to continue.'
    try:
        raw_input()
    except EOFError:
        pass
files = os.listdir("./Languages")


exit = False
while not exit:
    print "Select a language file: (any other input to quit)\n"

    # present all available files as options
    for (id, file) in enumerate(files):
        print id, ": ", file

        # interpret option number, if anything goes wrong quit
    try:
        filename = files[int(raw_input())]
    except ValueError or IndexError:
        break

        # load generator data from language file
    generator = NameGen("Languages/" + filename)

    # generate a few words
    for i in range(20):
        print generator.gen_word()

        # pause (wait for some input)
    print "\nPress Enter to continue."
    try:
        raw_input()
    except EOFError:
        pass
Exemple #9
0
    def initUI(self):

        # Create the menu bar
        menu = self.menuBar()
        fileMenu = menu.addMenu('&File')
        # editMenu = menu.addMenu('&Edit')
        # viewMenu = menu.addMenu('&View')
        # toolsMenu = menu.addMenu('&Tools')

        # File Menu Setup
        # File Menu - New option configuration
        newAct = QtWidgets.QAction('&New', self)
        newAct.setShortcut('Ctrl+N')
        newAct.setStatusTip('Create a new character')

        # File Menu - Open option configuration
        openAct = QtWidgets.QAction('&Open', self)
        openAct.setShortcut('Ctrl+O')
        openAct.setStatusTip('Open a previously saved character')

        # File menu - Save option configuration
        saveAct = QtWidgets.QAction('&Save', self)
        saveAct.setShortcut('Ctrl+S')
        saveAct.setStatusTip('Save character')

        # File menu - Save As option configuration
        saveasAct = QtWidgets.QAction('Sa&ve as', self)
        saveasAct.setStatusTip('Save character as')

        # File menu - Quit option configuration
        quitAct = QtWidgets.QAction('&Quit', self)
        quitAct.setShortcut('Ctrl+Q')
        quitAct.setStatusTip('Exit application')
        quitAct.triggered.connect(QtWidgets.qApp.quit)

        # Add actions to the file menu
        fileMenu.addAction(newAct)
        fileMenu.addAction(openAct)
        fileMenu.addAction(saveAct)
        fileMenu.addAction(saveasAct)
        fileMenu.addAction(quitAct)
        """
        Menus are still a work in progress
        """
        # Edit Menu Setup
        # editMenu = menu.addMenu('&Edit')
        print("PyCGen -- main.py: InProg message -- TODO: Add edit menu stuff")

        # View Menu Setup
        # viewMenu = menu.addMenu('&View')
        print("PyCGen -- main.py: InProg message -- TODO: Add view menu stuff")

        # Tools Menu Setup
        ng = NameGen()
        toolsMenu = menu.addMenu('&Tools')
        nameGenAct = QtWidgets.QAction('Name &Generator', self)
        nameGenAct.setShortcut('Ctrl+G')
        nameGenAct.triggered.connect(lambda: ng.show())

        toolsMenu.addAction(nameGenAct)

        # Handle the status bar
        self.statusBar().showMessage('Status: ')

        # Set Window Geometry and display it
        self.showMaximized()
        self.setWindowIcon(QtGui.QIcon('pycgen_icon.png'))
        self.setWindowTitle('PyCgen')

        self.table_widget = MyTableWidget(self)
        self.setCentralWidget(self.table_widget)

        self.show()
Exemple #10
0
#!/usr/bin/env python3

import random
import math
from namegen import NameGen
from person import Person
from config import *

nameGen = NameGen()


class Family:
	'Base family class'
	__professions = PROFESSIONS

	def __init__(self, community, familyName=None):
		self.people = []
		self.deadPeople = []
		self.food = 0
		self.profession = random.choice(self.__professions)
		self.eventLog = []
		self.community = community

		if familyName is not None:
			self.familyName = familyName
		else:
			self.familyName = nameGen.last()

	def addPerson(self, p, preserveSurname=False):
		if not preserveSurname:
			p.setSurname(self.familyName)
Exemple #11
0
	def passTime(self):
		if self.partner is not None and not self.married:
			self.timeWithPartner += 1
			# decide whether to break up
			if self.timeWithPartner >= 2 and not self.romanticallyLikes(self.partner):
				self.breakUp()

			if self.partner is not None:
				# Since conscientiousness reflects spontaneity, modify the base time an average *2 (= the sum)
				minMarriageTime = BASE_MARRIAGE_MIN_TIME * (self.getAttr("c") + self.partner.getAttr("c"))
				if self.timeWithPartner >= minMarriageTime and self.age >= MARRIAGE_MIN_AGE and\
					self.partner.age >= MARRIAGE_MIN_AGE:
					# Get married! Other marraige conditions can go here in the future
					if self.romanticallyLikes(self.partner) and self.partner.romanticallyLikes(self):
						self.marryPartner()
		else:
			self.timeWithPartner = 0

		if self.married and self.partner.alive:
			# Decide whether to have baby, but only if married, and both people
			# still are attracted to each other. Chance of baby decreases with number of
			# children.
			# probably a bad way to find lowest age
			if len(self.children) > 0:
				lowestAge = self.children[-1].age
			else:
				lowestAge = 4

			if lowestAge > 3 and\
				len(self.children) < BABY_MAX_AMOUNT and\
				self.romanticallyLikes(self.partner) and self.partner.romanticallyLikes(self):
				if random.randint(1, BASE_BABY_CHANCE*(len(self.children)+1)) == 1:
					child = self.family.generatePerson([self, self.partner])
					if self.gender == "female":
						self.log("I gave birth to {}".format(child.firstName()))
						self.family.community.log("{} gave birth to {}".format(self.printableFullName(),
							child.firstName()))
					else:
						self.log("My wife gave birth to {}".format(child.firstName()))
						self.family.community.log("{} gave birth to {}".format(self.partner.printableFullName(),
							child.firstName()))
					self.children.append(child)
					self.partner.children.append(child)
					self.addModifier(15)
					self.partner.addModifier(15)

		# life expectancy is calculated by another random truncated gaussian distribution
		if self.age > self.lifetime:
			self.die()
			return True

		if self.partner is None:
			friends = self.countFriends()
			if friends[0] <= MAX_ARMY_BEST_FRIENDS and friends[1] <= MAX_ARMY_FRIENDS and\
				self.age >= MIN_ARMY_AGE and self.age <= MAX_ARMY_AGE and self.gender == "male"\
				and not self.isMayor:
				# Whether someone wants to join the army is a function of conscientiousness
				multiplier = 10
				armyChance = multiplier*(BASE_ARMY_CHANCE - self.getAttr("c")*2)
				if random.randint(1, math.ceil(armyChance)) <= multiplier:
					self.log("I left the community to join the army")
					self.family.community.log("{} has left the community to join the army at the age of {}".format(
						self.printableFullName(), self.ageToString()))
					self.family.removePerson(self)

		# Randomly generate a great work
		if self.getAttr("i") > GW_INT_THRESH and self.age >= GW_MIN_AGE:
			prob = int(round((1.5-self.getAttr("i")) * (1.5-self.getAttr("c")), 2)*100)
			if random.randint(1, prob) == 1:
				op = self.getAttr("o")
				ar = self.artistic
				workDesc = ""
				if op >= 0.5:
					if ar == "musician":
						workTypes = [("opera", "an opera"), ("symphony", "a symphony"),
							("suite", "a suite"), ("concerto", "a concerto")]
						choice = random.choice(workTypes)
						workDesc = "composed "+choice[1]
					elif ar == "artist":
						workTypes = [("painting", "painted a painting"), ("sculpture", "made a sculpture"),
							("fresco", "painted a fresco"), ("exhibition", "organised an exhibition")]
						choice = random.choice(workTypes)
						workDesc = choice[1]
					elif ar == "author":
						workTypes = [("novel", "a novel"), ("epic", "an epic"),
							("play", "a play"), ("poem", "a poem")]
						choice = random.choice(workTypes)
						workDesc = "wrote "+choice[1]
				else:
					workTypes = [("treatise", "a political treatise"), ("paper", "a scientific paper"),
						("speech", "a speech")]
					choice = random.choice(workTypes)
					workDesc = "wrote "+choice[1]

				nameGen = NameGen()
				workTitle = nameGen.workTitle()
				fullTitle = workDesc + ", '" + workTitle + "'"
				self.log("I {}".format(fullTitle))
				self.family.community.log("{} {}".format(self.printableFullName(), fullTitle))
				self.logKeyEvent("{}".format(fullTitle))
				self.family.community.greatWorks.append(
					["{}: '{}'".format(choice[0], workTitle), self.printableFullName(), self.family.community.date])

				self.addModifier(20)

		# mood level at which someone will commit suicide is currently
		# TODO Could be a function of something in future?
		suicideLevel = SUICIDE_MIN_MOOD_LEVEL
		if self.getMood() <= suicideLevel and not self.isChild():
			self.family.community.log("{} attempted suicide".format(self.firstName()))
			self.log("I attempted suicide")
			self.die()  # TODO - maybe not every time
		elif self.getMood() <= -1.3:
			self.log("I'm feeling very bad")
		elif self.getMood() > 1.3:
			self.log("I'm feeling really good")
		elif self.getMood() > 2:
			self.log("I'm feeling euphoric")

		# Rapport decays towards 0 by a set value per season
		for r in self.rapport.keys():
			if self.getRapport(r) >= RAPPORT_DECAY:
				self.updateRapport(r, -RAPPORT_DECAY)
			elif self.getRapport(r) <= -RAPPORT_DECAY:
				self.updateRapport(r, RAPPORT_DECAY)
			else:
				self.rapport[r] = 0