Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve crop farming. #24291

Merged
merged 41 commits into from
Aug 27, 2018
Merged

Improve crop farming. #24291

merged 41 commits into from
Aug 27, 2018

Conversation

Vasyan2006
Copy link
Contributor

@Vasyan2006 Vasyan2006 commented Jul 13, 2018

These changes will add depth to the farming and add more open air activities.

Each plant will have stats:
Health - determine number of fruits at harvesting.
Water and fertilizer - how much water and fertilizer is available for this plant. They will be consumed every hour and change plant health.
Weeds - will grow and reduce plants stats.
It is recommended to water plants and remove weeds every week.

Common plants (besides root vegetaibles) will not produce seeds, only fruits. Default fruit yields are specified in json. Plants with best health will yield twice more fruits, near dead plants will yield none.
Amount of harvested fruits will scale with season length, because plants will require more care at longer seasons.

New UI (depends on survival skill):

01
02
05
06

Add new farm mechanics:

  • Plants will grow at full speed if the temperature is above 70F (21C) and will not grow at 32F (0C) and below. Planst have comfortable_temperature json parameter. Air temperature below this point will decrease plants health. Temperature below 23F(-5C) will kill the plant.
    Seeding UIs (depends on survival skill):
  • Plants will consume water. Plants will lose health if dont have enougth water. Watering is available from plant info window and will use water from crafting inventory. Temperature above 80F (26C) will increase water consumption,
  • Fertilizer will be slowly consumed (using it just before harvesting will be pointless) and increase plant health,
  • Weeds will grow on every plant and decrease its stats. Must be manually removed.

Separate plants into groups with different vegetative stages:

  • Annual plants (same as it was before),
  • Root vegetables:
    Potatoes will provide seeds in aditions to tubers. Carrots, sugar beets and onions are biennale plants and planting their seeds will provide root vegetables (first year of growth). Planting root vegetables will provide seeds (second year of growth).
  • Perennial berry bushes:
    All berries will grow into shrubs and provide berries after that. Shrubs will survive winter without damage.
  • Mushrooms:
    Mushrooms will grow mushroom bed and and provide mushrooms after that. Mushroom bed will survive winter without damage. It will be possible to farm mushrooms undeground.

List of all seed parameters modified by json:

  • "plant_name": "sunflower", // The name of the plant that grows from this seed. This is only used as information displayed to the user.
  • "comfortable_temperature": 10, // (optional, default is 0). Minimal comfortable temperature (in degree Celsius). Plant will be damaged in the air temperature is below this point.
  • "fruit": "corn", // The item id of the fruits that this seed will produce.
  • "fruit_count": 10, // (optional, default is 10). Number of fruits per harvest for plants with default health.
  • "seed": "seed_sunflower", // (optional). The item id of the seeds that this plant will produce.
  • "seed_count": 10, // (optional, default is 0). Number of seeds per harvest for plants with default health.
  • "water_requirement": 1.0, // (optional, default is 1.0). Multiplier for plant water requirement.
  • "weed_susceptibility": 1.0, // (optional, default is 1.0). Multiplier for damage to plants health from weeds. If set to 0.0 weeds will still consume plants water and fertilizer, and therefore damage indirectly.
  • "grow_into": "t_shrub_blueberry", // (optional). The furniture id this plant will transform once fully grown. Used for perennial plants.
  • "byproducts": ["withered", "straw_pile"], // A list of further items that should spawn upon harvest.
  • "is_mushroom": true, // (optional, default is false) Is this plant a mushroom.
  • "is_shrub": true, // (optional, default is false) Will this plant grow into a berry shrub.
  • "grow" : 91 // Time it takes for a plant to fully mature. Based around a 91 day season length (roughly a real world season) to give better accuracy for longer season lengths. Note that growing time is later converted based upon the season_length option.
  • "grow_secondary" : 91 // (optional). Time it takes for a perennial plant to grow fruits (based of off a season length of 91 days).

@sfsworms
Copy link

Seems like you're being a bit too generous with the impact of frost:

"Corn is killed when temperatures are near 32 F for a few hours, and when temperatures are near 28 F for a few minutes (Carter and Hesterman, 1990). A damaging frost can occur when temperatures are slightly above 32 F and conditions are optimum for rapid heat loss from the leaves to the atmosphere, i.e. clear skies, low humidity, no wind. At temperatures between 32 to 40 F, damage may be quite variable and strongly influenced by small variations in slope or terrain that affect air drainage and thermal radiation, creating small frost pockets."

Source

@Vasyan2006
Copy link
Contributor Author

It significantly depends on vegetative stages and plant species. Being exposed to cold is deadly for chilli peppers but acceptable for root vegetables. All farming stuff is poorly implemented right now and require complex reworking, this PR is only a part of it.

@Mecares
Copy link
Contributor

Mecares commented Jul 13, 2018

Allowing planting at 0°C will result in certain death for most planted plants in early spring without a clear indicator for the player what he did wrong. this seems quite frustrating.

@Vasyan2006
Copy link
Contributor Author

