KirkMcDonald / kirkmcdonald.github.io

Simple web-based calculator for the game Factorio.
Apache License 2.0
540 stars 148 forks source link

Space Science Timings #196

Open JellyCoatedBean opened 4 years ago

JellyCoatedBean commented 4 years ago

What timings are actually used for Space Science?

If I want find out how many Control Units I need to constantly run .854 of a Silo I use: .8541024/???=

Is it possible to add the time used somewhere in the calculator? It seems like the time used here is 3.416, giving me an answer of 60 level 3 Assemblers to run .854 Silo. I'm not very good with numbers and don't really know what's going on tbh.

Awesome tool btw :D

DRY411S commented 3 years ago

Don't you just select Space science as your output and choose .854 space science 'factorys' (which is in fact the silo)?

https://kirkmcdonald.github.io/calc.html#data=0-17-60&min=4&k=off&belt=fast-transport-belt&mprod=30&dbc=16&items=space-science-pack:f:.854

JellyCoatedBean commented 3 years ago

Yeah, the calculator works it all out for you. I wanted to know what the hidden workings were. In this case, the time programmed into the calculator for space science. I like to work out the ratios myself and use the calculator to check before I build. Huge waste of time I know, but it's one of the things I love about the game. It seems when I change the amount of rocket silos in use in the calculator, it changes the time taken to launch. So I was hoping the creator could add the timings in the calculator for a rocket launch, since 3 secs obviously doesn't work.

DRY411S commented 3 years ago

The time taken to launch does not change. The frequency that you can launch rockets changes that's all.

The time programmed into the calculator is dependent upon the modules and the beacons associated with the silo. Whilst these can make the craft time of the 100 rocket parts faster, they have no effect on the 2475 ticks for the rocket to emerge from the silo and for the doors to close post launch. That sequence is unaffected by modules and beacons.

JellyCoatedBean commented 3 years ago

Yes I know, this is the reason for my question. I'm asking what time the calculator uses for space science and if it can be displayed. If I were to use the 3 secs per part (plus or minus any beacons), plus rocket launch animation, it doesn't up. And if I change the amount of Silos used, as I say, the calculator seems to change the time per part, not in game obviously. This only happens when Prod Mods are used in the calculator. It might have been formulated in a not so obvious way to account for productivity not affecting launch animation. Just wondering what it is and if it can be displayed.

DRY411S commented 3 years ago

factory.js contains the code for the silo and thus space science. It's an open source project, you are free to propose code changes. :)

I were to use the 3 secs per part (plus or minus any beacons), plus rocket launch animation, it doesn't (add) up.

This only happens when Prod Mods are used in the calculator.

Are you remembering that the Prod modules reduce the number of rocket parts required for a launch? 4 Prod 3 Modules in a silo mean that only 714.29 rocket parts are required for a launch.

I'm asking what time the calculator uses for space science and if it can be displayed.

The calculator doesn't use time for space science. If you say what amount of space science you want per time period, it uses that to calculate how many silos, and assemblers you need for RCUs, LDS, rocket fuel, and (the unique part for space science) satellites. When calculating the silos required, it factors in that the silos cannot make rocket parts for 2475 ticks post launch.

JellyCoatedBean commented 3 years ago

Thanks Dry :D I did have a look at that when I was trying to figure this out, but couldn't figure out how it was being worked out from it all. I'm not too bright in general.

Yeah, factored in the reduced parts needed.

Sorry, I mean the time used in the Silos. There must be a time used in the Silo for the calculator to know how many components would be needed to keep it running surely? For example, if I have 10 grey science assemblers and I need to know how many component assemblers I need to keep it running I use - 10(grey sci) x 1(red ammo needed) x 2.4(time for 1 red ammo in assembler 3) / 8(time for grey sci in assembler 3) = 3(assembler 3 making red ammo). I assume the calculator takes the time from a recipe and divides it by the assemblers crafting time. It needs to know how long it takes for something to be made , in order to keep it running.

DRY411S commented 3 years ago

