Weeding, Plowing, Tilling, and Burning:
Before crops are planted, the field needs to be cleared of any existing plants. This means choosing one of weeding away specific plants by hand, plowing or tilling the whole field, and possibly burning the plants in the field before tilling the soil in order to kill all the unwanted plants in the future farm plot.
Plowing or tilling the soil has the advantage of killing almost any plant already in the soil and killing most of the seeds that would allow more weeds to grow back in that soil. This helps insure that the crops you want grown have no competition from weeds that can crowd them out. Tilling of the soil can occur by hand (by using sticks), by using a metal tool like a hoe or mattock (a pick will do if you don't want extra tools being created for specialized tasks), or by using a wooden or steel plow (nothing less than steel is really strong enough to work well, although blue metal can certainly work) in conjunction with a draft animal like a horse or ox. (Anything that carries wagons in trade works.) The amount of time plowing takes should go from intolerably slow on the end of tilling soil by hand to reasonably fast if using a steel plow hauled by draft animal.
Tilling the soil has several effects besides killing plants already on the tiles and killing seeds - it can aerate the soil (reduce CEC-D), and benefit some soil bacteria that help in decomposing biomass, but can also dry the soil out, make the soil lose some of its stored nitrogen, and reduce the ability to store water and certain nutrients (also represented by reducing CEC-D), makes soil more vulnerable to soil erosion (if water is run over the soil, there is no root structure to prevent soil from eroding), and can make the soil more attractive to certain forms of insects or pests to move in.
A
zero tillage system is one where you avoid plowing or tilling the soil. In modern times, zero tillage is rising in popularity for soil conservation reasons, but it also requires advanced farming machinery and access to pesticides, so it may be simply beyond dwarves to practice full zero-tillage policies, although they might have ways to reduce the amount of tilling they need to do. Most notably, use of specific cover crops and polycultures in general can allow dwarves to go several seasons without having to till the soil, which could potentially knock down labor needs.
Because messing with CEC-D is so difficult, however, it may be advisable to simply make tillage hurt humus, instead, which is something that players can rebuild more readily than CEC-D. CEC-D is something that, realisitically speaking, you're stuck with. You can maybe create artificial flowerbeds for small numbers of crops, but you can't do that for a whole field.
Burning the fields or slash and burning away trees is also an option to add nutrients back to the soil in a hurry, and would definitely kill off all the weeds. Burning clover fields used as cover crops before tilling the ashes into the soil is also a way to maximize the nitrogen fixation potential of clover fields. It also kills pretty much everything in the soil, good and bad insects alike. This can lead to vulnerabilities to certain pests if you kill off all their natural predators.
Most fertilizers are added during the clearing/tilling period, as well, although water and possibly nitrogen through "manure tea" can be added during growth.
Competition for space:
When a field spot is empty, dwarves can try planting seeds there. (The actual planting process should be very fast, and it may be appropriate to have dwarves carry a whole stack of seeds that they just toss into several tiles all at once.) This adds the seeds that your dwarves are trying to grow to the list of seeds in the soil at that time that are competing to grow in that space.
In the game right now, with the multiple grass types, every form of grass competes to become the longest grass. This code can be reused for all the growable plants in the game, by making tiles initially unclaimed by seeds, and letting them compete to grow up to a certain threshold value before they can manage to edge out their competition, and start starving rival plants of their sunlight.
This is how weeds can be portrayed in the game - if a seed or an already-growing plant is in the same tile as a crop you are trying to grow, the weed can try growing in the same tile. This weed will compete with the crop, and unless the crop is hardy enough to prevail on its own, some pest will target and eat the weed, or a farmer pulls out the weed, then the weed can crowd out a crop before it has a chance to dominate its tile and prevent weeds from growing.
Once a weed has some dominance on the field, it may be worth leaving the crop still in the field, but with declining growth values so that a dwarf farmer can kill the weed and give the crop a chance to grow again.
"Dominance" may actually mean different things, depending on how Toady wants to go with the game's tracking of plants in soil, as well. Polycultures where plants are literally placed on top of or directly next to one another may be possible, so that some plants may actually grow sharing the same tile, making companion planting a much more interesting feature. Since ancient times, rice farmers have planted
azolla with rice as they flooded the rice paddies once the rice stalks had grown long enough that they cleared the water line, since the azolla would cover the water's surface, preventing any sunlight from reaching any weed that would try to grow and compete with the rice, while the rice had already grown tall enough that the azolla was no longer a threat to the rice itself.
If we do not have something quite so complex as having multiple plants growing in the same tile, there would still need to be a sort of mechanic that allows plants in one tile to have an impact on the tiles around it. Tall trees, for example, may shade out nearby plants, causing plants in adjacent areas to have less access to sunlight, and making trees actually compete with one another. Certain plants actually enjoy the shade, and grow better right next to tall trees, while other plants cannot stand having anything but direct sunlight.
This can require a new variable to adequately represent how much different plants compete for space. Taller trees, for example, may actually only take up one tile, but still "crowd" plants that are nearby, preventing other tall trees from growing near them. This could be expressed by having crowding plants become unable to grow near other crowding plants, forcing plants to be grown in a checker pattern, or by skipping rows, or even having no plants touch at all, being planted only every other row and every other column, so that only one space in four actually has a plant in it. (This being most likely for orchards with many trees crowding one another.)
Smaller plants or weeds whose crowding variable makes it "smaller than its tile" would be able to grow near the crowding plants. In the real world, some plants prefer growing in the shade of other plants to growing alone, and so, some flowers, crops, or weeds may actually be well-suited to growing alongside orchard trees or other very crowding plants that would not compete as well without those crowding plants pushing out their competition. Tall trees may also sometimes be grown with shorter trees that do not crowd as much, with the space between these taken up by small underbrush or grass plants that can work with the trees that would generally crowd out most other plants.
Basically, the idea is that you have a set number of sizes for plants - let's say 7 just because, although this has nothing to do with the 7/7 fluids thing. So, if a plant has 4 crowding, it occupies its entire tile. If the plant is a tree or something, it might have a 5, 6, or 7. If it's a 5, it blocks off anything but a 3 or less in the tile next to it, although diagonals might have up to a 5, as well. Hence, a 5-crowding tree could be planted as a checkerboard of trees with smaller 3-crowding plants. Then, a 6-crowder could have a 2-crowding plant nearby (which would be something fairly small that likes the shade, like a flower or vine) and a 3-crowder in the diagonals. A 7-crowder would force nothing more than a 1-crowder adjacent, and 2-crowder in the diagonals.
Growth Value:
So far, I have been discussing a handful of variables that are relevant to the growth of a crop. Each of these factors needs to apply each "growdur" tick. A growdur is 100 time units (1 second in playtime at 100 FPS), so everything plants do is at a scale of about 1/10th that of most creatures. This helps reduce the CPU processing time taken up by plants, which are fairly inert most of the time, after all.
At the growdur tick, rather than simply iterating a growth point towards a crop being harvestable (as is the case now), the plant will make a calculation to see how well it can grow in general.
Every soil variable for the plant needs to have an "ideal" range, where the plant will grow at its maximum speed. Outside this ideal range, there should be a declining rate of growth, down to a range where one factor of the soil is so bad that it kills all growth of the plant entirely. This is probably best achieved by having a maximum growth rate, which is multiplied by a variable between 1.0 (if the variable is in the ideal range) gradiating down to 0.5 (if the variable is at the marginal range) to 0 (if conditions are intolerable to the plant). This means that any one variable, if intolerable, will completely kill plant growth until that variable is changed. During this time, the farmer skill multiplier is also multiplied in, and pests have a chance to eat some of the crop, reducing its total growth values, as well.
This means that plants should generally have a wider range of tolerance for certain variables than others - some crops will need plenty of water, and others are more drought resistant. They both want a fairly high water value (but not overwhelming), but suffer less for being in dryer soil.
Farmer Activities:
Farmers should generally have a lot more to do in this system than in previous ones. Dwarfish farmers now must till the soil or perform other more labor-intensive soil preparation activities, apply fertilizers, plant seeds, weed the soil if their crops are threatened by weeds, irrigate the soil (by bucket if necessary), harvest crops, and perform some other tasks like restructuring soil beds if necessary. This should probably be more than enough tasks to keep plenty of farmers busy even if each individual task is fairly short.
This brings up the question of what role, exactly, farmer skill should have in the growing of crops so that a legendary farmer is distinguishable from a dabbling one. Legendary farmers might be able to perform certain tasks instantly, while dabbling farmers are slower, but this would make a dabbling farmer incapable of running a farm at all if it takes them too long to perform basic tasks like tilling the soil.
As a sort of compromise in how much impact a farmer's skill can have on the growth of a crop, then there can be a variable for the farmer's skill in setting up the field in the first place. A multiplier that is applied to the growth value at every, or at least certain, portions of the plant's growth, so that a dabbling farmer will have a 1.0 multiplier to growth speed, while legendary farmers would be gaining 1.5 or 1.6 plant growth speed, for a +60% total potential crop yield. Not the same as the difference between having no food units and having 5 food units that we have now, but that sort of massive difference maybe shouldn't be so heavily represented. The scale can be made different, of course, with plant growth being multiplied by a factor of .5 to 1.1 or 1.0 to 2.2 or some similar multiplier. The farmer's skill check for the field can still be applied at the planting of the seeds, which would presumably indicate an ability to prepare the soil and plant seeds in a way that gives those plants the greatest possible advantage in growing compared to their weed rivals, and to have the best chance to grow larger fruits. (If this growth multiplier applies at the weed crowding phase before a plant can dominate the tile, then it gives a major advantage to weeds to have a less than 1.0 growth multiplier, and a major advantage to the desired crops to have a more than 1.0 growth multiplier when competing for space.)
Farmers are also called into play to apply fertilizers and water. Legendary farmers may be more exact in the amount of fertilizers and irrigation that they allow onto their land, while dabbling farmers may be more sloppy, overzealously fertilizing or watering their plants, or underestimating the amount they need.
Another task farmers may need to perform are soil bed alterations. This means doing something like applying gravel or sacks of dirt to an otherwise fairly barren cavern floor to start the process of farming by breaking down the gravel or soil and building up the humus while expanding your total farmland. It can also mean changing the current soil's consistency by liming the soil to alter soil pH, or building a raised farming bed to alter the soil's CEC-D values. With the exception of adding small amounts of gravel as a nutrient booster, these can be fairly major alterations to the soil that take a significant chunk of time to perform. Altering the soil to have a different CEC-D value is a major undertaking, and could damage many of the soil nutrients and humus depth, requiring building up the soil for a couple years to compensate.
Harvesting:
Each plant will try to hit a blooming (harvest) period at a certain point, which is when it signals it is ready for harvest, regardless of how much growth the plant has actually done. Plants which do not hit a threshold value by that point simply wither and die without having any harvestable crop at all. Plants which get past this threshold value produce one harvestable crop per certain amount of growth beyond the threshold value, both of these values being determined by the crop's raws. This means that certain plants could require very small threshold values, but produce few fruits to harvest, while other crops could have very high threshold values but have a high chance of producing very large stacks of crops if you are capable of passing that threshold value. (For example, one plant might have a minimum threshold of 100 growth and 25 growth to produce every unit of food beyond that, while another plant could have a minimum threshold of 200 growth, but produce a unit of food per 5 growth beyond that. If both plants hit 250 growth, the first one would have 6 units of food, while the second would have 10, but if they only hit 199 growth, the first plant would have 3 units of food, while the second would not produce any food at all.)
All other aspects of harvesting should be as they are currently, generally speaking. Having children help in the harvest is a good thing to keep in (although maybe having nobles refuse to help harvest is a good idea), since they historically did help in such things, as harvesting the crop as quickly as possible was a major concern of farming cultures.
Ratoon Crops and Orchards:
Certain plants are not necessarily killed entirely when they are harvested.
Orchards and trees in general only are removed when chopped down. An orchard tree would need to have a set amount of growth that has to occur before it becomes a "fruitable tree", at which point it becomes a full tree on screen to the player, and a new growth value cycle has to start for creating the actual fruits that are harvestable. Harvesting the fruits of an orchard tree resets this value, but leaves the tree portion, making growth for the successive years easier.
Ratoon crops are crops that you can leave a portion of the stalk and roots intact while harvesting just the fruiting body of the crop. Rice, for example, is a potentially ratoon crop in warm enough climates, and many equatorial Asian cultures can make three or even more harvests of rice in a year because they only cut off the top of the rice plant where the rice itself grows, letting the stalk regrow the grains of rice that are its seeds the way that a lawnmower leaves most of the grass in your lawn intact for the grass to grow again. Such ratoon harvests of rice can keep the same stalk for up to around 10 years of harvests with three harvests per year, should the weather stay warm enough that the stalk never dies, helping give rice its ability to feed massive numbers of people with relatively little land.
Such ratoon harvests are a little more tricky to calculate, but could be performed by cutting the growth value of a harvested plant down to a certain number in a harvest, and then resetting a new ratoon harvest date, and letting the growth value climb back up again, so that there can be another harvest of the same crop without having to have another planting.
Gathering Seeds:
Each type of crop needs to have a way of obtaining seeds for the next planting. Generally, plants can fall into two categories, of either having a seed that is a waste product of using the crop (such as an apple's apple seeds, which are not needed in any processing of the apple itself), or as the actual "fruit" of the crop itself (such as corn kernels, where the seeds are the edible and useful parts, themselves), where farmers would want to hold off a certain number of the crops to use as the seeds for the next harvest. This would require some sort of expansion of the cooking menu that lets you hold aside a certain number of the seeds/crops for planting only (unless a dwarf is so hungry they break orders and eat your next year's seeds).
Some crops, especially alchemical or magical ones, might not produce normal seeds at all, or produce seeds for other, more mundane crops. This might require some alchemical process to turn a mundane seed into these special seeds, and require alchemy every time you want a seed for that plant before growing them. Such plants would be useful in making sure certain alchemical reactions are very rare and time-consuming to perform, so that certain alchemical reactions may be powerful, but suitably challenging enough to acquire the components to perform that they make most players think twice before even attempting them, especially if the crops themselves have very stringent requirements for the sort of soils that they grow in.