Hey, wow a lot to respond to.
Let's try this.
Impatient wrote: Sun Dec 01, 2019 1:52 am
This immediately shows that the mod is lacking some sort of "normalizer". An algorithm which keeps the ratios within some boundaries
...
one speed module 1 costs one billion crude oil.
...
I really want your mod to generate random tech trees and recipes,
From what i could tell, the latest version of the mod should produce more "sane" recipe trees now because it relies less on transmutation (changing the item of an ingredient to something else).
The one billion crude oil shouldn't really happen, but true, it still can because there is little control over how long a recipe chain can get. This is where the 1000+ recipes come from.
This may make for a good difficulty setting if there was some way i could measure and control how long a chain gets, or rather, how fast a chain can be built like that.
Also, this mod only does recipes.
I
think it would be possible to randomize the technology tree, but i also think it would produce results that are even more insane than it is currently producing.
Maybe something for down the line, but for now it'll just be recipes.
Impatient wrote: Sun Dec 01, 2019 2:37 am
Currently I judge the mod as unplayable. The risk to get stuck at some point in the tech tree for too long or forever is there.
Of course this risk exists.
But i don't think you'd get stuck anywhere for too long as long as the recipes don't rely on non-automatable resources (e.g. wood).
This is the only real problem i see in the mod so far.
Impatient wrote: Sun Dec 01, 2019 2:37 am
An angle to look at the balancing would be, to look at what for resources are spent. I can think of these main sinks:
- to build the factory
- to power the factory
- to make science (including the rocket) for advancing the tech
- and then there are one time use items like ammo
This is not how the recipes are measured.
The logic assumes once you have access to something that generates power (even if its just a solar panel), you are able to power literally everything no issue.
I didn't want to get into the details of figuring out how much of a thing can be powered by the power-generating recipes you have access to because it just don't work like that.
Example: if solar panels cost 1 iron ore each, then you're not going to have any issue powering your base regardless of what the logic thinks.
As for building the factory, these recipes are randomized along with everything else.
There is some logic in place to check if you can "automatically" craft a recipe (e.g. assembling machine), but these values are currently not really used for anything.
Though it doesn't measure how long the recipes would take in terms of crafting time.
As for science, because of how the stepper works you're unlikely to get a seed that has jumped deep into the tech tree before it gives you something to automate it e.g. assembling-machine-1.
However this used to (and should be again) something that is checked before researching too far.
Impatient wrote: Sun Dec 01, 2019 2:37 am
The mod should keep the recipe ratios for items used in these areas within some sane boundaries.
Let's just say as an example between 0.5 and 2 times of the vanilla costs.
There's no simple way to measure that.
If anything the ratios don't actually matter, what really matters is how long the recipe chains are.
This is a lot easier to measure, but at the same time, making the logic act on that is challenging at best.
Impatient wrote: Sun Dec 01, 2019 2:37 am
The mod should take into account what resources are on the map and in what ratios to each other.
This is literally impossible to do because the logic runs during the data stage.
It cannot detect and respond to what your resource settings will be because that happens during the control stage.
Furthermore - resources are accounted for (and most ratios are) by way of simply trying not to transmute the ingredients.
By not transmuting, "vanilla ratios" are maintained, e.g. there will only be one recipe that uses copper ore, and whatever that recipe result is, is technically equivalent to your copper plate for example.
Because of this, ratios are maintained pretty much by default.
Impatient wrote: Sun Dec 01, 2019 2:37 am
Making everything out of wood, would be possible but ...
Possible yes, but i'd like to make it impossible.
Resources that cannot be automated should be transmuted out of the ingredients pool as soon as it is scanned, to avoid scenarios like this:
https://gyazo.com/92ca47114f6106873250f087cdb5a0f9
Impatient wrote: Sun Dec 01, 2019 2:56 am
Btw, something I noticed is, that the mod does not generate a strict dependdency tree for the technologies.
At least it does not with additional mods installed.
The randomization logic strictly depends on and follows the technology tree, particularly when additional mods are installed.
If it didn't, then it would produce impossible seeds on seablock.
Impatient wrote: Sun Dec 01, 2019 2:56 am
I think, what I saw was that a tanker from mod cargo ships had a tier 1 miniloader from mod miniloader as ingredient in its recipe.
But the tech for the tier 1 miniloader was not a dependency of the tech of the tanker.
The logic won't generate a recipe that makes use of an ingredient that you haven't unlocked yet.
e.g. if your tanker requires a miniloader, then the miniloader
definitely won't need a tanker in its recipe chain.
The only exceptions to this rule is if there are multiple recipes that produce the same item, but even in those cases, there will always be one recipe to produce it that does not itself require the result.
This is because, if such recipes existed, then the seed would be technically impossible.
Impatient wrote: Sun Dec 01, 2019 2:56 am
I presume you thought about it well enough and made sure the recipes have a strict dependency tree.
What you may have been seeing is how the logical stepper will scan a few technologies and then randomize a few recipes.
This means that some recipes will have ingredients that are "closer" on the tech tree, but it can occasionally produce recipes that have ingredients very "far away" from eachother on the tech tree.
Really, it's completely randotorio!
Impatient wrote: Sun Dec 01, 2019 3:38 am
A case which shows how important it is to take into account what resources are available on the map and in what ratios to each other is, if all the recipes depend let's say 80% on stone. Suddenly a vanilla map becomes a railworld map, but even more outstretched.
See above - this is literally impossible to do because the logic runs during the data stage.
It cannot detect and respond to what your resource settings will be because that happens during the control stage.
Instead, see above notes on transmutations - ratios are reasonably maintained by avoiding transmuting ingredients as much as possible, and this particularly applies to resource distributions.
Impatient wrote: Sun Dec 01, 2019 3:54 am
Another idea on how to approach the balancing is to divide the game into eras. An era would be delimited by eg researchable technologies. Or maybe by buildable things. Let's take researchable techs. There would be the pre-science era, the red era, the red-green era and so on. The resources needed to advance from one era to the next should also be within some set boundaries.
How can this "red science green science eras" be applied to seablock? or pymods? or god knows what else?
The thing you've got to remember is literally nothing is hardcoded.
The mod doesn't actually test ratios, it doesn't test resources, and really, it
doesn't need to.
What if you had omnimatter installed, which removes all the base game resources?
What about seablock?
Any randomization rules or ideas put forward for the randomizer
must work in every environment.
E.g. what if there is a mod that puts automation far into the tech tree and you have to handcraft up to it?
Such a mod would throw a serious wrench into pretty much every idea you have suggested so far.
Impatient wrote: Sun Dec 01, 2019 3:54 am
Looking at it like that, in my opinion the proper name for the current randomizer should be hardtorio, slowtorio, masotorio, crazeoutorio or quitorio.
Factorio is balanced to have "reasonable" recipes at all stage of the game.
If you start to shuffle the recipes around, you are definitely going to end up giving yourself some insane recipes.
But well, that's what i made the mod for!
This is not a vanilla remix.
This is randotorio.
RNJesus is your god now, and if he wants 1000 iron ore per automation science pack, then that's what it's going to be.
All glory to RNJesus.
Impatient wrote: Sun Dec 01, 2019 2:56 pm
Another thing I just noticed is, that Randotorio is creating perpetum mobile recipes.
With the standard seed eg it is possible to make one empty barrel and 50 light oil from one empty barrel.
This is a circular dependency.
Using this recipe and one initial empty barrel, I can make unlimited light oil out of some energy used in the production.
There is not really anything wrong with circular dependencies.
I thought the barrels being randomized was absolutely hilarious, and i did see how you could technically get "infinite" resources from them if they end up with the right ingredients, e.g. unbarreling oil itself costs an empty barrel, which can happen.
If i were to add catalyst checks (e.g. so a recipe can't require an ingredient that is in its results) then you conflict with the uranium enrichment recipe.
What i'm saying is those circular recipes already exist in vanilla, it's just a very short one spanning a single recipe.
It's little things like this that make rando logic very hard to write.
And although you can perhaps make the oil cheaply, what're you going to do with all those empty barrels?
Personally i just liked seeing how the barreled fluids actually had some uses in the recipes, e.g. you
must barrel some fluids in order to craft something, so making these recipes part of a chain is pretty unique and interesting.
However, because of the niche unique behavior of the barreling/unbarreling recipes (and
specifically the barreling recipes), i can probably add a setting to make the randomizer ignore them.
They're a bit like the angelbobs converter and void recipes anyway and can be more or less ignored without impacting the randomization logic in any meaningful way.
If you have access to the fluid that makes the barrel, adding/removing the barreling recipes would not really impact what you can craft.
Leaving barrels as, at most, a possible transmutation target for ingredients, and this is quite desirable.
Impatient wrote: Sun Dec 01, 2019 2:56 pm
I think in general this should be avoided.
If this was avoided, then the logic wouldn't be able to finish with seablock installed.
Seablock makes heavy use of circular recipes.
Impatient wrote: Sun Dec 01, 2019 2:56 pm
Circular dependencies are bad. Very bad. They can make items unobtainable. Eg when one tanker needs a miniloader as ingredient and one miniloader needs a tanker as ingredient.
Like in this case, circular dependencies can also lead to perpetum mobile recipes. Or perpetum mobile recipe groups.
False.
Circular recipes must be started from somewhere.
There will never be a situation where you need an ingredient which is the result of something in the recipe loop that you didn't already have access to.
On top of that there is transmuation, so it is literally impossible for impossible recipes to happen, no matter how convoluted it is.
The only exception to this issue is if a mod, like seablock, gives you special items to start with (starting / initial conditions)
That's the only time i need to manually add specific items to the randomizer to make the logic work.
I'm not sure what you mean by perpetum mobile recipes, but at a guess it's about duplication recipes. i'll come back to that.
Impatient wrote: Sun Dec 01, 2019 2:56 pm
I think perpetum mobiles can be avoided if the mod breaks all production costs (ingredients and power) down to basic resources (stone, ore, crude oil, ... ).
If the net cost in basic resources is negative, this recipe or group of recipes should be removed and re-rolled.
Impatient wrote: Sun Dec 01, 2019 4:34 pm
I went through the chore of sanity checking the standard seed "Randotorio" for how much resources are needed to make 0.5 science/s of each type. I used helmod to do this.
The results are funny.
400 mio iron ore/s (smelted in 1.5 BILLION stone furnaces
)
32 mio coal/s
Copper ore with a necessary rate of 27k/s is not even worth mentioning compared to the above.
That's some pretty useful imperical data.
Aint gonna deny, i agree more work needs to happen.
But i also must again stress that this mod is very complicated, and changes like a "maximum recipe chain length" is not a simple thing to engineer.
We'll see how it goes over the next few iterations.
Always spiralling closer and closer towards that perfect version.
Impatient wrote: Sun Dec 01, 2019 4:34 pm
A polite question pyrofire: Did you playtest your own mod?
Even if i "playtested" it, well, do you have
any idea what goes into this mod actually function?
This isn't some mod that i can tweak a few settings and it works right, or that it's a matter of a few numbers being in the wrong place.
Logic is very hard to write, and very complicated.
Often it can take entire code blocks to account for a single little thing, e.g. "can i currently automate this science pack i'm about to unlock? If not go find it if it exists".
And even then, i'm not really ever directly controlling the randomizer logic (with that being the only exception).
I'm more like "guiding" it through the technologies and recipes lists at certain rates.
In fact, just to illustrate the point, heres what that code looks like to forcibly search and "select" automation for a science pack (that is unlocked by said science pack) (and assuming you can actually perform research e.g. you have labs with that science pack slot and can power said lab)
Code: Select all
function rando.ScanTechAutomation(pack) -- Search for automation for a newly unlocked science pack & forcibly randomize it.
if(rando.hand.categories[pack.crafting_category or "crafting"]==1)then return true end
for k,rcp in pairs(data.raw.technology)do
local packs=proto.GetTechnologyPacks(rcp)
local can=true
local ispack=rando.packs[v]
if(ispack)then if(not rando.hand.labpacks[v])then can=false end elseif(not rando.hand.items[v])then can=false end
if(can)then
local fx=proto.GetTechnologyEffects(rcp)
if(fx)then
for k,v in pairs(fx.recipes)do
local rx=data.raw.recipe[v]
local rx_results=proto.GetResults(rx)
for i,e in pairs(rx)do
local rxitem=proto.RawItem(e.name)
if(rxitem and rxitem.place_result)then
local ent=proto.PlaceResultEntity(rxitem.place_result)
if(ent)then
local cats=proto.CraftingCategories(ent.crafting_categories)
if(cats)then
for a,b in pairs(cats)do
if(b==pack.crafting_category)then
rando.PushTechnology(rcp)
rando.PushRecipe(rx)
rando.ShuffleRecipe(rx)
return true
end
end
end
end
end
end
end
end
end
end
end
So i answer your question with a counter question, Impatient: Did you read my code?
It's one thing to be a critic, it's another to be the person who actually made this concept a reality.
That's no simple feat or it would have already existed before i started writing it.
Which, ironically, looking at the final post here..
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
This is funny, last month I attempted to create a similar randomizer mod myself, based on Kenira's Random Recipes mod.
I'm glad to see there's a mod that does it correctly. I'll give it a try.
Woo!
Yeah this mod was (and still is) a pretty tough one to write for!
Also, very important: This mod randomizes recipes, whereas Kenira's Random Recipes mod only changes the
cost of those recipes.
E.g. smelting iron-ore to iron uses 2 ore instead of 1, or whatever.
Randotorio changes it so you might need to smelt a transport belt to get iron plates.
Big difference (for anyone else reading this thread).
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
In making my mod, the two major issues are separating tech tiers and ensuring that you don't get circular dependencies.
Not an issue and both situations are already accounted for.
That's what the entity logic is for - e.g. can a lab be given power and do you have a power pole?
If not - you shouldn't unlock further technologies because you can't actually physically research anything!
The current logic already takes that into account.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
- Items acquirable without crafting.
- Items acquirable without any research.
- Items acquirable after researching all of the research available at the previous step.
- Repeat the above step (you'll get to 6 or 7 before you're at the infinite techs).
Those first two points are actually only used when setting up the initial conditions.
Don't forget there may also be technologies that are a technology, unlocks recipes etc, and are actually enabled in the data stage which means you start with those technologies researched.
There's also a few things about hidden recipes, hidden technologies, and worst of all, recipes that are not hidden, are not enabled, and are
not unlocked by any technology e.g. "small-plane" (yes this is actually a real recipe in vanilla it's just "hidden") that i've already taken care of.
Steps 3 and 4 is how you scan for the science packs relative to what stage you unlock them.
And is basically how
https://mods.factorio.com/mod/scientorio does it, e.g. utility science packs requires both chemical and military, and space science packs would need both utility and production.
Each science pack is sort of its own step, and scientorio is very explicit about that.
Funfact: Randotorio and scientorio are based on the same logic system / backend.
And so is Spaceblock (moreso for the initial conditions like what is and is not a minable resource (versus uranium ore for example which needs a fluid) and the "first science pack").
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
I attempted to automate this in LUA and the API, but it's really finicky.
Believe me, i know exactly how finicky we're talkin' here
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
For example, liquids, initially available recipes,
Some fun facts about liquids:
There are zero liquids available at the start of the game.
Liquids cannot be hand-mined or hand-collected.
And same goes for resources that require liquid input to be mined e.g. uranium.
This is because water, seemingly endless and abundant, is inaccessible until after you can access and craft the offshore pump.
And for vanilla, the offshore pump makes water, which is used by the boiler to make steam, which steam goes into the steam engine to make power.
And because the ingredients are randomized, that means you may not be able to get the pump until after a few intermediates are randomized.
It's little things like this that make rando logic very hard to write, because consider that for a moment.
You may have the recipe for the boiler, it may already be randomized, but you won't neccessarily be able to fuel it (e.g. if it used something that had to be made from an assembler for example instead of just hand-minable coal).
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
You have to specify a bunch of things manually or make a lot of exceptions, and it's probably easier to specify everything manually instead.
Easier yes, but also about the same amount of work with far less payout.
I want this thing to work with literally anything on the mod portal.
Aint going to do that with hardcoded item names or mods doing weird things like, having a technology require an item as its ingredient, but that item isn't actually obtainable and there is no lab that can work with it (No seriously, the first 3-4 reasearches in Seablock are exactly this and i had to add special checks for it)
And what if one of those mods is updated? :shudder:
The only exception to this, at least for rando logic, is the starting conditions, like how in seablock you start with some power and a few ingredients - but at the same time, again because ingredient randomizations, you don't actually have access to water until the pump is randomized.
Finicky is an understatement
Currently as it stands, randotorio is 99% procedurally generated with the only exception being the seablock starting conditions.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
Without creating checks for circular dependencies you end up with them about 99% of the time or more.
I realize rando code is very complicated and hard to read, but if you were to read it, you'll find zero checks for circular recipes/dependencies.
"Impossible" recipes are avoided naturally because of how the logic is written to behave - it will never add ingredients to a recipe that it does not yet have access to.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
There was
never a time when I didn't have such a situation.
I can see there may be two ideals here.
When you say circular recipes i'm assuming you're talking about recipes that require itself and becoming impossible.
As explained earlier this is a non-issue.
On the other hand, you may also be talking about infinite self-replication recipes.
E.g. what if a mod adds two iron-gear recipes, and they're intended to just be different ratios of the same recipe.
Because there are now essentially two ways to make iron gears (even though the mod made it exactly the same way), it is possible for the second recipe to itself cost some iron gears (and possibly even at a loss), even without transmutations.
I don't see it as an issue, mostly because anything you do about circular recipes would completely break seablock which relies on circular recipes, but i agree it needs more thought.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
Of course, the whole concept of randomizing the order of all (available) recipes does create gameplay that has massive variation in difficulty, but that's the whole nature of it, you just have to accept it.
That's basically what i'm looking at.
I can see the difficulty is high particularly towards the endgame, but that is not something i can directly control because everything is randomized.
I don't even know when you'll get access to water via the offshore pump, but also consider this: i can be
100% certain it is before you can power a research lab for example.
Perhaps i should explain more about the logic system, how it's structured and how it works so others can better understand what it's doing so anyone interested has a chance to consider these things first before entering discussions with it.
The objective here is to come up with ways to describe a "logical rule" which will guide the logical stepper in the direction we want it to go.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
Some slight feedback: It seems indeed to be true that, on average, items become considerably more expensive to craft, even with difficulty turned down - I used 1, 2 for the min max values. One thing you can do to alleviate it is to randomize output item counts as well
The difficulty settings are a bit of a strange way to control it.
I'd like to add more options in the future.
MEOWMI wrote: Sun Dec 01, 2019 5:51 pm
(Kenira's mod does this and thus my mod also does).
I'll have to double check that.
I recall it not being very useful last time i looked at it, but that was only a skim.
-----------------------------------------------------------------------------------------------------------------------------------
Whew that's a lot!
Some wall of text amirite?
the TL;DR of all this comes down to a few things.
Q: Recipes that are circular in nature, e.g. requiring the result of eachother as an ingredient, can be impossible to start. Is this an issue with Randotorio?
A: The randomization logic ensures that this never happens - you will always be able to logically "enter" a circular recipe chain.
Q: What about recursive recipes which can result in an infinite surplus or deficit of something?
A: Between the nature of randomizing ingredients, and how mods like Seablock explicitly rely on circular recipes, nothing is currently done about recursive recipes.
Now the difficult part.
Difficulty.
- Particularly of end-game recipes
- Examples given such as a single item costing in the 1000's of a resource or needing 1.5 billion furnaces to produce one science pack every second.
Rando Example: Say, red science needs 5 gears and 5 copper plates. 1 Gear needs 5 iron plates. 1 Iron Plate needs 5 electronic circuits. 1 electronic circuit needs 4 iron pipes. 1 iron pipe needs 5 stone brick. 1 stone brick needs 2 copper ore. 1 copper plate needs 5 copper wire. 1 copper wire needs 5 coal.
The sum of this example is: 5gear *5iron-plate *5electronic-circuit *4iron-pipe *5stone-brick *2copper-ore = 5000 copper ore. 5copper-plate *5copper-wire *5coal = 125 coal.
And that's just one science pack.
There is nothing stopping the logic from producing an outcome like this.
I believe this issue is a mix of factors.
And starting with the obvious, the length.
Most recipes aren't that long, even in the end-game.
Though part of randotorio is making this intentionally happen.
In the example, if we avoid a longer chains we can remove the 5 iron plates step before gears and immediately reduce the cost from 5000 copper ore to 1000.
Removing a step also makes it take less time to craft the entire chain in sequence.
The second issue is the cost of each step.
In the example, if even a single of the 5's is reduced to a 2, we immediately reduce the cost from 1000 (after previous step) to 400.
So that's basically what needs to happen, but how to do it?
Notes:
- I was thinking something about checking for "endpoints", e.g. a recipe that makes an item that is placeable, versus an intermediate, but that doesn't work because seablock uses endpoints as ingredients normally.
- Recipe lengths can be calculated, even with recursive loops. And because i'm reconfiguring the recipes from the ground up, "distance from mineable resource" can be built as it goes, with mineable resource referring to anything that can be infinitely reproduced (e.g. mineable, or by recursive recipes). This gives us an easy way to score the recipe (e.g. marketplace if i wanted to), but i dont see this as useful for logic purposes. Nothing wrong with loops, in fact it's somewhat cool. Maybe that's how you get that 5,000 copper? I can probably turn this into a setting or something to have more control over it.
- Desired score: One way to calculate this is just how deep into the technology tree it is compared to the longest existing tree, inclusive of the science pack cost of the technology and the recursive science pack cost of its ingredients (recursively). This also means having many small technology trees that are available at the start of the game but require science packs from later on have their distances calculated correctly. Example: Satellite is 99% of the largest chain size, but landfill is 5% and blue science at about 50%.
Solving for this problem reactively is easy, you just randomly change ingredients and counts until it meets some desired score.
But i would prefer to do it proactively (the logic knows beforehand, not after).
Watch this space for more maybe?
Join us on discord?
https://discord.gg/a9CNarA
because laying all this out has taken quite a while as it is and it's not an easy problem to solve (if i haven't made that clear enough yet).
I'll add some stuff to the FAQ about how the logic works