Need an article/info/study/algorithm/idea about managing economic resources for a real time game like The Settlers

Started by
7 comments, last by BBeck 7 years ago

Hello,

Recently, I asked this question on gamedev.stackexchange.com but it wasn't the right place to ask. So, I take my chances here now :)
http://gamedev.stackexchange.com/questions/139212/any-algorithm-which-manages-economic-resources-according-to-supply-and-demand-in

Basically, I am developing a game very much similar to The Settlers. It's a real time economy management strategy game. Player only places buildings onto the map and all the other work is done by the little guys who live and work in those buildings. They cut trees and stones, bring gathered resources back to their own buildings. Other guys go get those resources and convert them into other resources in their of buildings.

So, I guess, all this transportation and resource management system must be implemented according to supply/demand logic and available carriers. There must be a resource allocation logic for carriers too so the other carriers don't try to fetch the same resources while the first carrier start walking to the resources he decided to carry.

I know it's an overwhelming topic. I can implement and try my own system via trial and error method but I wanna know if there are any article/study/algorithm on internet which I can take a look.

The Settlers is a giant game serries and there are many more Settlers-like games out there so I guess there must be some resources on internet but I can't find one.

This is my proof of concept video of the game I'm developing. Just sharing it here so you can get the idea better.

Any info/tip would be very helpful.

Thank you.

Advertisement

It is a great game series, and each game includes a complex set of systems. I was hooked with the first one (Serf City: Life is Feudal).

I guess, all this transportation and resource management system must be implemented according to supply/demand logic and available carriers. There must be a resource allocation logic for carriers too so the other carriers don't try to fetch the same resources while the first carrier start walking to the resources he decided to carry.

For most of the games, I suspect it is a matter of picking destinations for the objects.

If I were to implement it, having only played the game and given minimal thought to the implementation, I think I'd stick a destination target on the individual resources.

Resource sources generate items until their local storage is full. They have no destination, they just sit there.

Resource consumers might search the world until they find an unallocated item. I think I'd implement it as a breadth-first tree traversal spiraling out from my own location in the world's graph. When you find an unallocated item, set the item's destination to the consumer.

Note how in most of the series, warehouse buildings allow you to toggle each item: the warehouse can be a source, a consumer, or neutral.

For a carrier, if there is an item with a destination, carry it there using regular pathfinding. Different versions of the games had different rules there, some had carriers assigned to specific road segments carrying them end to end, others could travel freely.

No matter how you store it (a table, a tree, a graph) the economy system can be reduced to a graph problem, so all the graph processing algorithms can be applied.

@frob, thank you for your answer but I am more interested in a written source like an article,guide, blog or something. Can't believe no one published such stuff on the great sea of Internet before :(

University courses in AI teaches many methods to solve factory production problems so you can find it in most course books about AI.

You might want to separate the AI into multiple systems doing their own things before you complicate it further.

* Diplomacy (When to start a war)
* Warfare (Who to attack when at war)
* Resources (How to reach the number of wanted soldiers)

Each state of a resource has a counter and a whole set of those make a world state. Rather than storing a list of hammers with different properties, you have a counter for each possible combination of properties that matters to the AI. NumberOfBrokenHammers, NumberOfNewHammers...

Each action consumes or borrows resources/workers, takes a certain time to complete and produces resources/workers/buildings when completed.

In each tick of the production schedule, calculate a number of possible scenarios with simplified game logic a few minutes into the future and use heuristics on the final results to estimate a score based on available resources. Remember the best solution for the next tick and refine it by consuming the time that passed and filling with new random guesses at the end. Each random guess may use as much as they want from the previously optimal plan but may only randomize the plan after the point of change since reuse of actions after a change makes no sense.

Within a random walk, add random actions until no more actions can be added, step over time to let actions in the list be completed and return the investments. The generation of random actions should be constrained by a primitive reflex system that prevents doing things that can easily be proven to be suboptimal like not producing wood when the stockpile is full.

