[Refactioring] Recipes

Simply idea: put item tags in component instead items_ids or with it. Add possibility to write weight of component instead count. After this list of components for kompot be looks like “components: [“sweet veggy” : “1000g”, “water” : 1, “sugar”: 1]” instead huge list of all fruits and berries in game.

Weight wouldn’t work properly.
In case of fruits, the problem is that we usually try to balance them by nutrition instead.
In case of materials, the weight isn’t always properly balanced and it could result in using too much or too little of a given material.

If we want component groups, it would be better to manually define them like:
“unit_of_fruit” : [“blackberry” : 4, “banana”: 1, “strawberry” : 2…
And then used as
"components" : [“unit_of_fruit” : 2, “water” : 1, “sugar” : 1]

[quote=“Coolthulhu, post:2, topic:11293”]If we want component groups, it would be better to manually define them like:
“unit_of_fruit” : [“blackberry” : 4, “banana”: 1, “strawberry” : 2…
And then used as
"components" : [“unit_of_fruit” : 2, “water” : 1, “sugar” : 1][/quote]
What point of this solution? Just move huge lists to other place? Main idea - escape from lists. If someone add new item(in mod, for example), he just write tags, instead rewriting lists.
Best way - make weight and nutrition calculation for product durin crafting. Also it solution help avoid problems with nutrition and weight balance of recipes without editing jsons.

Lists will always be there. A new item has to be added to item_groups just to spawn.
Adding a new item to a list isn’t much work.

Having just a tag would prevent micromanagement of components.
Say, you have a tag SWEET_VEGGY for anything sweet made of plant matter. But apples are less sweet than grapes per unit of mass, watermelon contains a lot of water and not much solid mass, dried fruit contain a lot of nutrients compared to their mass etc.
To fix that, the tags would have to become properties instead.

Also, tags would be less readable and harder to update than single, globalized list per “tag”.
This could result in old items not getting updates with new recipes.
The only good way to find all items with a given tag would be to parse all items and find those with the tag.

Best way - make weight and nutrition calculation for product durin crafting.

It was proposed a few times.
It sounds like the best solution on the paper, but it requires so much work that it most likely won’t happen anytime soon.
Things like:

[ul][li]UI problems - how to name new items? How to stack them (if at all)?[/li]
[li]Modifiers on crafted items - what do we add, what is replaced, what is dropped. For example, sugar crafted from dried fruit shouldn’t keep their nutrition[/li]
[li]Crafting from crafted items - generating crafting lists not always possible (due to items having varying stats putting it in different category), presenting choices to player[/li][/ul]

Coolthulu pretty much covered it, contributors need to be able to read the recipes in json in order to understand them and make their own recipes, tagging adds yet another layer of abstraction to the process, making it harder to understand and keep consistent.

Lists will always be there. A new item has to be added to item_groups just to spawn. Adding a new item to a list isn't much work.
For mod joining few lists harder that just overwriting tags. For few items - profit.
Say, you have a tag SWEET_VEGGY for anything sweet made of plant matter. But apples are less sweet than grapes per unit of mass, watermelon contains a lot of water and not much solid mass, dried fruit contain a lot of nutrients compared to their mass etc.
SWEET_VEGGY - tag for "kompot" recipe. We have no deal about amount of natural sugar, water or nutrition.
Also, tags would be less readable and harder to update than single, globalized list per "tag".
Generally we don't need this. SWEET_VEGGY always be SWEET_VEGGY. In other case JS save us.
This could result in old items not getting updates with new recipes.
??? You have lots of SWEE_VEGGY and "kompot" recipe. Add new recipe "jem" with SWEET_VEGGY. Where is problem?
UI problems - how to name new items?
By template like %s jam/ kompot from %s
How to stack them (if at all)?
By "stack" parameter from recipe. If not full stack - stack from recipe/weight from recipe * weight after craft.
Modifiers on crafted items - what do we add, what is replaced, what is dropped. For example, sugar crafted from dried fruit shouldn't keep their nutrition
Flags for reaction dependence: reagent weight/nutrition/quench etc. Dependence amount of out product from skill - it would be nice.
Crafting from crafted items - generating crafting lists not always possible (due to items having varying stats putting it in different category), presenting choices to player
Crafted items = items in list, but with moded some stats. Better way it that? Take editor and search everytime where 2 eggs and water with 8 nutrition give soup with 120 nutrition?

Any example for tags maintenance? Build list {tag: [items]} - few lines JS code. New recipe? See tags and do it. No problem with out nutrition/quench/weight balance, no problem with search all appropriate items. Add tag to all need items it too not big problem. But current model has big problems with balance and maintenance it. Add new fruit? Write it to all recipes (also find this recipes), add to all spawngroup (and find them), check balance… it is not lots of work?
I don’t image any example for tags maintenance. Anyway edit one tag easier that lots of ids.

SWEET_VEGGY - tag for "kompot" recipe. We have no deal about amount of natural sugar, water or nutrition.

But then the whole deal about removing lists no longer works: if SWEET_VEGGY can’t be used for sugar because it doesn’t carry the proper values, then we still need a list for sugar crafting.

We’d also have to specify what do we want from the SWEET_VEGGY.
For example, when crafting sugar, we don’t care about water content, but care about sugar content. We can’t use volume, weight or nutrition here.

Later we’d run into tag name conflict: if we want only the very sweet veggies, we’d need another tag for it.

By template like %s jam/ kompot from %s

It works for single components.

But consider woods soup made of 2 components, each of which can be made from other components.
For example, woods soup made from meat jerky with seasoned salt, dried cabbage and pine tea.
It would have different stats than same woods soup made from dried fish, bone broth and cooked dandelion.

And not-food items made from lots of components, like pneumatic rifle.

By "stack" parameter from recipe. If not full stack - stack from recipe/weight from recipe * weight after craft.

I mean how to add modifiers from craft items.
For example, if you’re crafting woods soup, you’re getting x nutrition from meat item, y nutrition from vegetable item, z nutrition from broth. Then weight from each of those.
Just adding them up may work for nutrition, but not for weight.

Flags for reaction dependence: reagent weight/nutrition/quench etc.

This one sounds like a ton of work. Could work, but it would require tagging a lot of recipes.

Crafted items = items in list, but with moded some stats.

That’s the deal: how would you present those lists?
Player crafts 2 soups with 119 nutrition. The recipe that uses 120 nutrition soup will now consume both those soups and probably create a super-nutritious result.

But current model has big problems with balance and maintenance it. Add new fruit? Write it to all recipes (also find this recipes), add to all spawngroup (and find them), check balance... it is not lots of work?

You won’t get rid of spawngroups with tags - you’d run into too many tags per item. Each item would need a giant list of tags like:
[ “SWEET_VEGGY”, “IRRADIATED_VEGGY”, “FRIDGE_FOOD”, “DESSERT”, “MANSION_FRIDGE” …
And when someone adds a new tag, they either have to go through ALL of those items and change multiple files or leave it without a proper tag.
With lists, we’d just change a single file to include the new item in few lists or add a new lists with few items - localized, small change.

You’re proposing a change in paradigm and that’s a major thing. Even if your idea was better than mine, it would require a lot of work to invert all those lists.
Globalized lists are safer and faster to implement and don’t require a new system to rebalance everything.

Dependence on components for stats is a huge thing, bigger than the whole deal with lists and tags.

Hmmm. Ok, i agree it. Both models needed.

For example, when crafting sugar, we don't care about water content, but care about sugar content. We can't use volume, weight or nutrition here.
Some recipes just may not use tags.
It works for single components. But consider woods soup made of 2 components, each of which can be made from other components. For example, woods soup made from meat jerky with seasoned salt, dried cabbage and pine tea.
Woods soup from and -> Woods soup from meat and veggy. Or just "woods soup" and list "made from" lower.
And not-food items made from lots of components, like pneumatic rifle.
You may not do autoname for ALL recipes.
I mean how to add modifiers from craft items. For example, if you're crafting woods soup, you're getting x nutrition from meat item, y nutrition from vegetable item, z nutrition from broth. Then weight from each of those. Just adding them up may work for nutrition, but not for weight.
Why not for weight?
This one sounds like a ton of work. Could work, but it would require tagging a lot of recipes.
Yes, it is ton of work to rewriting 200k of copypaste with food recipes, but it much better, that do few more.
Player crafts 2 soups with 119 nutrition. The recipe that uses 120 nutrition soup will now consume both those soups and probably create a super-nutritious result.
2 soups (4 liters volume, for example) after crafting become 1 new soups (4 liters volume, 8 charges) with 240 nutrition and +5 morale. What is problem?
You won't get rid of spawngroups with tags - you'd run into too many tags per item. Each item would need a giant list of tags like: [ "SWEET_VEGGY", "IRRADIATED_VEGGY", "FRIDGE_FOOD", "DESSERT", "MANSION_FRIDGE" ...
tags : [...], craft_tags: [ "SWEET_VEGGY", "IRRADIATED_VEGGY", "DESSERT"], groups: [""FRIDGE_FOOD", "MANSION_FRIDGE"]
And when someone adds a new tag, they either have to go through ALL of those items and change multiple files or leave it without a proper tag.
Few lines JS code.
With lists, we'd just change a single file to include the new item in few lists or add a new lists with few items - localized, small change.
As i say both methods has good and bad sizes.
You're proposing a change in paradigm and that's a major thing. Even if your idea was better than mine, it would require a lot of work to invert all those lists.
Are you real coder? Covers arrays from item_groups to array for each item or back - half hour of coding time with JS/Perl. Or you think do this with text editor?
Globalized lists are safer and faster to implement
Array for each item or array of items - absolutely no difference for stability or implement. If first case group list fills with items list, in second - after.
new system to rebalance everything.
You have no any system for balance something, except text editor.
Hmmm. Ok, i agree it. Both models needed.

Tag system is not needed, unlike list system. It could help and be useful, but it’s not necessary.

Woods soup from and -> Woods soup from meat and veggy. Or just "woods soup" and list "made from" lower.

But there are many examples where we want those materials visible, mostly for allergies and later for cannibalism.
And shortening “meat jerky” to just “meat” would require keeping those “short names” somewhere.

So we’d need a list of what can we shorten item names to or generate them from tags somehow.
And in case of tags, we’d need a good way to limit the name, to prevent names like “fish soup from meat, bone, wheat and eggs”.

Why not for weight?

Because water content changes a lot. Dehydrated food loses a lot of weight, but shouldn’t result in lighter soups.
Nutrition should also be retained in case of some foods - soup made from dehydrated meat should have as much nutrition as one from rehydrated meat (dehydrated and then rehydrated back).

Yes, it is ton of work to rewriting 200k of copypaste with food recipes, but it much better, that do few more.

Globalized lists would be less work, though. And they would still solve the repetition.

tags : [...], craft_tags: [ "SWEET_VEGGY", "IRRADIATED_VEGGY", "DESSERT"], groups: [""FRIDGE_FOOD", "MANSION_FRIDGE"]

You’d still have a big block for almost every item. It would make individual files big and “dense” in those tags.

Few lines JS code.

How would you get all the items that you want to add the new tag to?
You’d still have to build a list, just that you’d only use it to add tags to those items and then drop it.

Are you real coder? Covers arrays from item_groups to array for each item or back - half hour of coding time with JS/Perl. Or you think do this with text editor?

It’s not as simple as that.
Consider lists with weights such as item_groups. Those can’t be inverted easily. And we need those weights.

Then there’s the issue of replacing a large part of data in one go - we generally don’t merge changes so huge that they can’t be displayed in github UI, as this means that:

[ul][li]The PR is huge and hard to review[/li]
[li]To review the PR, we need to download it first and use an external diff program[/li]
[li]Testing such a PR may take a lot of time[/li][/ul]

So it would most likely require multiple PRs to convert the data.
Doing it in “one go” rather than breaking it up would require a very good reason to make an exception. I don’t see a good enough reason to do that. And Kevin would probably be stricter than me about a good reason to break our project rules.

You have no any system for balance something, except text editor.

Recipes. Our current recipes are roughly balanced by the fact that we compare inputs and outputs manually.
If we added an automatic system for stats out of components’ stats, we’d have to make sure it gives proper results.
For example, that soup made from dehydrated meat doesn’t lose nutrition compared to same soup made from same meat with water added to rehydrate it.

As i say both methods has good and bad sizes.

Item tags have the advantage that only one file has to be changed per new item/recipe, but they mean that maintenance and listing may require scripts and they don’t allow weights.
Plus, item tags would take much more work.

I see those two cases as roughly comparable. I’d prefer globalized lists, but I’d be fine with tags.
But the amount of work required for item tags would be much greater than one for globalized lists.

Ok. List + scripts for parsing tags to list and back.

Because water content changes a lot. Dehydrated food loses a lot of weight, but shouldn't result in lighter soups.
Add mods for each result stat (if needed) - it is not hard. Dehydrate recipe - 25% from base weight, rehydrate - 400%, etc.
How would you get all the items that you want to add the new tag to?
As well as now i find it in huge files. If i want add new spawn group i must search items in all jsons. But in case of global list I have 2 open files, for local - 1.
You'd still have to build a list, just that you'd only use it to add tags to those items and then drop it.
It is good from one side, but bad from other.
I see those two cases as roughly comparable.
http://pastebin.com/a6BJGkG1 Code: http://pastebin.com/81nYXVwH Do back to list too not so hard.
Add mods for each result stat (if needed) - it is not hard. Dehydrate recipe - 25% from base weight, rehydrate - 400%, etc.

But then you want to craft a soup from dehydrated flesh. And soup can’t have global weight/volume modifiers, but needs them per component type.

Being able to craft items from permafood components (like dehydrated meat and flour) and from fresh food in the same recipe is a pretty big deal.

Where would you store the modifiers? Have each recipe use one of two tags or something like that?

I got to say i actually like better the food recipes the way crutchmaster wants them.
That said, i view the work in converting, balancing, bugfixing and generally working on it until it is better than the current system, to not be worth it. We could do real progress elsewhere with such work. Such as expanding mapgen with the sea, hills and variable biomes as you move continually in one direction (+weather changes), or making z-level buildings frequent, adding flying stuff, etc…

[quote=“Coolthulhu, post:12, topic:11293”]

Add mods for each result stat (if needed) - it is not hard. Dehydrate recipe - 25% from base weight, rehydrate - 400%, etc.

Where would you store the modifiers? Have each recipe use one of two tags or something like that?[/quote]
In recipes, i think.