Any idea how to make this indication?

@mlangsdorf
Copy link
Contributor

Add a separate function, similar to warm_enough_to_plant, that gives the player the option to not plant if the temperature is too cold for safe planting.

Alternately, don't drop the safe temperature all the way to 0C but leave it around 5-7 C so the plants can only be planted at temperatures when they're unlikely to die.

@Vasyan2006
Copy link
Contributor Author

Add a warning to the "select seed" menu if the temperature is below 50F (10C).

src/iexamine.cpp Outdated
@@ -1722,7 +1722,7 @@ void iexamine::dirtmound(player &p, const tripoint &examp)
smenu.return_invalid = true;
std::string planing_text = "Use which seed?";
if( !warm_enough_to_safe_plant() ) {
planing_text = "Use which seed?. Plants can be damaged by cold weather.";
planing_text = "Use which seed?. Plants can be damaged by cold weather.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excessive period after question mark.

@Vasyan2006 Vasyan2006 changed the title Plants grow time will depend on actual temperature. [WIP][CR] Improve crop farming. Jul 15, 2018
@Vasyan2006
Copy link
Contributor Author

Desided to bloat this PR into more complex "Stardew days ahead".

@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Items: Food / Vitamins Comestibles and drinks [C++] Changes (can be) made in C++. Previously named `Code` Map / Mapgen Overmap, Mapgen, Map extras, Map display Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. and removed [JSON] Changes (can be) made in JSON labels Jul 22, 2018
@Maddremor
Copy link
Contributor

How will the water value be affected by rain? One could imagine a crop with low water requirement needing no human watering during some seasons. Is consumption of fertilizer, water, and weed growth to be variable (JSON defined) for different crops?

@Vasyan2006
Copy link
Contributor Author

Rains will provide water, but not enought. Plants must be manually watered to provide best results.
I dont have a datatable with separate water/fertilizer requirements for every ingame plant, so all plants have the same rate. Maybe it will be added later.

@Mecares
Copy link
Contributor

Mecares commented Jul 31, 2018

Maybe this list helps:
http://agropedia.iitk.ac.in/content/water-requirement-different-crops
Missing plants could use a default value or one of a similar crop.

@ZhilkinSerg
Copy link
Contributor

Hmm... I've got crash while gathering harvest, but I cannot reproduce it now when using debugger, so I don't know yet if it is related to your changes.

@Vasyan2006
Copy link
Contributor Author

I've got crash while gathering harvest

I've got this crash too, it was from iexamine::get_harvest_items. But after last changes this crash somehow disappeared. I suppose it was from adding new items with zero count to the std::list item
Have you tested it on a new world or the one from previous commits? Because harvesting from old world produced this crash almost every time. But on the new world I have harvested common plants (carrots), normal mushrooms and srawberry shrubs without any problem. And saveloaded few times to be sure.
Still not sure what was the real reason of this crash.

@ZhilkinSerg
Copy link
Contributor

It was new world. I hope it would be possible to reproduce it eventually.

@Vasyan2006
Copy link
Contributor Author

Vasyan2006 commented Aug 26, 2018

Can reproduce crash by harvesting corns on this save
Nipomo.zip
There is about 10% chance to crash on 3-rd from left plant.
But cannot reproduce after disabling these lines in iexamine.cpp

add( fruit_id, fruit_count );
add( seed_id, seed_count );

And minor bugfix - harvesting will provide fruits and seeds only if the plant supposed to do so.

src/weather.cpp Outdated
@@ -736,7 +908,9 @@ int get_local_windpower(double windpower, const oter_id &omter, bool sheltered)
}

