### Computation

In addition to the set of simple utility programs, we also need more complex programs for determining the actual level of production achieved by farmers in light of trampling activities by surrounding cows, a program that determines the equilibrium set of prices in the economy, and, finally, a complex program for determining the profitability of each site in light of its intended production (pretrampling), its actual production, liability for damages, compensation for damages, and the computational cost of determining how to behave.

To compute actual intensities, we take a ring of behaviors and partition it into groups of three, each offset by one site. Each site thus lies at the center of a three-length neighborhood of sites. For each three-length neighborhood of sites thus created, we examine the pattern of interference. For example, if the site in the center of one of these neighborhoods has produced ranching behavior, we know that the site's actual production of cows is the same as its intended production; vegetables do not trample cows. On the other hand, if the site in the center of one of the neighborhoods has produced farming behavior and the site on the left produces ranching behavior, we know there is a chance that the farm's level of production will be reduced according to the destructive capabilities of the neighboring cows. The code for accomplishing this procedure is shown in Code Fragment 14.

Prices:

To compute prices, we use Mathematica's `FindRoot` command to determine numerically for each commodity the price that equates demand with the total actual amount of each good produced.

Profits:

A computation of profits at each site requires a determination of several values.

• Computation Costs: The act of computation is not necessarily free in this model. It is expensive to figure out, for example, how neighbors are behaving or are figuring out how to evolve themselves. In this model, the computation cost for each site is a user-specified function of the programs employed at each site. An example might be some scaling factor multiplied by the dot product of the `ByteCount` and `LeafCount` of all the programs. Both `ByteCount` and `LeafCount` are vehicles in Mathematica for assessing the complexity of an expression. Another example might be some scaling factor multiplied by the number of times the expression `direction[mostprofitable]` appears in the program. [Note10]
• Production Costs: It costs money to produce vegetables or cows. The user is permitted to specify an arbitrary function to apply to each site's level of intended production.
• Revenues: The site each revenue receives is equal to its actual production (after trampling damage is taken into account) multiplied by the price of the commodity produced.
• Revenue Loss: Sites whose actual production is less than the intended production suffer a loss equal to the price of the commodity produced multiplied by the difference between intended and actual production.
• Compensation Received: The user may specify a function (such as the `Identity` function) that maps revenue loss to actual compensation received by each site.
• Damages Paid: The user supplies a legal rule regarding how damages are to be computed, which may involve apportionment of damages suffered when cows from two surrounding neighbors damage an interior site's vegetables. A rule of proportional damages frequently used in this article holds that in such situations the ranchers pay the farmer in proportion to the number of cows they actually own. A rule of "no damages", also used in this article, holds that in such situations the ranchers pay nothing.

The profit of a site ends up being the revenues plus the compensation received, less cost of production, less cost of computation, less damages paid.