Procedural recepies
Procedural recepies
Hi!
Is it possible to make procedural recepies? Every time you start new game, it makes new recepies with new items with different tiers. By starting you have some easy items, next game needs more and more complicated items.
Is it possible to make procedural recepies? Every time you start new game, it makes new recepies with new items with different tiers. By starting you have some easy items, next game needs more and more complicated items.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Procedural recepies
Procedural basically just means creating content from a formula. In theory, that is quite easy to do.
Making it different every time is also possible with use of random, however, since recipes are created on loading the game itself, then you won't be able to use savegames, because the recipes will be different each time you start the game up, and therefore won't match what is in the save game.
As for the difficulty increasing each time... there's no way to make it remember what it did last time to know how to make it harder.
Short answer: The game isn't designed to be able to do what you're asking.
Making it different every time is also possible with use of random, however, since recipes are created on loading the game itself, then you won't be able to use savegames, because the recipes will be different each time you start the game up, and therefore won't match what is in the save game.
As for the difficulty increasing each time... there's no way to make it remember what it did last time to know how to make it harder.
Short answer: The game isn't designed to be able to do what you're asking.
- Arch666Angel
- Smart Inserter
- Posts: 1636
- Joined: Sun Oct 18, 2015 11:52 am
- Contact:
Re: Procedural recepies
You could predefine recipes and then have them enabled/disabled at the start/load of a game via script because that is possible runtime.
Angels Mods
I. Angel's Mods Subforum
II. Development and Discussion
III. Bugs & FAQ
"should be fixed"
I. Angel's Mods Subforum
II. Development and Discussion
III. Bugs & FAQ
"should be fixed"
Re: Procedural recepies
What about using math.randomseed, and putting the seed in a config file? Seems like something like that should would. As long as the seed stays the same, the "random" formulas should stay the same for every load. If the user wants new random formulas, they would just have to change the seed.bobingabout wrote:
Making it different every time is also possible with use of random, however, since recipes are created on loading the game itself, then you won't be able to use savegames, because the recipes will be different each time you start the game up, and therefore won't match what is in the save game.
Re: Procedural recepies
Yes, that will work. It just means if you have different saves you'll have to manually remember the seed and change it to play themwithers wrote:What about using math.randomseed, and putting the seed in a config file? Seems like something like that should would. As long as the seed stays the same, the "random" formulas should stay the same for every load. If the user wants new random formulas, they would just have to change the seed.bobingabout wrote:
Making it different every time is also possible with use of random, however, since recipes are created on loading the game itself, then you won't be able to use savegames, because the recipes will be different each time you start the game up, and therefore won't match what is in the save game.
- FuzzCat927
- Inserter
- Posts: 23
- Joined: Sat Apr 08, 2017 3:04 pm
- Contact:
Re: Procedural recepies
Don't recipes stay the same per world unless recipes are reloaded?Sirenfal wrote:Yes, that will work. It just means if you have different saves you'll have to manually remember the seed and change it to play themwithers wrote:What about using math.randomseed, and putting the seed in a config file? Seems like something like that should would. As long as the seed stays the same, the "random" formulas should stay the same for every load. If the user wants new random formulas, they would just have to change the seed.bobingabout wrote:
Making it different every time is also possible with use of random, however, since recipes are created on loading the game itself, then you won't be able to use savegames, because the recipes will be different each time you start the game up, and therefore won't match what is in the save game.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Procedural recepies
Yes, but all kinds of things cause recipes to be reloaded these days. Simply changing the settings on options -> mods will likely force a reset_recipes call in the latest version of the game.FuzzCat927 wrote:Don't recipes stay the same per world unless recipes are reloaded?
Re: Procedural recepies
This has certainly caught my interest.
I think the cleanest solution to seeding the procedure would be to reuse the map generation seed, which is available from the modding API. I'd probably go with using just part of the seed. That way, if you find a recipe combo you like but aren't happy with the map, you could generate a fresh map while keeping the same procedural recipes by preserving the appropriate part of the seed.
I suggest that it would be best to use 0.15 recipe settings for difficulty. I like the idea of automatically increasing difficulty, but the 0.15 settings give players more control. I think the mod's "default" difficulty level should be slightly higher than vanilla default recipes, given that 0.15 difficulty already offers a smooth learning curve. The mod is likely to be of more interest to players who have already completed the vanilla game and are looking for a fresh challenge. The mod's version of expensive recipes should be "fiendish"
I have a few ideas on how the recipes could be procedural but biased towards rewarding game play. I'll get started right away
I think the cleanest solution to seeding the procedure would be to reuse the map generation seed, which is available from the modding API. I'd probably go with using just part of the seed. That way, if you find a recipe combo you like but aren't happy with the map, you could generate a fresh map while keeping the same procedural recipes by preserving the appropriate part of the seed.
I suggest that it would be best to use 0.15 recipe settings for difficulty. I like the idea of automatically increasing difficulty, but the 0.15 settings give players more control. I think the mod's "default" difficulty level should be slightly higher than vanilla default recipes, given that 0.15 difficulty already offers a smooth learning curve. The mod is likely to be of more interest to players who have already completed the vanilla game and are looking for a fresh challenge. The mod's version of expensive recipes should be "fiendish"
I have a few ideas on how the recipes could be procedural but biased towards rewarding game play. I'll get started right away
Shameless mod plugging: Ribbon Maze
- Ranakastrasz
- Smart Inserter
- Posts: 2171
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Procedural recepies
You can't use the map seed. Recipes are generated on game load, you can't change them on map-load. You have to use a seed that is set in a config.H8UL wrote:This has certainly caught my interest.
I think the cleanest solution to seeding the procedure would be to reuse the map generation seed, which is available from the modding API. I'd probably go with using just part of the seed. That way, if you find a recipe combo you like but aren't happy with the map, you could generate a fresh map while keeping the same procedural recipes by preserving the appropriate part of the seed.
I suggest that it would be best to use 0.15 recipe settings for difficulty. I like the idea of automatically increasing difficulty, but the 0.15 settings give players more control. I think the mod's "default" difficulty level should be slightly higher than vanilla default recipes, given that 0.15 difficulty already offers a smooth learning curve. The mod is likely to be of more interest to players who have already completed the vanilla game and are looking for a fresh challenge. The mod's version of expensive recipes should be "fiendish"
I have a few ideas on how the recipes could be procedural but biased towards rewarding game play. I'll get started right away
Also, here's a mod that does this.
https://mods.factorio.com/mods/Kenira/z ... domRecipes
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Procedural recepies
Right, so I've studied the code for this mod. The scope is different, effectively randomizing ratios (timings, quantities) as well as many other things; but not meeting the OP's requirement to "makes new recepies [sic] with new items with different tiers".Ranakastrasz wrote: Also, here's a mod that does this.
https://mods.factorio.com/mods/Kenira/z ... domRecipes
Procedural generation typically implies that there are relationships between the various random elements being generated, via a stateful algorithm. Consider the map generation in Factorio, where ores and water form in patches, in contrast to what the map would look like if each tile were assigned a random resource with no accounting for neighbouring tiles and higher-level structure. It's not enough to set unequal probabilities to create structure.
This mod looks like it does a great job if you only want the ratios to change, but to have the same fundamental ingredients. Having played with expensive recipes and found them a lot of fun, there is much to be said for that, so it's no back-handed compliment. But a structured procedural generation of recipes would offer a very different challenge and is what's in scope here.
Shameless mod plugging: Ribbon Maze
- Ranakastrasz
- Smart Inserter
- Posts: 2171
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Procedural recepies
Yep. No reason you can't extend it tho. It gives you the tools you need and an example, but without more information is isn't going to happen.
It is possible to make recipes via script, even vanilla does it now for barreling, so that is fine. Same with any other prototype.
As such, using this mod as a base the suggestion is possible. I at least don't understand the problem well enough to do anything with it yet.
It is possible to make recipes via script, even vanilla does it now for barreling, so that is fine. Same with any other prototype.
As such, using this mod as a base the suggestion is possible. I at least don't understand the problem well enough to do anything with it yet.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Procedural recepies
Very true, it's under MIT license! It's already worth attribution because I can see how it's doing the random seeding, and will borrow it to focus on other matters
My thinking for the procedural generation is as follows:
1. Cheat a bit by using the "master seed" to generate a seed per recipe to be manipulated
2. Manipulate recipes in a defined order (if a recipe is removed in a future version of Factorio, then it's seed would be skipped over etc.)
3. The choice of ingredients for the recipes is psuedo-random, but independent between recipes
4. The ratios for the ingredients, however, is adjusted, to give a similar total cost in raw products and time for final products. The ratio adjustment has no psuedo-random element, given the chosen ingredients for each recipe.
5. Begin with science products, then other final products, and then move backwards (this is the procedural part) to determine ratios. Say the green science was switched to use underground belts instead of standard belts; then some other ingredients upstream would be reduced. Underground belts might take less iron plates, for example.
The above process should give the overall framework. It should minimize the pain caused by future updates, limiting them to changes in ratios rather than erratic changes in recipes. It should also be compatible with recipes from other mods, as long as the ingredients are limited to those that are possible given a certain technology level etc. Those mods will just not have procedural recipes.
There's a lot more to figure out, like how to determine appropriate ingredients and avoid impossible combinations (green science requiring plastic for example!) and what heuristic should be used to balance recipe costs overall without creating weird ratios. But it's a starting point
My thinking for the procedural generation is as follows:
1. Cheat a bit by using the "master seed" to generate a seed per recipe to be manipulated
2. Manipulate recipes in a defined order (if a recipe is removed in a future version of Factorio, then it's seed would be skipped over etc.)
3. The choice of ingredients for the recipes is psuedo-random, but independent between recipes
4. The ratios for the ingredients, however, is adjusted, to give a similar total cost in raw products and time for final products. The ratio adjustment has no psuedo-random element, given the chosen ingredients for each recipe.
5. Begin with science products, then other final products, and then move backwards (this is the procedural part) to determine ratios. Say the green science was switched to use underground belts instead of standard belts; then some other ingredients upstream would be reduced. Underground belts might take less iron plates, for example.
The above process should give the overall framework. It should minimize the pain caused by future updates, limiting them to changes in ratios rather than erratic changes in recipes. It should also be compatible with recipes from other mods, as long as the ingredients are limited to those that are possible given a certain technology level etc. Those mods will just not have procedural recipes.
There's a lot more to figure out, like how to determine appropriate ingredients and avoid impossible combinations (green science requiring plastic for example!) and what heuristic should be used to balance recipe costs overall without creating weird ratios. But it's a starting point
Shameless mod plugging: Ribbon Maze