bool warm_enough_to_plant() {
return g->get_temperature( g-> u.pos() ) >= 50; // semi-appropriate temperature for most plants
// It is possible but not recommended to plant at the temperature of the ice melting
return g->get_temperature( g-> u.pos() ) >= 32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is FREEZING_TEMPERATURE constant in game_constants.h.

@ZhilkinSerg ZhilkinSerg removed their assignment Aug 27, 2018
@ZhilkinSerg ZhilkinSerg merged commit 6b3eda6 into CleverRaven:master Aug 27, 2018
// 30% - (Widely) scattered/chance
// 40% or 50% - Scattered/chance
// 60% or 70% - Numerous/likely
// 80%, 90% or 100% - No additional modifiers (i.e. "showers and thunderstorms")
Copy link
Contributor

@Brambor Brambor Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could that be reverse of switching these minuses for different minuses or what?
I mean, there was a recent commit that changed these around, is thi changing them backwards?

@ZhilkinSerg
Copy link
Contributor

Just some github screwup.

} else {
std::list<item> harvest_items = get_harvest_items( seed );
proceed_plant_after_harvest( examp );
for( auto &i : harvest_items ) {
Copy link
Contributor Author

@Vasyan2006 Vasyan2006 Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some debugging I found what the crash can occur at this block, where new items are added to the map. It occurs only if new perishable items are added (cannot reproduce only with withered plants). Not sure if it is related to new changes, because reloading the game and doing literally the same actions will produce the same list of items (even with the same bday time) and it works fine almost every time.

UPD: I mean the code after line 1844, not before it. Generating the list and removing old plants was fine.

@Vasyan2006 Vasyan2006 deleted the grow-time branch August 27, 2018 15:19
@vlad1492
Copy link

Awesome upgrade, love this idea.

Sadly my tiny late-season wheat farm was erased. Along with anything else I had planted.

Oh well, at least now where is hope for my dream of an atomic powered hydroponic underground lair.

@Vasyan2006
Copy link
Contributor Author

my tiny late-season wheat farm was erased

This is one of "works as intended" migration bugs. It does not worth effort as long as we have more important problems. Just roleplay locust swarm or create more wheat via debug.

atomic powered hydroponic underground lair.

Shrooms will grow undeground even without these gismos.

@vlad1492
Copy link

RP works for me, my new follower screwed up the fertilization. What do you mean that barrel was full of acid rain? Who keeps a barrel of acid rain?

And shrooms were the first thing I planted in my basement. But I gotta have my vitamins.

Thanks for the overhaul!

kevingranade added a commit that referenced this pull request Aug 29, 2018
@kevingranade
Copy link
Member

Reverted this and the follow ups.

Incomplete list of problems that need to be fixed to re-merge:
Doesn't follow project coding standards.
UI is insufficient, there's no apparent feedback about the state of growing plants.
Changeset is too big, needs to be split into at least three pieces.
As far as I can tell the micromanagement of visiting fields multiple times a day for optimal growth is intended, that's not ok. If it's not intended, it needs to be fixed.
Needs a test plan outlining how to verify that everything is working as intended.

@Brambor
Copy link
Contributor

Brambor commented Aug 29, 2018

@kevingranade

As far as I can tell the micromanagement of visiting fields multiple times a day for optimal growth is intended, that's not ok. If it's not intended, it needs to be fixed.

This, I believe, will be sorted with automatic zones. If that's enough. It means about one keypress, but presence on the field every day, or lower yields, if I understand correctly.

@Vasyan2006
Copy link
Contributor Author

Ok, I will refactor it in reopen when everything will be ready.

Some comments:

Weeds - Plant grow is recalculated on every examine action in addition to loading plants into the bubble. But due to a bug every recalculation increased plants age by 1 hour (even if the last check was in the last turn). Such fast grow is barely visible for plants, but is very visible for weed. This behaviour was not intended and was rather simple to fix.
Chance of the damage from weeds depends on number of weeds and they will grow to maximum in 7 days (depends on actual season length).

Water - Climate generator is brocken and rains are too often (last time I checked it was 2700 mm of rain water during 91 days of summer instead of 300 mm https://en.wikipedia.org/wiki/Climate_of_New_England ) and rain efficiency was reduced 10 times for farming. Default plant consume 0.2L of water per hour, 33.6L per week, 400L per season. Actual water requirements can be found here http://agropedia.iitk.ac.in/content/water-requirement-different-crops.
Rains produce about 23L per week, and irragation will require 15L of water per week for one plant.

Crop yield - Default crop yield is 10 fruits (can be specified in json for every plant). Most fruits and vegetables weight 0.2 kg, so default harvest (for plant with water and without weeds) is 2 kg. Using fertilizer will increase this yeld to 20 fruits or 4 kg. These numbers are to compare with real world (91 day per season). Lack of water or too much weeds will decrease yield. The result will scale with season length (less for shorter seasons, more for longer).

@John-Candlebury
Copy link
Member

John-Candlebury commented Aug 29, 2018

Water - Climate generator is brocken and rains are too often (last time I checked it was 2700 mm of rain water during 91 days of summer instead of 300 mm https://en.wikipedia.org/wiki/Climate_of_New_England ) and rain efficiency was reduced 10 times for farming. Default plant consume 0.2L of water per hour, 33.6L per week, 400L per season. Actual water requirements can be found here http://agropedia.iitk.ac.in/content/water-requirement-different-crops.
Rains produce about 23L per week, and irragation will require 15L of water per week for one plant.

You completely disregard the influence of underground water and soil humidity in your calculations.

https://nwis.waterdata.usgs.gov/nh/nwis/gwlevels
Here is data claiming that through the Merriwick River Basin the water table is mostly between 4ft and 9 ft from the surface. This is relevant because the region mapgen generates is analogous to this river basin.

It seems to me that on average you would need to be procupied with water drainage and not with irrigation. Certainly you wouldnt need 15 liters of water per plant weekly.

@vlad1492
Copy link

Watering from sources within crafting range please.
I'd be planting rain barrels at convenient places or driving my irrigation tractor along to do this.

Consider underground cultivation of plants - I plant to grow cole crops by atomic light. With adequate heat and light we should be able to grow pretty much anything there.

@cainiaowu
Copy link
Contributor

We need more unit tests and testcases. Let the Bot do the hard work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Items: Food / Vitamins Comestibles and drinks Map / Mapgen Overmap, Mapgen, Map extras, Map display (P2 - High) High priority (for ex. important bugfixes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.