For example, if I have 10 grey science assemblers and I need to know how many component assemblers I need to keep it running I use - 10(grey sci) x 1(red ammo needed) x 2.4(time for 1 red ammo in assembler 3) / 8(time for grey sci in assembler 3) = 3(assembler 3 making red ammo).

Yes, so you would do something like this. https://kirkmcdonald.github.io/calc.html#data=0-17-60&rate=s&min=4&furnace=stone-furnace&items=military-science-pack:f:10

Tell the calculator that you want to have 10 grey science makers and let it calculate how many of the other assemblers it needs to have for red ammo. grenades and walls.

There must be a time used in the Silo for the calculator to know how many components would be needed to keep it running surely?

No. You tell the calculator how many 'rocket part factories' you want to have. Essentially, 1 'rocket part factory' equals 1 silo working all the time (including the 2475 ticks when it can do no work.)

Example: I want 1 rocket part factory (essentially a silo). https://kirkmcdonald.github.io/calc.html#data=0-17-60&rate=s&min=4&furnace=stone-furnace&items=rocket-part:f:1&ignore=electronic-circuit,advanced-circuit

Note how it tells you that you need 1 silo. That means 1 silo running all the time (allowing for the 2475 ticks when it is idle). The rest of the output is the assemblers smelting and ore needed to keep the silo running 'all the time'.

image

If you tell the calculator the rate of space science you want, it calculates the rocket part rate, which drives the number of silos required, and the extra for the sattelite manufacture.

Example: 1000 space science per minute

https://kirkmcdonald.github.io/calc.html#data=0-17-60&min=4&furnace=stone-furnace&items=space-science-pack:r:1000&ignore=electronic-circuit,battery,advanced-circuit

Here you are told that you need 5.7 silos. That's 5.7 silos running all the time, allowing for the 2475 ticks when it cannot make parts.

image

(Of course you cannot build 5.7 silos. Building 6 will mean that they are each working 5.7/6 = 95% of the time allowing for the 2475 ticks)

jdashton commented 3 years ago

(Of course you cannot build 5.7 silos. Building 6 will mean that they are each working 5.7/6 = 95% of the time allowing for the 2475 ticks)

Or, perhaps wording it slightly differently, it means that each of the six silos will overproduce slightly, or will be inactive about 5% of their possible production time (not counting the launch animation), waiting for parts to be delivered to them.

JellyCoatedBean commented 3 years ago

Yeah I get how to use the calculator. I know that I can just punch in what I want and it works it out for me, like with the grey science. I literally just say I want to make so much science per sec, or I want to know the output of 10 machines, and it will give me all relevant machines needed. But for the calculator to know how to keep a machine running without pause, it needs to know how long each recipe takes, which will already be programmed into it, I'm not saying I need to input this, I just wanna know. It needs a time so it can calculate the component machines. If in the Silo's case, rather than know an individual time for each rocket part, it just does it as a whole per launch, what is this time? That's my query, and wondering if it can be displayed alongside the main calculator? Since I can't find it in the code. I don't think I'm being clear in what I'm asking, I just don't know how else to word it xD Maybe more simply, does anyone know the exact formula the calculator uses for silos? Maybe some handsome code trawler can fish it up for me?

Thanks for the help so far :)

DRY411S commented 3 years ago

(Of course you cannot build 5.7 silos. Building 6 will mean that they are each working 5.7/6 = 95% of the time allowing for the 2475 ticks)

Or, perhaps wording it slightly differently, it means that each of the six silos will overproduce slightly, or will be inactive about 5% of their possible production time (not counting the launch animation), waiting for parts to be delivered to them.

Sure. My statement was based on the assumption that the rest of the calculator wwould be followed, and there would be no capacity for over production by silos. :)

DRY411S commented 3 years ago

If in the Silo's case, rather than know an individual time for each rocket part, it just does it as a whole per launch, what is this time? That's my query, and wondering if it can be displayed alongside the main calculator? Since I can't find it in the code. I don't think I'm being clear in what I'm asking, I just don't know how else to word it xD

The calculator IS telling you how many silos you need for them to work without pause. If it tells you (for example) you need 0.5 silos, then if you could build 0.5 silos, it would work without pause.

