-
Notifications
You must be signed in to change notification settings - Fork 156
/
calc.html
315 lines (272 loc) · 14.2 KB
/
calc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<html>
<head>
<meta charset="utf-8">
<title>Factorio Calculator</title>
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="calc.css">
<link rel="stylesheet" type="text/css" href="dropdown.css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-66808523-1', 'auto');
ga('send', 'pageview');
</script>
<script src="third_party/BigInteger.min.js"></script>
<script src="third_party/d3.min.js"></script>
<script src="third_party/dagre.min.js"></script>
<!--<script src="third_party/graphvizlib/index.min.js"></script>
<script src="third_party/d3-graphviz.js"></script>-->
<script src="third_party/pako.min.js"></script>
<script src="third_party/popper.min.js"></script>
<script>
var handlers = {}
</script>
<script type="module">
import { plusHandler, clickTab, clickVisualize, changeTitle, changeRatePrecision, changeCountPrecision, changeFormat, changeMprod, changeVisType, changeVisRender, changeVisDir, toggleDebug } from "./events.js"
import { init } from "./init.js"
handlers.plusHandler = plusHandler
handlers.clickTab = clickTab
handlers.clickVisualize = clickVisualize
handlers.changeTitle = changeTitle
handlers.changeRatePrecision = changeRatePrecision
handlers.changeCountPrecision = changeCountPrecision
handlers.changeFormat = changeFormat
handlers.changeMprod = changeMprod
handlers.changeVisType = changeVisType
handlers.changeVisRender = changeVisRender
handlers.changeVisDir = changeVisDir
handlers.toggleDebug = toggleDebug
handlers.init = init
</script>
</head>
<!--Copyright 2015-2024 Kirk McDonald
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.-->
<body onload="handlers.init()">
<table><tr>
<td>
<ul id="targets">
<li id="plusButton">
<button class="targetButton ui" title="Add new item."
onclick="handlers.plusHandler()">+</button>
</li>
</ul>
</td>
<td class="changecell">
<div class="changebox">
Recent changes:<br>
2024-10-27 - Some Space Age improvements.<br>
Details in the <a href="docs/changelog.html" target="_blank">changelog</a>.
</div>
</td>
</tr></table>
<div class="tabs">
<button class="tab_button" id="totals_button" onclick="handlers.clickTab('totals')">Factory</button>
<button class="tab_button" id="graph_button" onclick="handlers.clickVisualize()">Visualize</button>
<button class="tab_button" id="resources_button" onclick="handlers.clickTab('resources')">Resources</button>
<button class="tab_button" id="settings_button" onclick="handlers.clickTab('settings')">Settings</button>
<button class="tab_button" id="faq_button" onclick="handlers.clickTab('faq')">FAQ</button>
<button class="tab_button" id="about_button" onclick="handlers.clickTab('about')">About</button>
<button class="tab_button" id="debug_button" onclick="handlers.clickTab('debug')">Debug</button>
</div>
<div id="graph_tab" class="tab graph">
<div class="graph_setting">
<form id="graph_type">
<input id="sankey_type" type="radio" name="type" value="sankey" checked autocomplete="off" onchange="handlers.changeVisType(event)">
<label for="sankey_type">
<svg viewBox="0 0 64 64" width="64" height="64">
<use href="images/icons.svg#sankey"></use>
</svg>
</label>
<input id="boxline_type" type="radio" name="type" value="boxline" autocomplete="off" onchange="handlers.changeVisType(event)">
<label for="boxline_type">
<svg viewBox="0 0 64 64" width="64" height="64">
<use href="images/icons.svg#boxline"></use>
</svg>
</label>
</form>
</div>
<div class="graph_setting">
Render mode:<br>
<form id="graph_render">
<input id="zoom_render" type="radio" name="render" value="zoom" checked autocomplete="off" onchange="handlers.changeVisRender(event)">
<label for="zoom_render">Zoom & pan</label>
<input id="fix_render" type="radio" name="render" value="fix" autocomplete="off" onchange="handlers.changeVisRender(event)">
<label for="fix_render">Fixed</label>
</form>
</div>
<div class="graph_setting">
Graph direction:<br>
<form id="graph_direction">
<input id="right_direction" type="radio" name="direction" value="right" autocomplete="off" onchange="handlers.changeVisDir(event)">
<label for="right_direction">Left to right</label>
<input id="down_direction" type="radio" name="direction" value="down" autocomplete="off" onchange="handlers.changeVisDir(event)">
<label for="down_direction">Top to bottom</label>
</form>
</div>
<div id="graph_container">
<svg id="graph"><g /></svg>
</div>
</div>
<div id="totals_tab" class="tab">
<table id="totals">
<thead><tr></tr></thead>
<tbody></tbody>
<tfoot>
<tr class="power-row">
<td class="surplus"></td>
<td class="right-align power-label"><b>total power: </b></td>
<td class="right-align pad"><tt></tt></td>
<td></td>
</tr>
</tfoot>
</table>
</div>
<div id="settings_tab" class="tab">
<table id="settings">
<tr class="setting-section">
<td colspan="2"><span>Data</span><hr></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Use recipe set:</td>
<td><select id="data_set"></select></td>
</tr>
<tr class="setting-section">
<td colspan="2"><span>Display</span><hr></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Title:</td>
<td><input id="title_setting" type="text" size="30" placeholder="Factorio Calculator" oninput="handlers.changeTitle(event)"></td>
</tr>
<tr class="setting-row">
<td class="setting-label top">Display rates as:</td>
<td><form id="display_rate"></form></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Rate precision:</td>
<td><input id="rprec" class="prec" type="number" value="3" min="0" onchange="handlers.changeRatePrecision(event)"></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Count precision:</td>
<td><input id="cprec" class="prec" type="number" value="1" min="0" onchange="handlers.changeCountPrecision(event)"></td>
</tr>
<tr class="setting-row">
<td class="setting-label top">Format values as:</td>
<td><form id="value_format">
<input id="decimal_format" type="radio" name="format" value="decimal" checked onchange="handlers.changeFormat(event)"><label for="decimal_format">Decimals</label><br />
<input id="rational_format" type="radio" name="format" value="rational" onchange="handlers.changeFormat(event)"><label for="rational_format">Rationals</label><br />
</form></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Color scheme:</td>
<td><select id="color_scheme"></select></td>
</tr>
<tr class="setting-section">
<td colspan="2"><span>Factory</span><hr></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Belt:</td>
<td><span id="belt_selector" class="radio-setting"></span></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Preferred fuel:</td>
<td><span id="fuel_selector" class="radio-setting"></span></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Default module:</td>
<td><span id="default_module"></span></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Secondary default module:</td>
<td><span id="secondary_module"></span></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Default beacon:</td>
<td><span id="default_beacon" class="beacon-container"></span>
×
<input id="default_beacon_count" type="text" size="3">
</td>
</tr>
<tr class="setting-row">
<td class="setting-label top-icon"><div><span>Buildings:</span></div></td>
<td><span id="building_selector"></span></td>
</tr>
<tr class="setting-row">
<td class="setting-label">Mining productivity bonus:</td>
<td>+<input id="mprod" class="mprod" type="number" step="10" value="0" min="0" onchange="handlers.changeMprod(event)">%</td>
</tr>
<tr class="setting-section">
<td colspan="2"><span>Recipes</span><hr></td>
</tr>
<tr id="planet_setting_row" class="setting-row">
<td class="setting-label top">Planets:</td>
<td>
<div>(Click to select one planet, shift-click to select multiple.)</div>
<div id="planet_selector"></div>
</td>
</tr>
<tr class="setting-row">
<td class="setting-label top-icon"><div><span>Toggle recipes:</span></div></td>
<td><div id="recipe_toggles"></div></td>
</tr>
</table>
</div>
<div id="resources_tab" class="tab">
<p>Click and drag items to configure resource priority.<br />
Higher numbers = more valuable</p>
<div id="resource_settings"></div>
</div>
<div id="faq_tab" class="tab">
<div class="about-content">
<h3>What does clicking on an item's icon in the "Factory" tab do?</h3>
It omits the dependencies of that item from the solution. The intent behind this feature is to model the case of building a factory when you are shipping in one or more ingredients from elsewhere. For example, if you are making an advanced circuit factory and want to ship in electronic circuits, and want to see the remaining copper cable requirements on their own.
<p>
Clicking on the icon a second time will restore its dependencies.
<h3>How do I interpret the pipe numbers on the "Factory" tab?</h3>
Pipe throughput is inversely proportional to the length of the pipe. This means that the longer a pipe is, the more parallel lanes of pipes will be required.
<p>
Say the solution calls for 7500 units of heavy oil per second. With the default "minimum pipe length" setting, the calculator will display a value of "[pipe] × 7 ≤ 47." This means you will need seven parallel lanes of pipes, each with a maximum length of 47 segments.
<p>
The "minimum pipe length" setting controls the minimum number of segments that a pipe will be permitted before the calculator uses multiple lanes of pipes. It defaults to 17, which corresponds to a fluid rate of 1200/s, which is the output rate of an offshore pump.
<p>
The number of pipes will be omitted if only one pipe is required.
</div>
</div>
<div id="about_tab" class="tab">
<div class = "about-content">
This calculator is copyright 2015-2024 Kirk McDonald. It is licensed under the Apache License 2.0, and its source may be <a href="https://github.com/KirkMcDonald/kirkmcdonald.github.io">found on github, here</a>.
<p>
This calculator is the result of a few years' worth of fooling around, off and on, with performing calculations using Factorio's recipe graph. You may find an essay on the subject, which outlines the techniques used in this calculator, <a href="http://kirkmcdonald.github.io/posts/calculation.html">here</a>.
<p>
Features of this calculator include:
<ul><li>Proper handling of oil products. Obtaining numbers for these recipes can be tricky, as several of the items involved may be produced from multiple recipes.
<li>Support for modules, including beacons.
<li>Support for the mining productivity bonus, introduced in 0.15.
<li>Support for "expensive" mode.
<li>Arbitrary numerical precision. Calculations are performed using bigint rationals, so errors from floating-point calculations should not be an issue.
<li>Support for multiple simultaneous outputs.
<li>May display rates per second, minute, or hour.</ul>
</div>
</div>
<div id="debug_tab" class="tab">
<div id="debug_message"></div>
<label for="render_debug">Render debug tab:</label>
<input type="checkbox" id="render_debug" onchange="handlers.toggleDebug(event)"><br>
Last tableau:
<div id="debug_tableau"></div>
Last solution:
<div id="debug_solution"></div>
</div>
<div id="footer"><a href="https://github.com/KirkMcDonald/kirkmcdonald.github.io">GitHub</a> | <a href="https://discord.gg/yxrBKCP">Discord</a> | <a href="https://www.patreon.com/kirkmcdonald">Patreon</a></div>
<div id="tooltip_container"></div>
</body>
</html>