First Week (Setup)
Background
After discontinuing the previous project, it was time to restart with everything I had learned. I had a rough idea of the basic character system which could be simplified and used again.
Terminology
The citizens in Pocket Life are known as "peeps". A peep is rather like a human being, having desires, ambitions and a strive for life.
Getting Started
Before starting, I had categorized the games development into 3 stages:
- Setup
- AI
- Player Interaction
The first stage to work on was setup. This involved the initial creation or generation of the peeps, as well as populating fundamental arrays.
The game will be centred around simulating around 100 peeps in 1 or more towns. Each peep will have variables such as:
- A first and last name
- Age
- Relationships
- Career
- Personality
- etc.
In order to store this dimension of data, I decided to use an array. The array would need to be 2 dimensional, with the peep on the x axis; variables on the y. This can be seen in the diagram below:
This allows flexibility, as I can add more variables or peeps in the future. This is paramount, as the x axis will be consistently changing throughout the game, as peeps are moving into the town and others dying.
Once this array was created, it could be populated. This can be done through stochastically generating data, or using a more deterministic approach. For example, the ID just counts up from 1, whereas the peeps' first and last name are picked at random from a couple more arrays (in this case I just downloaded the 100 most common male and female names to populate the arrays).
Generating Families
An important part of a peep's life is family. A family involves multiple peeps which are related to each other through special relationships. Families can start out simplistic with a nuclear base, but lead to much more complexity. This was a problem, because large families needed to be recognised by the game in order to simulate life.
Of course, the inevitable question arises of how would I store the families in the array. I had a few ideas, but there was little guidance online. In the previous game, I thought I could generate the entire family through just the mother and father. I hadn't thought this through however, and later came to the conclusion that this would not be possible.
Instead, I would store the ID of the peep in a brother, sister, mother, father, aunt etc. record. This would certainly make the game loop faster, however, became bloated rather quickly.
You can see the older bloated system, compared to the newer system. |
The new problem, of course, was generating the family tree from just 2 parents. I will go into greater detail in a future post.
Anyway, now that the basic variables for the peeps had been determined and the array had been setup, I could write a function which creates a family. It does this by generating the parents of the household and then, consequently, the children. This ensures that I have the ID of the parents to insert into the newly created child's father ID and mother ID record.
I could also generate single parent households, and households without children (married couples, and bachelors/bachelorettes).
A place to live
Now that the household can be generated, they need a place to live. This is another record in the array, which stores the ID of the house from another array, which stores the houses in. Think of this like a relational database, where the house ID in this case is a foreign key, which references the primary key in the housesArray.
This is so I can easily store additional information about the houses, such as number of bedrooms, price etc.
Before the family is generated, the amount of peeps in the household is selected. This then determines which house is suitable and can be picked. The house ID is then stored locally and then when a peep is generated in the household, they can appropriately populate the correct house ID.
Personality
The peeps, of course, have additional characteristics. One of which is the personality. These are like "traits", which influence a peep's decisions in life. I don't want peeps to all think alike, so this is one of the main differentiators between them.
There are 10 personalities, with an additional 2 - ugly and attractive. The 10 are based directly from the big 5 personality traits, with each opposite having a personality. For example, a peep who lacks in openness is cautious, whereas a peep who is very open is curious.
The personalities are shown below:
Personalities in the game |
Peeps will be generated with a random personality from the top row and another random personality from the bottom. This ensures that no contradictory personalities are chosen, such as a peep being both outgoing and shy.
Peeps will use their personalities each turn to influence their actions. For example, an organized peep is more likely to get promoted, a curious peep more likely to cheat.
Moods
Personalities will also affect another variable - moods. Each peep will feel a certain way. This is represented by their mood. These are just like personalities, but they are temporary, which adds more complexity and nuance to the peeps' decision making.
These moods will change annually, and can be thought of as a long term emotional state. Moods can also affect other moods, an upset peep is more likely to become depressed.
List of the moods in Pocket Life |
At the moment, there are 13 moods, which can be categorised broadly into happy, sad and angry (indicated by the colours).
The player
Finally, the player must go through a similar treatment of household and peep generation (after all the player is a peep themselves). There were 2 options for this: either generate the player separately or within the same array of peeps. I chose the latter.
At this stage of generation, the player is treated just like peeps, with moods, personalities and families being created at the start. To identify the player, I gave them the "player" tag in the relationshipTag record. This is where the relationship labels are stored, such as Father, Mother, Aunt etc.
Comments
Post a Comment