No resource storing! When I think about resource storing, it makes me dizzy. I want to see Elemental a bit more hardcorish, but come on - do we want a fantasy capitalism simulation? Imagine this: you have a mine. This mine can mine (pun intended) a fixed number of units of ore (UO) every day. Mine won't store it's ores anywhere - when a city needs a specific resource, this mine will mine it (I hate the word mine) and send it to the specified city. The longer the destination city is, the longer it will take for caravan to reach it's destination (is should be relatively fast). Of course whole system should be automatized.
To make it a little bit more comprehensible, I will try to walk you through a typical production chain:
1. We want to train an army of Drizzts (let's say 30x of them). Each one of them needs following 'items'/resources:
- Training (City needs to have a special (upgraded) barracks built).
- Magical sword (ie. two scimitars) & armor (provided by upgraded blacksmith who has access to mana crystals and iron).
- Recruits (let's assume we can use a typical Joe here; every city has people, so we have a nice ).
2. We press the button to create the Drizzts. Now the game looks for all needed resources and whether or not we own them.
3. If we don't have - let's say - mana crystals, the game should inform us that we don't have a specific resource, thus we won't be able to train Drizzts.
4. Of course - as you can see in the picture - we have all the needed ingredients. Now comes the hardest part.
5. Before training of Drizzts can begin in Iyawa, all the items (apart from 'training', obviously) have to be on place. One may argue that Drizzts could start training before they got their hands on magical armament, but not to confuse the player too much, we require all pieces to be in one place (the training zone).
6. First, we need people. We require 30 recruits. 30 recruits will be taken from the global number of citizens. Every city will contribute in this recruitment relatively to it's size. That is why Macira will provide more people then Safat or Tikolego. We define that every day max. 10 new recruits can be found (ie. transported to Iyawa) - despite of the placement of Iyawa (is it the center of our empire, or the outskirts). As you see, recruiting soldiers isn't hard at all and it forces the player to have enough of big cities to provide recruits for huge armies.
Indirect cost: 30 citizens, 3 days (final)
7. Second, we need iron ore. Miners can mine 50 units of ore (iron) every day. 10 UO allows you to forge 10 swords, 10 scimitars, 8 shields or 5 chain vests. For all the equipment, we need 90 UO (30 swords = 30 UO, 30 chain vests = 60 UO). So the mine needs 2 days to send them. We assume (for simplicity's sake) that the mine won't send the shipment, if it won't have enough ore packed. Of course the ore has to be transported. The distance is small, thus the shipment will take only one day. I assume that distance from Safat to Macira will take ~1 day (remember that the map is quite zoomed out); if you would like to transport it from Tikolego to Macira, it would take 2 days.
Indirect cost: 90 units of ore, 2 days (mining) + 1 day (shipment) = 3 days
8. Third, mana crystals. This case is similar to iron mine, so I will just get straight to the point.
Indirect cost: 15 units of crystals, 2 days (mining) + 1 day (shipment) = 3 days
9. Blacksmith comes as the forth. In order to start making the magical armament, he need all the ingredients in his shack, thus he has to wait 3 days (max. of all shipments). One blacksmith is able to forge 3 magical armors/3 magical weapons a day. Remember: we are always talking about 1 mana extractor, 1 mine and 1 blacksmith; more will provide us with more stuff, but there will be limit - let's say you can build max. 3 mana extractors, 3 mines, but as many blacksmiths as you wish. That is quite obvious rule - you can't extract some resource too much, but you can make as many factories as you wish (providing you have the resources available). Let's say we have 3 blacksmiths. 3 blacksmiths = 9 magical armors/weapons a day. We need 30 weapons (let's assume our Drizzt's will be a poor man's type, wielding only one blade) & 30 vests, that equals 60 magical items. 60/9 = 6.67 = 7 (of course we have to round up). So it will take 7 days (a friggin' week!) to forge these items. Don't you forget about sending it over to Iyawa. The time, of course, 1 day.
Indirect cost: 3 days (shipment) + 7 days (forging) + 1 day (shipment #2) = 11 days
10. Ufff... we have been waiting 11 days and finally we have all the parts in one place. Now the last part. Each barracks (you can build as many as you need) can take 10 recruits. The training to become a Drizzt clone takes 7 days (a week). Let's say we have 2 barracks built in our beautiful city of Iyawa - it will take 14 days to train 30 drizzts (2 barracks + 1). What's important is that we will get 20 drizzts after 18 days, so if you order to train 100 units (of any type) you won't have to wait 1 month . In other words: it's incremental build.
Time cost: Max(all resources) + training = 11 + 14 = 25 days
Resource cost: 90 units of iron + 15 units of crystals
HOW THE HECK YOU WANT TO MAKE IT SO A TYPICAL JOE WILL UNDERSTAND THIS ROCKET SCIENCE?!111!one
Everything I have presented will be fully transparent to the player! Yes, that's what I am saying. He only chooses the type, amount of units he wants to train, and he gets the estimated time. If he wants to know more info, he can always hover over the time and check the description:
- Resource cost: 90 units of iron, 10 units of mana shard
- Human resources cost: 30 citizens
- Transport time: 4 days (total)
- Manufacturing time: 7 days (total)
- Training time: 14 days (total)
Ok, so we have 1 more problem. Let's say I desperately need to build some defenses in my cities. That's where priority system comes into play. There will be 4 levels of priority: 0 stars, 1 star, 2 stars, 3 stars. The more stars, the higher the priority. If we suddenly add new units we want to build, then all the resource chain switches to provide enough resources for our needs. What does that mean? Mines will select new caravan, load it with ores and send it to blacksmith as a priority package. All other (lower priority) tasks are stalled (if they are conflicting with the important task). If two task are of the same priority, FIFO will start to work.
The last thing I would like to talk about is the resources sharing system. In the aforementioned example I assumed a simple case when we have one city with barracks, one with crystals, one with blacksmith and one with mine. But what when we have several cities having such facilities built? There's an easy answer, but I know that it would be quite a feat to write a fast algorithm for that. On the other side, nowadays we have so fast CPUs and efficient algorithms, that I don't think it's anywhere impossible. Keep in mind, that a player won't know anything about this system - he will just enjoy the game.
So, that's how I would define the algorithm:
1. Select the city in which the units are to be trained as the destination place (we don't allow training units in a few cities).
2. Find all the starting places from which we would have to obtain resources. Obviously recruits are already done (read 6th point above), so we are left with mines, crystal extractors etc.
3. Divide resources into such that can be immediately delivered to the destination (aka simple resource), and such that has to be processed (complex resource).
4. Simple resources: find production places closest to the destination. Select the closest one and find if it can deliver all the goods in the lowest possible time (it means: extraction for 1 day). If it can't, calculate the time it needs to extract all needed resources. Sort the production facilities (the rest of them) so that the closest ones (the shortest travel time) are on top. Check the delay in the travel time (comparing to the best place) and calculate whether or not it's worth choosing this location as sub-resource-supplier. If it is, than select it and check if now the shipment will be fulfilled. If not - either wait longer for extraction, or take the next supplier - and so on...
5. If case of complex resources the case is much more complicated. I don't want to define yet another algorithm, so just a short explanation:
1. Find all the start locations (mines).
2. Find all the processing locations (blacksmiths).
3. Find all the extra processing locations (super hyper something).
4. Create a matrix of nodes and interconnections.
5. Use some fancy graph algorithms or something like this and calculate
6. Get the best path and block/reserve the spaces according to priority.
Ok, that's all. Red signing out...
P.S. I got suggestion addicted .