Making a man chop down a tree: modeling economic rationality

I’ve recently been getting more heavily into my economy sim, creating the foundations for resource gathering and interactive objects. I then came to the next logical functional step: making a man chop down a tree.

In my current, simple testbed, the only resource is wood, and the only objects trees and branches on the ground. However, in order to get an AI-controlled agent to “want” to cut down one of the trees (which we can all agree is a worthwhile use of his time), short of hard-coding this behavior, I’ll need to model something more fundamental, possibly the most fundamental element of a human economy: rationality, for the agents to employ and apply to the world in which they find themselves (Certain human-like irrationalities will of course be useful additions later, but even they will require this foundation).

A preliminary sketch gave me this framework for the parts necessary for rationality to exist, each of which would need to be implemented before rational behavior begins emerging:

  1. A finite goal for the agent, be it finite through a time limit or a goal threshold
  2. Performable actions, with predictable outcomes
  3. Consideration of sequences of actions, including changes in wealth and availability of actions
  4. Response to changes in environment, prices, and possibly other agents, while executing an action sequence
  5. A search of potential action sequences, for the one which will allow the agent to reach his goal earliest (in the case of a goal threshold) or with the best outcome (if a time limit applies)

So, with a goal of “acquire 35g” a possible action sequence might be:

  1. Walk to tree #2
  2. Cut down tree to obtain 4 wood
  3. Walk to person #35
  4. Sell wood for ~40g (based on the current price at that area)

Agents’ goals (1) will be straightforward to add, though room for flexibility must be made, such that new goals can be added later (like having children, or attaining some specific item, or earning a title).

The actions performable (2) will likely be limited to moving, interacting with objects, buying and selling, and later some form of property maintenance. If this is everything, then these actions can be explicitly addressed in code.

Sequences of actions (3) will be somewhat more challenging. The time to complete each action must be estimated. Additionally, a subset of the world state must be maintained for each sequence, changing with each constituent action. For example, if I cut down tree #2, it will no longer be there, and thus if I need yet more wood I won’t be able to cut it down a second time in the sequence.

Responding to real-time changes in the world (4) is important. If the price of wood in an area suddenly drops to virtually zero, then wood may no longer be the optimal path to prosperity, or at least selling wood there would not be. If somebody else cuts down a tree in my action sequence, I’ll have to adjust accordingly. This will likely come down to checking the active sequence regularly, ensuring that it is still applicable, and recalculating if it is found not to be.

Lastly, a search for the optimal sequence (5) could be done as the sequences are constructed and considered; there is a defined “best”, and so the process comes down to a more detailed version of finding the highest value in a tree. If a tree is used, of course, and the entire state space searched, then infinitely-long sequences won’t work; this may mean time limits will be a necessary part of goals, or perhaps the search will simply end after a certain number or total time of actions.

There are simpler ways to make a man chop down a tree, of course; a job-assignment system like in Stronghold or Pharaoh, specialized, single-job units like in Knights and Merchants, centrally assigning roles like some communist dictator… but I feel that independent, rational actors in a model economy will provide the most interesting possibilities, as well as a (hopefully) simple way to expand the scope of a game without reworking unit AI.

Advertisements

One thought on “Making a man chop down a tree: modeling economic rationality

  1. Pingback: Available actions « Block Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: