Page 2 of 7 FirstFirst 123456 ... LastLast
Results 11 to 20 of 62

Thread: An attempt at mapping using economics.

  1. #11

    Default

    You might look into academic use of agent-based programming, which has been used to understand the ecology of
    human settlement during the medieval warm period in what became the US southwest, think Mesa Verde and the
    Anasazi peoples. It treats the map as a productive surface of varying qualities, and set loose a small number of
    agents that behave like a family of paleo Native Americans: gather food, fuel, build, garden, age, reproduce and
    split up when a locality becomes too crowded. As I recall, there is specialized Linux software to host this kind of programming.

  2. #12
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    Thanks Marc. I had not even heard of agent based programming. It seems this path has been well trod ! As you can gather I am not particularly into AI or game theory etc but just into the idea that this might be a good way to make maps. The wikipedia entries are a good start:

    http://en.wikipedia.org/wiki/Agent-B...onal_Economics
    http://en.wikipedia.org/wiki/Rational_agent

    its fascinating how my language used to describe what I wanted is so closely matched to these articles.

    I briefly considered using prolog as the main language since its declarative. Then I thought maybe I could write this in GnuMake then gave up on both ideas and reasoned that id need to write my own declarative language or engine to drive it in this way. And I can see that I am not alone there either...

    http://en.wikipedia.org/wiki/GOAL_Ag...mming_Language

    which seems similar to what I am doing except that my notation is totally different (They even mention the rules being in prolog format). Its also interesting that I had in my mind some ideas about trying to reprogram the rules after this map exercise to see if it would predict real world economics and I can see thats what people have been doing all this time with them already. Yeah so thats opened up a whole can of goodness right there. I always seem to find this. I think of a really good idea. Wait for ages for someone to implement it and see nothing for years and then as soon as I start its pointed out that its been done to death. C'est la vie.

  3. #13
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    As much as I very much appreciate the new info its taken the shine off my new results which I was quite pleased about.

    If I set my newly spawned human male (Called Andy) to be healthy but thirsty, hungry, without rest or wealth and run it up then it gives:
    Code:
    Character Andy would like to be drinking water.
    They need the following:
    1.000000 Bucket(s) of at least 50.000000% quality Fresh water
      which is available by moving 9,19 to 19,29.
      and it is free for the taking.
    If I make him less thirsty then:
    Code:
    Character Andy would like to be eating harvested crops.
    They need the following:
    1.000000 Sack(s) of at least 50.000000% quality Harvest
      which would be available right here.
      if they start by planting seed.
    If I make him less hungry then:
    Code:
    Character Andy would like to be resting in shack.
    They need the following:
    1.000000 Shack(s) of at least 100.000000% quality Wooden Shack
      which would be available right here.
      if they start by chopping down trees.
    and if rested then:
    Code:
    Character Andy would like to be building a shack.
    They need the following:
    1.000000 Arm load(s) of at least 100.000000% quality Timber
      which would be available right here.
      if they start by chopping down trees.
    So this is all ok for the time being. In the last case you can see that he wants to build a shack which starts by chopping down trees and misses some stages like planing the wood into planks. So its doing a search through the possible transactions forming possible paths through it. So whilst he cant build the shack in one go he knows thats what he wants to do and how to start doing it. Its like this that the language should really be declarative like GnuMake or prolog. All through the paths its tracking the costs involved at each stage and trying to work out the best course of action based on his needs and desires. So hopefully soon ill have him walking to the water and therefore generating a bit of path.

    As you can see its looking quite likely that as soon as he has taken a drink from the river he will plant crops right on the waters edge. Im not unhappy about that since you usually camp next to a stream and I see no reason why thats not a bad move. Of course he will have a longer trek to the forest if he wants wood but so be it. We will probably find that he builds his hut right next to the wood and ferry between his crops & water and his shack and the wood. Those building closer are probably going to be more productive.
    Last edited by Redrobes; 09-01-2010 at 10:05 AM.

  4. #14
    Community Leader Facebook Connected tilt's Avatar
    Join Date
    May 2010
    Location
    Trelleborg, Sweden
    Posts
    5,784
    Blog Entries
    2

    Default

    so when andy gots his drink and food an shack (not the naughty one) - he just need a table, quill and ink and he can start mapping
    regs tilt
    :: My DnD page Encounter Depot free stuff for your game :: My work page Catapult ::
    :: Finished Maps :: Competion maps - The Island of Dr. Rorshach ::
    :: FREE Tiles - Compasses :: Other Taking a commision - Copyright & Creative Commons ::
    Works under CC licence unless mentioned otherwise

  5. #15
    Guild Adept Alfar's Avatar
    Join Date
    May 2009
    Location
    Denmark
    Posts
    276

    Default

    I've been wanting to do something like this, to the extent of starting making notes on ideas. Nice to see that I'm not the only one, and also that someone is having more progress than me.

    Keep at it, sounds like you've got a good thing going.

  6. #16
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    Thanks Alfar. Its going to be slow progress for a while until the engine is more complete then I will be able to add more interesting stuff and see what happens.

    Quote Originally Posted by tilt View Post
    so when andy gots his drink and food an shack (not the naughty one) - he just need a table, quill and ink and he can start mapping
    Heh yeah that would be good AI wouldn't it. Computer spawns new villager. Computer applies skills to him including level 30 in cartography. Computer makes request of villager what kind of village he wants. Save & Exit !

    On my Dev list I have a few immediate things I need to do. In order:
    1.) Get human to work out best path to stated transaction location.
    2.) Get them walking along path adding to path amounts on the map.
    3.) Making character perform the chosen transaction when at the transaction location.
    4.) I need to group similar items together into collections. This would allow me to set a requirement of more than 1 arm load of planks to make a shack for example.
    5.) I need transactions which don't result in a desire change or an item being produced but are events. One of the events is to modify the quality of an item. I.e. If they are planing wood into planks then the planks should start rough and get better. Or crops get tended to grow faster, or patch up the shack into a better one.

    Dunno when I will be able to do some of this next.

  7. #17
    Guild Novice
    Join Date
    Aug 2010
    Location
    California, US
    Posts
    13

    Default

    One aspect you seem to be preparing for, but not ready to implement, is waste production/disposal and sanitation. If that's the case, great. If you forgot, don't forget he'll need to visit the privy every once in a while.

    Also, you had wanted to avoid barter and try money (without a mint) because of the inequalities of trades in barter. Would it be easy enough for you to use the barter method with a minimal amount of money? If everyone had needs and everyone is trading something they have for something they need and the difference in relative values is made up of money you won't have inflation since the money is just an equalizing value, not an absolute value itself. Of course then the whole rich paying for goods and services thing stops working.

    Alternatively you could have money enter like it would have for most cities, minted off screen and brought in by a merchant who will pay near the going rate for goods (sometimes more, sometimes less). Once people get prosperous enough, they would rather buy the goods off of the traveling merchant than work for them themselves, but local inflation would still happen a bit between merchant visits. If too much cash is flooding the village and there isn't any food, people are less likely to sell their grain at any price.

    I think what makes the most sense, though, is a barter based economy with something (probably grain) required the most and the easiest to produce so that it can also act as the base monitary unit. (i.e. for Andy a log is worth 4 grain, plained wood is worth 7 grain and a full house worth 30 grain.) Since it is consumed regularly, you wouldn't have inflation.

    However you do it, you would also likely want to have a way for the AI to own/control the land and buildings, so that the person who owned the lumber mill could get a cut for it's use, same for the person who owned the field, the flourmill, the distillery, the bakery, blacksmith etc. All of these functions the starting AI could do on their own in their hovel (except produce grain), but the AI skilled at the task could do it for cheeper. Perhaps even include skilled carpenter/builders who are the only one capable of building/repairing special buildings like the mills and blacksimiths, that way your first settler doesn't build a hovel and a blacksmith shop, and a bakery and a... These special buildings could accelerate production times or decrease production costs (or both) over the work from hovel model.

    You've probably considered all/most of the above, and if so then I'm just feeling all excited for you. I hope that if the concept reminders were unneeded, at least that excitement is conveyed.

  8. #18

    Default

    This might be rather obvious and/or you've probably had thoughts on this already but...
    I was thinking about "Andy's" decision about where to build his home. It's a fascinating decision and since it has a large bearing on the "map" concept of the model I thought I'd put in my penniworth on what might affect that decision.

    Since Andy lives alone his thought processes would be "fur trapper" like. Self preservation and self sufficiency would be prevalent - he'd probably have his hut by the water and his crops (to keep animals away) and trek for wood. - he doesn't really need to protect the wood! His needs for wood would be large (capital investment) at the start - to build his home, and then just for fuel and tools etc at need - a "gathering" type exercise rather than a crop?
    However, as part of a community he could specialise, a farmer or a woodsman or fisherman, and trade/barter straight away for his house... His economy becomes more cash "crop" oriented.
    Andy the Fur Trapper would do this sort of thing with the "external" world but the value/profit of his "cash crop" is diminished by distance unless his is the only forest around! Or he has something else equally "unavailable" (fur) and so on.
    Initially, I think I'd approach the model from the fur trapper perspective (as you have I guess), treating subsistence as mandatory and then let him stockpile "profit" in terms of his cash crop. His decision on improving the quality of his cash crops is probably secondary to that? Ultimately, though, he has to make a decision on his "trade", what his main product is, I think. Improving "quality" is a factor dependant on that specialisaton. To make "planks" means diverting time from just hacking down trees. Time that is not (initially) profitable - indeed, to start with he will have to "scrap" his failures (e.g burn the wood, or eat the gritty flour himself!). This in itself is complicated, do you intend to include product longevity? Bread goes off, wood rots etc?
    I'm sure this is all "running" before he walks but I can't help thinking about this project!
    Don't feel deflated if someone else has already done something similar, most things have already been "done", but not always the same and doing it yourself is so much more FUN !! Andy is your own little man working out that he needs to drink and so on!
    Personally, I'd just love to see height fields brought in as soon as possible for the movement decisions, I'd love to see how it creates desire lines! However, don't be lead astray by such importunings!
    --
    "I do not know whether I was then a man dreaming I was a butterfly, or whether I am now a butterfly dreaming I am a man"

    My Finished Stuff
    ............. Some of my 3D Stuff (POVRay)

  9. #19
    Guild Journeyer
    Join Date
    May 2008
    Location
    PEI, Canada
    Posts
    213

    Default

    When I was talking about Dwarf Fortress, I was merely talking about how poorly it preforms as more and more actors are added into it. From what I've seen of how it preforms I would bet it stems from poor memory usage as things expand in 3D arrays. Actors need to be strictly limited to how far around the world they can look, and you may need to do some work with how information is looked up and shared. (ie, plan to allow main roads with path finding nodes to be put in place. Preprocess commonly used paths through your road network. Consider path finding from both ends of a problem with goals of finding paths to central travel networks. If an actor wants Wood then look at main wood sources and see which is closer to an existing road. Only open up roads to new sources when old ones are beginning to deplete, or if an untapped one becomes far 'closer' to get to. Things can become 'closer' because of congestion on roads, or expanding away from an existing source.)

    By relying on pre-paths, you can greatly reduce the amount of actual processing done.

    Another option is to avoid doing 100% precision simulation, and using a list of action queues. Actor John wants wood, and it is sourced by walking to Road Node A, then to B, C, D. John plans this, stores it in his personal action list. Action Queues can be sorted on the length of time a task will take to complete, and so an Actor will be placed in the Queue that corresponds to how long their next action will take to complete. This way the computer never looks at them again till enough 'ticks' go by for their action to finish.

    In the case of John you can either split it up as an entire trip and action, or at way points. I might be tempted to go with checking at each way point, and then flagging the road he is on to account for traffic evenly, rather than having to calculate out when which part of the road is occupied.

    A "Personal Action Stack" could be something that has a base case like:
    "Calculate Next Action"

    When the system pulls an actor off the current tick's Action Queue and sees the "Calculate Next Action" it can run the full AI on it, figure out what it needs, possibly looking at what it has done lately, and pick an action for it:

    "Gather wood"

    What does he need to do to gather wood? Path to wood source. Then the computer finds a suitable course for him to get to the wood and your "Personal Action Stack" for that actor looks like:
    Walk Node A, Walk Node B, Walk Node C, Walk Node D, Gather Wood, Calculate Next Action.

    Walk to node A would take 5 Ticks to do, so he is dropped into the Action Queue for 5 Ticks from now. 5 Ticks later it gets back to him, pops "Walk Node A" off his stack, updates his actual position, calculates how long to Walk Node B, and places him in whatever Action Queue for how long it takes.

  10. #20
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    If I describe what I am doing in a little bit more detail then I think it will answer some of these questions.

    I have a creature list with one item on it called Andy. All creatures have stats but I am not getting too bothered about them at mo. They also have skills which allow them to do certain things. They also have an item list of things they own on them personally.

    There is a map where each square has an item list which could be blank or might have say a tree on it as an item and it has an owner which starts with nobody. The square also says what basic kind of terrain it is. Land, water, sea etc.

    All items have an ownership one of which is the 'nobody' case which trees start out with. Each item has a quality percentage factor and a quantity. There is also an items stats list with an entry for each type of item. So you would have one for trees, one for logs, one for bread etc. Each stat contains the base price of the item and the prevailing current market price for it.

    Finally and crucially there is a transaction list. Each transaction has a required type of ground param, a required skill list, a required items list. It also has a list of consumed items and a list of produced items and it can be set so that it produces a satisfaction of desire amount instead. I have discovered that I need an even production as well but lets ignore this for a while.

    To start with it loops over all squares in the map and modifies some of the params of it. All items for each square are checked and if it finds some special cases it does some things. If it sees crops then it increases the quality of them. If it gets to 100% then it replaces the crops with harvest. Harvest does indeed start dropping in quality by a bit cos it does rot. If that reaches 0 then it removes the item off of the map and marks the square as not owned. It also marks down the path factor for it by a little bit.

    It then loops of creatures and looks at their item list and also rots harvest and bread. It marks him as a little bit more thirsty and hungry and should up his health by a little bit too. Then for this character it works out which items he can get availability on. These are items he can gather (or buy if he had any money) if he goes to a place and just takes or trades it right there. After that it runs thorugh the transaction list and looks at them all ignoring any transaction he cannot possibly perform because he lacks a static requirement like a skill or there is no place on the map it could be performed. It also temporarily ignores the transaction if he hasn't got the required items for it. Some of them will be satisfied (like planting seed) so that he can potentially obtain crops. Then it repeats the search for all the ones he lacked only items for and checks them again. Now it sees that because he can potentially obtain crops it says you can get harvest. So now he can potentially get crops or harvest. Once this has completed he has a list of items he has, he can get or can get if he makes a few transactions. All of the costs involved are managed so that by the end he knows how much consumed items and how far he has to go to make a shack by planing wood by chopping trees by moving to the wood. If the guy is making a lot of money generally then he has high personal turnover so each round spent doing something is costing a lot. For a subsistence peasant its not costing him much at all. So the value of a shack divided by the cost to make the shack depends on a) the prevailing value of shacks, b) how much this guy needs a shack and c) how long it takes him to make a shack. It does that kind of calculation over all the items and stages to work out which one gives the best return on time effort (where time is money anyway) or investment.

    Now when I was coding it I got to the point of the valuations and I did indeed think ok so what happens if this guy has something which is costing him more than its giving back in return. I though of a house which needed upkeep but was not generating good rent cos maybe there's too many empty houses in the village. He would not value it highly but what if it was actually a negative value. So I can see where taking a dump leaves you with an item which needs to be disposed of ! That sounds purile but it was the number 1 reason why cities maxed out in size in the middle ages so I think it has to be considered !

    Ok so onto specific questions...
    Sparticus:
    I would intend skill to be used in one of two ways. Either a) when you create an item via a transaction it generates it with a quality based on the skill of the person doing the transaction and b) id like to do a transaction where you can improve the quality of an item by a specific amount in one turn based on the skill level. Therefore, when a skilled carpenter makes planks he could make them in 3 turns but a noob makes them in 10 so planks to a carpenter are worth less than a noob so that would imply the noob might trade with the carpenter since there is a mismatch in the valuation of the goods.

    For bartering, the coding is easy as its just a substitution of items and ownership. The difficulty is in the decision process to do it. I think that if two people value items differently then its easy as Andy goes up to Bob and says I want your planks for 20gps and just does it. With bartering we have to find two items, one on each side where the Andy's valuation of one of his items is worth less to him than one of Bob items but at the same time Bob has to think his item is worth less than Andy's item. In which case they swap both thinking they got a good deal. Which, if Andy is a carpenter with planks and Bob owns lots of chickens with more eggs than he knows what do with them then a trade like that is perfectly reasonable. So I think its doable but I just gotta grind out the item comparison for every creature in play. If we add a merchant into the mix with a cart load of stuff not obtainable in the game up to that point then I am sure he will make some trades with the initial price being daylight robbery.

    A real issue looming on the horizon tho is what if Andy is not a carpenter but has loads of planks and is trying to build a house. Say Bob is a potter and can make tiles. Does Andy value the planks low cos he has a lot of them ? Is he going to trade planks for tiles only to find himself short of planks now to build his house. Future speculation is the challenge.

    Crayons:
    The future speculation thing is at work here too. Currently, and I have no idea how to move beyond this bit, every creature makes the move or transaction that boosts his standing at the time of calculation and based on what is available at that moment. If someone is in the process of building a smithy then a canny businessman might gather resources for items which the smithy is key to making such that he is the most ready, first to market and thus doing the daylight robbery. Putting that level of AI into the system is something I think ill wait for a long time. In that same sense he would likely build that hut or shack at the place where he is first in most need of it. I.e. if he is tired he may go on sleeping rough and getting by just enough to chop trees and plane wood. The moment he can build the shack then he does so and sleeps in it. I dont think he will consider the future costs involved in tracking to and fro the shack cos its in a duff position. The idea is that some people have made better decisions than others and will progress faster. Sort of like genetic algorithms and the Darwin's theory of selection at work.

    I havent added fur trapping or hunting in the forest for food but these could be added. A probability of getting some food per turn spent in a wood area. Same goes for fishing too. Also to be afraid of the forest I would need to put in a -ve adjustment for being close to it. I could also spawn nasty creatures like gobbos from the forest regions which might hamper those who live close and thus the Darwin selection would favor those further away. Or it might make those near the forest good at battle and become soldiers. I don't know. Id prefer to run with the latter idea as its more generic to the engine and does not introduce another special parameter.

    Certainly distance to forest and all items is a factor in valuation so long as the character has a good personal value turnover and thats easy to keep track of as a rolling average.

    Talroth:
    I haven't tried Dwarf Fortress but it says it runs on some ludicrous sized game grid. My intentions are that this should be run on about 500x500 so the map scanning should not be too severe. Its a localized not world sized thing. I would rather have more resolution than more physical distances. Ideally id like a mile or two of area and I thought that a square should be 5ft or perhaps 10ft which does make for 1-2 K square of size. Beyond that I think people would adventure, travel and so on not so much build their village, town or city.

    In terms of path traversal I would not have a distinct network as such but rely on the path parameter of the map and ensure that the character must walk each square looking for the best next square. Maybe that would not be good enough and he could get stuck but I need something where each square on the map is considered for it value. All roads decay back into dirt if left alone and get more path like if walked over.

    Your ideas about grouping actions and waiting the full duration with no processing is a good idea but the characters can change their minds about what they want to do depending on market changes. I'll bear it in mind. Obviously we need to see how fast it goes first after a little straight up optimization before I worry about this sort of thing. If I have to tho, this is a good plan.

Page 2 of 7 FirstFirst 123456 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •