This weekend was spent exclusively on my economic model. I spent a day planning out what I wanted to do. I wanted to replicate demand and supply, curves and market behavior.
At first I simply tried to replicate the curves explicitly, with quantity supplied, quantity demanded, price and equilibriums, shortages and surpluses. I realized quickly this was folly, because that is more useful for theoretical application and to understand from a top down view of what's going on. I found this out when I tried to say "ok, well with this shortage, what should the price be."
Instead, what I implemented is two markets. A contract market and a retail market. As in real life, logistics for how food gets to the market is usually 4 steps...farms producing the food, sent to wholesalers, sent to distributors and then sent to supermarkets. Very rarely does a farmer just sell to the market itself, and rarely do customers shop at farms.
I'm going to just let the market set the price and shortages and supplies, instead of simulating it. This is actually more exciting because I have a feeling a bunch of things I can't plan for will happen in this ecosystem, and I think it'll allow for a fun game.
Currently I have customer behavior up and running. They buy from retailers when they are hungry, and seek jobs when unemployed. They start businesses when they have money for it. They shop at retailers based on market share, and they prefer foods over others, but also keep in mind the cheapest food.
Retailers seek goods from Producers, and sell food at a profit. If food doesn't sell, they lower the price. If it's all bought up, they raise the price. They can spend money on budgeting to raise their market share.
Producers use recipes to make goods. They then sell them to other producers or retailers. They acquire more recipes for goods that are in demand when they have money for it.
I think it's a quaint system for my first economic model. The only thing I did not finish this weekend was getting producers selling to retailers. Everything else was tested to make sure it works, although I'm sure there are plenty of bugs once all the systems are linked to each other.
My first design problem I faced was that there was a lot of information I needed linked to each other, specifically with the items. Each company had to keep a list of what price they're selling each good at, and to track market changes. I realized quickly I needed some type of database, but I'm unsure how to hook it up to mySQL or Access. For now, I just have a lot of little classes I'll be putting together.
The economy itself is two for loops. A for loop to go through and throw objects into lists that need to be handled later, like if a customer is hungry, they go into a hungry customer list. Then later I'll iterate through and feed them by buying goods. I obsess alot about cpu footprint, although I have a feeling I should not worry about it since this isn't going into an Update() function...this will all be turn based and only function when a button is clicked. So I wonder how many agents I can have before performance is an issue. That'll be for this weekend.
Another problem I ran into is fatigue. I haven't coded so much that I start to make obvious errors. I finally decided on Sunday to go through and put a bunch of //TODO: comments everywhere, and let my mind rest. Interesting dilemma.
For now, I'm satisfied. The customers work fine with the test data I've given it. Once the companies are up and running, everything is hooked up to constants and will be enjoying to watch my little ecosystem either fail horribly or all prosper together, or watch the companies completely dominate the daily expenses of the customers.