This is inspired by the Monte Carlo method that is easy to implement as long as you keep things simple.
https://en.wikipedia.org/wiki/Monte_Carlo_method

@Dawoodoz thank you for your detailed answer but I guess you are more like thinking about duration based "start production now, calculate the the result after the duration" kind of games (mostly web and mobile strategy games). The settlers is realtime and 100% deterministic simulation. The workers pick the resources from the storage buildings by actually walking there in real time, bring the resources to their own factory buildings, process them 1 by 1 and carry the final products back to storage building. The player can sit and watch the entire production cycle in realtime. Because of all these reasons, there is a need for an algorithm which tracks the supply and demand points on the map, number of available resources in different locations, and the available carriers and their locations so, such algorithm may decide to give orders to specific carriers to carry specific resources to specific destinations. I can try to implement such system(I already did somehow) but there are so many unknowns. That's why I am looking for an article about such algorithm written by people who already has experience in this field.

I guess nobody knows about a good resource about this topic on Internet :(

I am more interested in a written source like an article,guide, blog or something. ... I guess nobody knows about a good resource about this topic on Internet

They do, and you have been directed to them. You are just looking for the wrong things.

There is no blog of "Build your full-featured AAA game".

There are plenty of resources for specific algorithms and data structures you will need.

Perhaps as a parallel, you won't find a guide that says "Build your own car from scratch!" But you will find instruction on how to do all the individual parts, how to weld in general, how to weld all the body parts, how to tear down an engine, how to put together each part of an engine, and so on.

There is plenty of information on each part, you need to do the work of putting the parts together in a way that works for you.

@frob Thank you for your suggestion but I think I have to explain my situation more clearly.

I am a very experienced software engineer. I am not a newbie programmer who is looking for random copy-paste solutions. I am well educated and experienced about all those parts you are giving me example of. I developed more complex systems than this economy simulation games in my personal, educational and professional life. Of-course, I can utilize one or more well know algorithms and add my own twist to them in order to implement a fully functional simulation system. The problem is, from my life-long experience, I learned that, trying to implement a complex system takes so much time and effort. Before starting this journey, I would like to gather as much information as I can to be able to reduce the amount of mistakes, pains during development. Because I know that there are some people who has great experience on this topic than me. If I could find a great article about developing such economy simulation system, it would help me a lot after I start the development journey.

In short, right now, I am in a "research phase" (which I can learn from the people who already has experience on this topic) instead of a "dive in and try to develop phase" (which will cost a lot) That's why I am only looking for guidance to existing articles. The game described in such article may be very different than my game idea but the entire article can provide great knowledge about the big picture which I can't imagine right now because of lack of experience.

Thank you guys for your effort and time trying to help me here.

The problem is, from my life-long experience, I learned that, trying to implement a complex system takes so much time and effort. Before starting this journey, I would like to gather as much information as I can to be able to reduce the amount of mistakes, pains during development. Because I know that there are some people who has great experience on this topic than me. If I could find a great article about developing such economy simulation system, it would help me a lot after I start the development journey.
I agree it's a lot of work. I disagree however that articles that you look for, give much help.

They can be insightful yes, but what they usually don't tell is why other solutions don't work, or when their solution will break down. In about 100% of the cases, your situation and ideas are different from theirs, so how do you know their solution is applicable to your case?

Much of the pain and mistakes is not about pain and mistakes, it's about getting a deeper understanding of your problem. You make a mistake, because somewhere along the line, you forgot to consider X, which later in the development proves to be crucial in making things work.

To successfully build a complex system, you need to know all X-es that exist so you can avoid them. Articles don't explain them, in my experience.

I have never worked on a project like that, but if I were to start on something like that, I think I would want to learn about economics in general. For that you might want to read "Naked Economics: Undressing the Dismal Science" it is a really good book that explains how everything boils down to supply and demand regardless of whether money is involved.

This topic is closed to new replies.

Advertisement