Differentiating NPC and Player agents

posted in KrisWolfe
Published May 18, 2019
Advertisement

The refactoring of the market code is trucking along. I've learned so much about C# and programming since I first wrote it, and my design has changed since then, so I'm using the old pseudocode as my template while rewriting the class itself. It's not really hard. My new code looks like this:

NewMarketCode.JPG.4ff67ccd01d42ecd9514a255a6e8bf01.JPG

Compared to my old code where I would loop through the agents List and then loop through all the companies that the agents owned...now that's handled internally to the class itself:

OldMarketCode.thumb.JPG.4e728b8746cf086e9ee1fdc022f7951b.JPG

This solves one of the things that was rubbing me wrong while coding. I hate casting. It feels so wrong. Now, instead of telling the market code which type of company it is, the company itself would know what type of company it is and just do what it needs to be done. The function "Beginning of Day" will be different for each type of company. The only thing it really needs is the properties from the market class, which I pass along in the call to the internal functions.

So now we have this delegation of tasks to internal classes. I ran into an issue with the "GetAJob" function. Before, it was just abstracted out to the companies to decide what the job was. But with an actual economy rolling along, we're going to need to differentiate them. We also want NPC's to have different productivity based on how well they are at the job.

We start with the simplest type of companies. Producers. These are your iron mines, or farms, or anything that creates goods from "nothing". In the real world, we have mineral rights and finite resources, but I don't think I really want to go into that. So my base company will just create goods, with their only costs being utilities, rent and salaries. No licenses, no natural finite resources, no fertilizer. Just creating goods from nothing.

So, we need a job type of "Good Maker". I don't want to differentiate industries at this level. I want you to just start up a company, it has to buy a recipe from lets say the government, and then start making whatever good that recipe calls for. So the job is just to execute whatever recipe we have. So what if we have two recipes? I think I'm just going to disable that option, force the player to buy a second company if they want a different recipe. It doesn't really add much to "fun" or the economy if one company can have multiple recipes. Besides, in the real world you want to focus on core competencies anyways.

So right now, the recipes require a certain amount of employees. Once you've hit that threshold, it starts producing the good. What I want is that the more employees you have, the faster you create goods. The better an employee is at creating goods, the more goods they make, and so on. Is it realistic to make 0.1 of a good everyday? Why yes, it is...in manufacturing companies, they have three inventory accounts: Raw materials, work in progress, and finished goods. So half a good would be a good that is halfway through the conversion process in the work in progress inventory account. So it makes sense.

So you keep hiring employees while it's profitable. What if an NPC doesn't have the skill required? Well it's created in the skill set and they start earning hours. Their productivity will be a function of how many hours they've spent on that skill.

So now back to the function "GetAJob". What do we want an NPC that doesn't have a skill to do? In the real world, most people just get a job in their best skill. But that's not always true. Sometimes people just want to do something new. So we want a chance for an NPC to go and get a job for something he's not really qualified for...maybe lie on the resume. You know, all going back to "committing Fraud". So what I think I'm going to have to do with NPC's, is that they don't actually check the skill of the NPC that they're hiring. People can slip through the cracks. And this allows for chaos in the skill system, allowing NPC's to have all kinds of skills instead of just whatever skill I assign them on initiation. I want to think of NPC's like loot...they have 2-6 different skills, and they can roll higher productivity on skills, and eventually earn higher skills through hard work anyways. Or, god forbid, a lowly entry position employee somehow getting to be CEO of a company.

So the market decides demand, and NPC's will adjust their asking salaries on how that goes. Businesses will also be evaluating their NPC's, and if they aren't profitable, they'll likely be fired. Layoff's and what not, which should be pretty easy with producers. You check what the market price for a good is, you can easily calculate the marginal cost of each employee, and if they're unprofitable fire them.

So we have this balance of NPC's getting one over on the companies that hire them by obtaining a salary that they might not deserve, and companies periodically checking the marginal cost of those employees.

But now, we have our first branch off between NPC's and players. None of this really applies to players. They're not going to get randomly assigned skills. The player choose what job they want to do, and begin earning hours in that job. We will also have free time to work on skills and get better to be more hireable. I don't want the player to be forced into owning companies, they can just work for businesses and focus on their skills and leisure time.

So now we need NPC Skills, NPC Skill Database, and NPC Agents that are different from player agents. Interesting stuff. Looking forward to getting this up and running.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement