AI: Part 2 (Dating, Marriage, Divorce, Pregnancy, Children, Moving House)

Introduction

After working on the finances for the peeps AI, I worked on the familial systems. Peeps have the ability to get married, have children, grow old and die. In order to do this, complex systems need to be developed. To do this, I made separate functions for each section. For example, their is a function called "funcMarriage", which when called calculates when a peep will get married etc.

Dating

At a certain age, peeps will become attracted to other peeps. This happens in 2 stages, first in high school and then as adults. Just like real life, there are relationships in high school. These are formed when 2 peeps who are attracted to one another start dating.

Once a peep reaches the age of maturity, they start dating as an adult, and have the potential of becoming married.

If a male peep is dating a female peep, they have a chance of having children. This is a smaller chance than if they are married.

The dating function is quite complex, but in essence loops through all of the peeps in the town and checks if they are single and are the correct preference. If all prerequisites are fulfilled, then the 2 start dating.

A peep will remember this relationship by storing their partner's ID in the "lover" attribute. The list of relationship attributes are shown below.


Also, to avoid in-family dating, the previous family tree function is used to determine family members and avoid selecting them.

Peeps will have a preference for gender, and can form gay or straight relationships.

Marriage

If 2 peeps are in love and have been dating for a while, they may decide to get married. This has a few affects, such as the changing of surnames, and moving in together.

Surnames can change to either peeps' surnames or combine them to make them double-barrelled.

Any of the future spouses children will move with their parents, and change surnames as well.

Divorce

Whilst a happy peep couple may get married, others may get divorced. This occurs usually when peeps are unhappy or have personalities which increase the likelihood of separation.

One of the peeps in the marriage will eventually decide to move out, as they won't want to continue living with their ex. This can lead to the splitting of families and children.

Both marriage and divorce were easy to implement, as they just required rolling some dice and increasing/decreasing the likelihood of a set outcome.

Affairs

Some peeps are more deviant than others, and wish to chase multiple partners at the same time. This can lead to affairs, which when discovered, will lead to grudges.

A peep can get pregnant from this relationship, which can lead to step-siblings/children.

To implement this a peep can simply start dating someone else whilst already married. Relationships, of course, are reciprocal, which can lead to the destruction of 2 marriages if the relationship is found out.

The grudge system was implemented as a retaliation to cheating in a relationship. On exposing a partners secret, they will likely get divorced and move out. Grudges can make peeps angry and if a peep is enraged enough, they have the potential to murder.

Children

Peeps in a relationships (either married or dating) can have children. A peep will become pregnant for a year and then have a child with the "pregnancyFather" and their own ID as the parents.

Inheritance

Children will inherit looks from their parents. On birth, the father's and mother's appearance is used to create how they look.

Behind the scenes, this is a pretty complicated process, involving trait selection. I also worked on rendering how peeps look, which I'll document at a later stage.

Moving

Moving Out

As mentioned above, peeps will move around the town. They can do this as families, or individuals. When a peep is old enough, they will move out of their parents house.

To achieve this, an appropriate house needs to be selected. This calls another function to find a house with the right amount of bedrooms and right cost.

Moving into Town

Peeps will also move into the town as randomly generated families throughout the game. This is to prevent stagnation and promote realism. This is controlled by a variable called MAXOCCUPANCY, which is set to 60%. This means if the town has less than 60% of its houses occupied, a family may move in. (This value may be tweaked in the future).

Comments

Popular Posts