You will though build 1 silo. If you don't double evrythng else that the calculator has output, and build 'to specification', then the 1.0 silos that you have built will only be working half the time. I'm not sure I understand the value in knowing what that time is, I understand what you are asking. If you knew that per launch, the silo was not making rocket parts for 20 seconds elapsed, what would you do with that information?

Maybe more simply, does anyone know the exact formula the calculator uses for silos? Maybe some handsome code trawler can fish it up for me?

In factory.js

`var rocketLaunchDuration = RationalFromFloats(2475, 60)

function launchRate(spec) { var partRecipe = solver.recipes["rocket-part"] var partFactory = spec.getFactory(partRecipe) var partItem = solver.items["rocket-part"] var gives = partRecipe.gives(partItem, spec) // The base rate at which the silo can make rocket parts. var rate = Factory.prototype.recipeRate.call(partFactory, spec, partRecipe) // Number of times to complete the rocket part recipe per launch. var perLaunch = RationalFromFloat(100).div(gives) // Total length of time required to launch a rocket. var time = perLaunch.div(rate).add(rocketLaunchDuration) var launchRate = time.reciprocate() var partRate = perLaunch.div(time) return {part: partRate, launch: launchRate} } `

Thanks for the help so far :)

I don't think I can help further.

JellyCoatedBean commented 3 years ago

Yeah you're definitely not getting what I'm saying. I understand the calculator and what it's telling me. I know how to use it build a factory, it's pretty straight forward. I'm not asking how many Silos I need, or how to work it out, or how to use the calculator. Literally just if anyone knows the time the calculator uses for space science, to be able to give us the figures it does. And if it can be added to the interface. As I said, I can't figure out what time is used for the launch in the calculator based on the code. I get the launch animation of 2475 ticks for rocket launch, that's where I got it from, but that's not the whole story. It's the time used in the calculators formula I'm after. Not production per second, or amount of buildings needed, all of which I can get from the regular interface of the calculator. There's no reason for anyone to know why I want this info, but as I said, I like to work it out and build the factory without using the calculator. I use this sometimes to check big builds before I build it. It's part of my personal fun. If I know it won't be working for so much time, then I need to account for that when building component machines. I don't like idle machines. I like seeing all machines run perfectly, infinitely, without stopping. Very satisfying, but I want to work it out myself and have got stuck with just this last bit.

DRY411S commented 3 years ago

And you're not getting what I'm saying. There is no calculation per se for time to make space science. Space science is a by product of a rocket launched with a satellite. And that's what the calculator outputs.

The calculation for the number of silos+satellite (= space science) is almost exactly the same as for the numbers of smelters, assemblers, refineries, chemical plants, and the miners. The calculator factors in that the silo can do no work during the animation, unlike the assemblers, refineries etc, that can do work all the time.

Perhaps 'the time to make the space science' that you are referring to is 'the time to prepare the rocket for launch with a satellite'? Well that is:

It will be the same for each silo. Is that what you want to expose in the calculator output? If one accepts that the assumptions are true, then that time is 300*prod_module_effect/beacon_module_effect.

That number is a constant, and will always be the same, based on the module and beacon settings you select. It will only be accurate if you build out to meet the assumptions above. If you don't build the RCUS, LDS, rocket fuel and satellite fast enough then the calculator has absolutely no idea how long it will take. And I still don't see that it has any value whatsoever.

That was definitely my last word on the subject...

BTW, good luck with coming up with a build that has every machine running all the time infinitely. Every time the calculator tells you that you need X point something of a machine, you need to round up to X+1 otherwise production will be short. As everything balances out, that means that there will be some point in time when that X+1th machine is idle. Unless you can manage to come up with modules in the X+1 machines that mean they work exactly like X point something.

jdashton commented 3 years ago

@JellyCoatedBean , the individual components are described in files divided by the game version and the expense:

(Try this search.)

Looking in data/vanilla-0.17.60.json we can see ten occurrences of rocket-part. The first three assert (starting around line 2405) that rocket-part is affected by the three varieties of productivity module. Those definitions also describe the various attributes of those productivity modules, including their speed and production bonus numbers.

A specific description of the rocket-part item begins on line 2741. This doesn't seem to go far toward answering your question.

Farther down in the file, beginning on line 7976, we find the recipe for rocket-part. This includes several interesting details, but the one that seems closest to your query is the, perhaps mis-named, energy_required:

"energy_required": 3,

Performing a manual comparison of this field in other recipes against the documented time to produce those items as described in the Factorio wiki suggests that this field is actually the number of game seconds required to produce one item in a factory (silo, in this case) with no modules, i.e. the base rate.

So, looking again at the code that @DRY411S pointed to above, we retrieve this recipe on line 281, and on line 286 we ask the factory, working with the recipe, to give a rate modified by the selected modules (I'm assuming that's what spec represents) for producing this item.

On line 290 we get a total production and launch time for 100 parts, i.e. one rocket. That's the "time" you asked for to produce 1,000 space science packs.

If you fork this project (GitHub is great about that), you can play with these numbers and look for a place to expose them in the interface. If you find a solution that is useful and looks good, you can submit a pull request offering your updates back to the original project.

I hope that helps and answers your questions.

DRY411S commented 3 years ago

@jdashton "energy_required" is in fact the number of seconds to make the recipe, assuming that the 'factory' (in this case a silo) has a craft speed of 1. See https://wiki.factorio.com/Prototype/Recipe#energy_required

It is definitely not an intuitive name. It is used in all recipes, whether the recipe is made in a silo, miner, refinery, chemical plant or assembler.

I've been thinking about the OP request about displaying 'time to make space science'. I think that the answer is... 'all the time'.

It should be easy to display that. 🥇

jdashton commented 3 years ago

Ooh, a part of the wiki that's new to me. Thanks for teaching me about that!

DRY411S commented 3 years ago

Ooh, a part of the wiki that's new to me. Thanks for teaching me about that!

Recently new to me. Before then, I was using definitions of everything factorio at https://lua-api.factorio.com/latest/ and publicly complaining on the forums that it wasn't being kept up to date.

That's when Klonan told me to use the wiki instead....

JellyCoatedBean commented 3 years ago

I get everything you're saying, but every reply you give, answers neither of my questions. When you input something for space science, it gives you the silos you need, since the silos are what create the rocket parts and launch, it's the figures in that calculation I'm after. Maybe I should have been more clearer on that, just didn't think I needed to. Obviously the formulas used will not change. My issue was when I use it manually, all things taken into account like rocket launch time, speed and prod mods, the timing for each part seems to change, which means there's an additional part of the formula I was missing. If I knew the time the calculator uses, that would help me along. Since the Silo can't produce during a rocket launch, this changes the way this specific recipe is worked out compared to the rest. So regardless of how similar it is to the rest, it isn't the same and doesn't help. The calculator tells you how many component machines you would need based on the speed of the silo and the time of the crafting recipe (rocket part) which is just what I was after. As opposed to knowing how long it takes based on my production. As jd says, it's 3 per part (base) which we knew it was, I just needed clarification to see if they changed it to make dealing with the idle time easier. Which is exactly what I needed, so thanks for that @jdashton. I'm just screwing something up when I'm working it out.

Obviously not all recipes are perfect, which kills me. especially the newer addition of 103/s water consumption in heat exchangers (that one hurt). But I won't know how close I can get it, if I don't have all the pieces I need to work it out. Most of my machines are perfect, no circuits, no over/under production. I've just always used circuits for the silos and wanted to better work it out myself and not rely on the calculator to do the work for me.

But yeah it would be cool if say after all beacons and mods are factored in, the new craft time for the recipe is displayed at the end or something. Seems like a simple addition, but really not necessary. Just helps people like me that aren't good with this sort of stuff, or explaining what I want it seems xD

Question answered, thanks for support guys <3

DRY411S commented 3 years ago

Now we heading offtopic and talking about the game rather than the calculator. But as far as I know, the heat exchangers have always consumed 103 water/s. There is nothing in the wiki that syas it has changed since nuclear was introduced in 0.15. https://wiki.factorio.com/Heat_exchanger.

But glad we got there in the end with the silo/space science timing. Though I confess I'm not sure where 'there' is. :lol: