-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.html
825 lines (753 loc) · 29.9 KB
/
index.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
<!doctype html>
<html ng-app>
<head>
<meta charset="UTF-8">
<!--
Copyright (c) 2013, Gary Court
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<title>KSP Optimal Rocket Calculator</title>
<style type="text/css">
.strong {
font-weight: bold;
}
.page-footer {
margin-top: 32px;
}
.form-control-minimal {
border: none;
background-color: transparent;
}
.input-group-addon:not(:first-child):not(:last-child) {
border-left: 0px none;
border-right: 0px none;
}
.input-group-addon.mathml {
padding-top: 5px;
padding-bottom: 5px;
}
.help-block.warning {
margin-top: 1em;
font-size: 0.8em;
color: #f00;
}
.panel-heading-pill {
display: inline-block;
margin-right: 20px;
}
.alert h1,
.alert h2,
.alert h3 {
margin-top: 10px;
}
.availableParts {
overflow: auto;
height: 77rem;
}
.availableParts.well {
padding-top: 0;
padding-bottom: 0;
background-image: none;
background-color: #f5f5f5;
}
.partList ol,
.partList ul {
padding: 0;
}
.partList .partList {
padding-left: 24px;
}
.packName {
font-weight: bold;
}
.searchProgress {
position: relative;
margin-top: 32px;
}
.searchProgress .actions {
position: absolute;
top: 0;
right: 0;
line-height: 85px;
padding: 0 16px;
}
.searchResults .panel {
margin-bottom: 8px;
}
.searchResults th.cost,
.searchResults th.mass,
.searchResults th.deltaV,
.searchResults th.twr,
.searchResults th.time,
.searchResults td.cost,
.searchResults td.mass,
.searchResults td.deltaV,
.searchResults td.twr,
.searchResults td.time {
text-align: center;
}
.searchResults .stageNumber {
font-size: 1.4em;
}
.searchResults td.stageMultiplier {
font-size: 1.4em;
font-weight: bold;
vertical-align: middle;
}
.searchResults li {
list-style: none;
}
.searchResults .decouplers { color: gray; }
.searchResults .payload { color: black; }
.searchResults .others { color: orange; }
.searchResults .lfoTanks { color: darkblue; }
.searchResults .branches { color: gray; }
.searchResults .lfoEngines { color: crimson; }
.searchResults .boosters { color: darkviolet; }
.searchResults .multiplier { font-weight: bold; }
.donate {
margin-top: 1em;
}
.donate-line {
margin: 0;
}
.help {
float: right;
}
.ellipsis {
letter-spacing: -1px;
}
</style>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="kspcalc.js"></script>
<script type="text/javascript">
function sortParts(parts, optimization) {
if (optimization !== "mass" && optimization !== "cost") {
optimization = "mass";
}
var ascending = function (part) {
return part[optimization];
};
var descending = function (part) {
return -part[optimization];
};
var descending_fuelmass = function (part) {
return -part.mass_fuel;
};
var types = _.groupBy(parts, "type");
return {
lfoEngines : _.sortBy(types[TYPES.LFO_ENGINE], descending),
lfoTanks : _.sortBy(types[TYPES.LFO_TANK], descending_fuelmass),
boosters : _.sortBy(types[TYPES.BOOSTER], descending),
stackDecouplers : _.sortBy(_.where(types[TYPES.DECOUPLER], {radial:undefined}), ascending),
radialDecouplers : _.sortBy(_.where(types[TYPES.DECOUPLER], {radial:true}), ascending),
branches : types[TYPES.BRANCH]
}
}
function SettingsController($scope) {
//default settings
$scope.optimization = "mass";
$scope.optimization2;
$scope.payload;
$scope.deltaV;
$scope.planet = PLANETS[0];
$scope.gravity = $scope.planet.gravity;
$scope.minTWR = 1.2;
$scope.maxTWR;
$scope.minTime;
$scope.maxTime;
$scope.maxMass;
$scope.maxPartCount;
$scope.maxStages = 3;
$scope.maxStacks = 4;
$scope.cluster = false;
$scope.parallel = false;
$scope.asparagus = false;
$scope.atmosphere = false;
$scope.payloadDecoupler = true;
$scope.lastStageSingle = true;
$scope.tankDiametersEqual = true;
$scope.tankDiametersEqualEngineDiameter = true;
$scope.tankDiametersGreaterThenEngineDiameter = true;
$scope.gimbal = true;
$scope.throttleable = true;
$scope.packTree = _.map(PACKS, function (pack) {
var result = Object.create(pack);
result.parts = _.map(_.groupBy(pack.parts, "type"), function (parts, partId) {
return {
name:TYPE_NAMES_PLURAL[partId],
parts:parts
}
});
return result;
});
$scope.webworkersSupported = false;
$scope.searching = false;
$scope.maxStagings = 20;
$scope.bestStagings = [];
$scope.bestStagingsCount = 0;
$scope.bestStagingsValid = 0;
$scope.bestStagingsInvalid = 0;
$scope.bestStagingsArgs = null;
//constants
$scope.NEEDS_OPTIMIZATION2 = NEEDS_OPTIMIZATION2;
$scope.PLANETS = PLANETS;
$scope.PACKS = PACKS;
$scope.TYPES = TYPES;
$scope.TYPE_NAMES_PLURAL = TYPE_NAMES_PLURAL;
$scope.OPTIMIZATION_NAMES = OPTIMIZATION_NAMES;
$scope.Math = Math;
$scope.parseFloat = parseFloat;
//static functions
function convertStaging(staging, args) {
var result;
if (staging) {
result = {
id : staging.id,
attempt : $scope.bestStagingsCount + 1,
optimization : staging.optimization,
metric : staging.metric,
partCount : KSP.Stages.partCount(staging),
cost : KSP.Stages.cost(staging),
mass : KSP.Stages.massStart(staging),
payloadFraction : 0,
deltaV : KSP.Stages.deltaVTotal(staging, args.atm),
time : KSP.Stages.timeTotal(staging),
stages : []
};
var runningDeltaVTotal = 0;
var runningTimeTotal = 0;
var currentStage = staging;
while (currentStage) {
var newStage = Object.create(currentStage);
newStage.next = undefined;
newStage.costStage = KSP.Stage.cost(currentStage);
newStage.costTotal = KSP.Stages.cost(currentStage);
newStage.massStage = KSP.Stage.massStart(currentStage);
newStage.massTotal = KSP.Stages.massStart(currentStage);
newStage.deltaVStage = KSP.Stages.deltaVStage(currentStage, args.atm);
runningDeltaVTotal += newStage.deltaVStage
newStage.deltaVTotal = runningDeltaVTotal;
newStage.twr = KSP.Stages.twr(currentStage, args.atm, args.planet);
newStage.timeStage = KSP.Stages.timeStage(currentStage, args.atm);
runningTimeTotal += newStage.timeStage
newStage.timeTotal = runningTimeTotal;
newStage.others = KSP.Parts.countUnique(currentStage.others);
newStage.lfoEngines = KSP.Parts.countUnique(currentStage.lfoEngines);
newStage.lfoTanks = KSP.Parts.countUnique(currentStage.lfoTanks).reverse();
newStage.boosters = KSP.Parts.countUnique(currentStage.boosters);
newStage.decouplers = KSP.Parts.countUnique(currentStage.decouplers);
newStage.branches = KSP.Parts.countUnique(currentStage.branches);
result.stages.push(newStage);
currentStage = currentStage.next;
}
result.stages.reverse();
result.payloadFraction = result.stages[0].payload / result.mass;
}
return result;
}
function onSearchResult(staging) {
$scope.bestStagingsCount++;
staging = convertStaging(staging, $scope.bestStagingsArgs);
var bestStagings = $scope.bestStagings;
if (!staging) {
$scope.bestStagingsInvalid++;
} else if (staging.id === $scope.bestStagingsArgs.id) {
$scope.bestStagingsValid++;
if (bestStagings.length < $scope.maxStagings || staging.metric <= bestStagings[bestStagings.length-1].metric) {
var index = _.sortedIndex(bestStagings, staging, "metric");
if (!bestStagings[index] || staging.metric !== bestStagings[index].metric) {
bestStagings.splice(index, 0, staging);
if (bestStagings.length > $scope.maxStagings) {
bestStagings.pop();
}
}
}
} else {
$scope.bestStagingsCount--;
}
}
//methods
$scope.startSearch = function (args) {
args.interval = 500; //slow down the search when processing in the main thread
$scope.stopSearch = searchForOptimalStaging(args, function (staging) {
$scope.$apply(function () {
onSearchResult(staging);
});
});
};
$scope.stopSearch = function () {}; //overwritten by startSearch
$scope.getEnabledParts = function () {
var enabledParts = [];
var packs = $scope.packTree;
for (var x = 0, xl = packs.length; x < xl; ++x) {
if (packs[x].enabled) {
var types = packs[x].parts;
for (var y = 0, yl = types.length; y < yl; ++y) {
if (types[y].enabled) {
var parts = types[y].parts
for (var z = 0, zl = parts.length; z < zl; ++z) {
if (parts[z].enabled) enabledParts.push(parts[z]);
}
}
}
}
}
return enabledParts;
}
$scope.search = function () {
$scope.stop();
var args = {
id : Math.ceil(0xFFFFFFFF * Math.random()),
optimization : $scope.optimization,
optimization2 : (NEEDS_OPTIMIZATION2[$scope.optimization] ? document.getElementById("settingsOptimization2").value : null), //workaround for Angular bug //$scope.optimization2,
next : {payload:$scope.payload},
deltaV : $scope.deltaV,
planet : ($scope.planet ? $scope.planet : {gravity:$scope.gravity}),
minTWR : $scope.minTWR,
maxTWR : $scope.maxTWR,
minTime : $scope.minTime,
maxTime : $scope.maxTime,
maxMass : $scope.maxMass,
maxPartCount : $scope.maxPartCount,
atm : ($scope.atmosphere ? 1 : 0),
maxStacks : ($scope.lastStageSingle ? 1 : $scope.maxStacks),
cluster : $scope.cluster,
parallel : false,
asparagus : false,
decoupling : $scope.payloadDecoupler,
tankDiametersEqual : $scope.tankDiametersEqual,
tankDiametersEqualEngineDiameter : $scope.tankDiametersEqual && $scope.tankDiametersEqualEngineDiameter,
tankDiametersGreaterThenEngineDiameter : $scope.tankDiametersEqual && $scope.tankDiametersGreaterThenEngineDiameter,
gimbal : $scope.gimbal || undefined,
throttleable : $scope.throttleable || undefined,
maxStages : $scope.maxStages,
stagesMaxStacks : $scope.maxStacks,
stagesParallel : $scope.parallel || $scope.asparagus,
stagesAsparagus : $scope.asparagus,
stagesThrottleable : undefined,
parts : sortParts($scope.getEnabledParts(), $scope.optimization)
};
$scope.bestStagings = [];
$scope.bestStagingsCount = 0;
$scope.bestStagingsValid = 0;
$scope.bestStagingsInvalid = 0;
$scope.bestStagingsArgs = args;
var singleStage = findOptimalStage(args);
if (singleStage) {
singleStage.id = args.id;
onSearchResult(singleStage);
}
if (args.maxStages > 1) {
$scope.searching = true;
$scope.startSearch(args);
}
}
$scope.stop = function () {
$scope.stopSearch();
$scope.searching = false;
};
//event listeners
$scope.onOptimizationChange = function () {
if (NEEDS_OPTIMIZATION2[$scope.optimization]) {
if (!$scope.optimization2) $scope.optimization2 = "mass";
} else {
$scope.optimization2 = undefined;
}
};
$scope.onPlanetChange = function () {
$scope.gravity = $scope.planet.gravity;
};
$scope.onGravityChange = function () {
$scope.planet = null;
};
$scope.onMaxStagesChange = function () {
if ($scope.maxStages <= 1) {
$scope.asparagus = false;
}
};
$scope.onMaxStacksChange = function () {
if ($scope.maxStacks <= 1) {
$scope.cluster = false;
$scope.asparagus = false;
}
};
$scope.onAsparagusChange = function () {
if ($scope.asparagus) $scope.maxStages = Math.max($scope.maxStages, 2);
};
$scope.onTankDiametersEqualChange = function () {
if (!$scope.tankDiametersEqual) $scope.tankDiametersEqualEngineDiameter = false;
}
$scope.onPartListItemChange = function (partListItem) {
var parts = partListItem.parts;
if (parts) {
for (var x = 0, xl = parts.length; x < xl; ++x) {
var part = parts[x];
if (!$scope.initialization || !part.size || !isNaN(part.size)) {
part.enabled = partListItem.enabled;
$scope.onPartListItemChange(part);
}
}
}
if (partListItem.enabled) {
for (var x = 1, xl = arguments.length; x < xl; ++x) {
arguments[x].enabled = true;
}
}
};
//initialization
$scope.initialization = true;
$scope.packTree[0].enabled = true;
$scope.onPartListItemChange($scope.packTree[0]);
$scope.initialization = false;
//web worker initialization
var kspcalcWorkers;
if (typeof Worker !== "undefined") {
try {
kspcalcWorkers = [];
//spawn 4 web workers
for (var x = 0, xl = 4; x < xl; ++x) {
kspcalcWorkers[x] = new Worker("kspcalc.js");
kspcalcWorkers[x].addEventListener("message", function (evt) {
$scope.$apply(function () {
onSearchResult(evt.data);
});
});
}
$scope.startSearch = function (args) {
for (var x = 0, xl = kspcalcWorkers.length; x < xl; ++x) {
kspcalcWorkers[x].postMessage(args);
}
};
$scope.stopSearch = function () {
for (var x = 0, xl = kspcalcWorkers.length; x < xl; ++x) {
kspcalcWorkers[x].postMessage({cancel:true});
}
};
$scope.webworkersSupported = true;
} catch (e) {
console.error("Failed to create web workers", e);
kspcalcWorkers = null;
}
}
}
</script>
<datalist id="timeSuggestions">
<option value="10">10 Seconds</option>
<option value="30">30 Seconds</option>
<option value="60">1 Minute</option>
<option value="120">2 Minutes</option>
<option value="180">3 Minutes</option>
<option value="240">4 Minutes</option>
<option value="300">5 Minutes</option>
<option value="600">10 Minutes</option>
<option value="900">15 Minutes</option>
<option value="1800">30 Minutes</option>
</datalist>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>KSP Optimal Rocket Calculator <small>for Kerbal Space Program 1.2</small></h1>
</div>
<div ng-controller="SettingsController">
<form name="settings" class="row">
<div class="col-md-6">
<div class="arguments form-horizontal">
<div class="form-group">
<label for="settingsOptimization" class="control-label col-sm-5">Optimize For</label>
<div class="col-sm-7">
<div ng-class="{'input-group': optimization == 'partCount'}">
<select name="optimization" id="settingsOptimization" class="form-control" ng-model="optimization" ng-change="onOptimizationChange()">
<option value="mass">Mass</option>
<option value="cost">Cost</option>
<option value="partCount">Part Count</option>
</select>
<span class="input-group-addon" ng-if="NEEDS_OPTIMIZATION2[optimization]"> then </span>
<select name="optimization2" id="settingsOptimization2" class="form-control" ng-model="optimization2" ng-if="NEEDS_OPTIMIZATION2[optimization]">
<option value="mass">Mass</option>
<option value="cost">Cost</option>
<option value="deltaV">Delta-V</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="settingsPayload" class="control-label col-sm-5">Payload</label>
<div class="col-sm-7">
<div class="input-group" ng-class="{'has-error': !payload}">
<input type="number" name="payload" required="required" min="0" step="0.001" placeholder="0" id="settingsPayload" class="form-control" ng-model="payload"/>
<span class="input-group-addon mathml"><math><mi>t</mi></math></span>
</div>
</div>
</div>
<div class="form-group">
<label for="settingsDeltaV" class="control-label col-sm-5">Minimum Total Delta-V</label>
<div class="col-sm-7">
<div class="input-group" ng-class="{'has-error': !deltaV}">
<input type="number" name="deltaV" required="required" min="0" step="1" placeholder="0" id="settingsDeltaV" class="form-control" ng-model="deltaV"/>
<span class="input-group-addon mathml"><math><mi>m</mi><mo>/</mo><mi>s</mi></math></span>
</div>
</div>
</div>
<div class="form-group">
<label for="settingsPlanet" class="control-label col-sm-5">Local Gravity</label>
<div class="col-sm-7">
<div class="input-group">
<span class="input-group-addon"><select name="planet" id="settingsPlanet" class="form-control-minimal" ng-model="planet" ng-options="PLANET as PLANET.name for PLANET in PLANETS" ng-change="onPlanetChange()"></select></span>
<input type="number" name="gravity" min="0" step="0.001" id="settingsGravity" class="form-control" ng-model="gravity" ng-change="onGravityChange()"/>
<span class="input-group-addon mathml"><math><mi>m</mi><mo>/</mo><msup><mi>s</mi><mn>2</mn></msup></math></span>
</div>
</div>
</div>
<div class="form-group">
<label for="settingsMinTWR" class="control-label col-sm-5">Initial Thrust-to-Weight Ratio</label>
<div class="col-sm-7">
<div class="input-group">
<input type="number" name="minTWR" min="0" step="0.1" placeholder="0" id="settingsMinTWR" class="form-control" ng-model="minTWR"/>
<span class="input-group-addon"> to </span>
<input type="number" name="maxTWR" min="0" step="0.1" placeholder="Infinity" id="settingsMaxTWR" class="form-control" ng-model="maxTWR"/>
</div>
</div>
</div>
<div class="form-group">
<label for="settingsMaxTime" class="control-label col-sm-5">Stage Burn Time</label>
<div class="col-sm-7">
<div class="input-group">
<input type="number" name="minTime" min="0" step="0.1" placeholder="0" list="timeSuggestions" id="settingsMinTime" class="form-control" ng-model="minTime"/>
<span class="input-group-addon"> to </span>
<input type="number" name="maxTime" min="0" step="0.1" placeholder="Infinity" list="timeSuggestions" id="settingsMaxTime" class="form-control" ng-model="maxTime"/>
<span class="input-group-addon mathml"><math><mi>s</mi></math></span>
</div>
</div>
</div>
<div class="form-group" ng-hide="optimization == 'mass'">
<label for="settingsMaxMass" class="control-label col-sm-5">Maximum Total Mass</label>
<div class="col-sm-7">
<div class="input-group">
<input type="number" name="maxMass" min="{{payload}}" step="0.001" placeholder="Infinity" id="settingsMaxMass" class="form-control" ng-model="maxMass"/>
<span class="input-group-addon mathml"><math><mi>t</mi></math></span>
</div>
</div>
</div>
<div class="form-group" ng-hide="optimization == 'partCount'">
<label for="settingsMaxPartCount" class="control-label col-sm-5">Maximum Total Part Count</label>
<div class="col-sm-7">
<input type="number" name="maxPartCount" min="1" step="1" placeholder="Infinity" id="settingsMaxPartCount" class="form-control" ng-model="maxPartCount"/>
</div>
</div>
<div class="form-group">
<label for="settingsMaxStages" class="control-label col-sm-5">Maximum # of Stages</label>
<div class="col-sm-7">
<input type="number" name="maxStages" min="1" step="1" placeholder="1" id="settingsMaxStages" class="form-control" ng-model="maxStages" ng-change="onMaxStagesChange()"/>
</div>
</div>
<div class="form-group">
<label for="settingsMaxStacks" class="control-label col-sm-5">Maximum # of Stacks</label>
<div class="col-sm-7">
<input type="number" name="maxStacks" min="1" step="1" max="50" placeholder="1" id="settingsMaxStacks" class="form-control" ng-model="maxStacks" ng-change="onMaxStacksChange()"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-5">Staging Setup</label>
<div class="col-sm-7">
<div class="checkbox">
<label>
<input type="checkbox" name="cluster" id="settingsCluster" ng-model="cluster" ng-disabled="maxStacks <= 1"/>
Engine clustering
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="asparagus" id="settingsAsparagus" ng-model="asparagus" ng-disabled="maxStacks <= 1" ng-change="onAsparagusChange()"/>
Asparagus fuel routing
<a href="http://wiki.kerbalspaceprogram.com/wiki/Asparagus_staging" target="_blank" class="help">?</a>
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-5">Options</label>
<div class="col-sm-7">
<div class="checkbox">
<label>
<input type="checkbox" name="atmosphere" id="settingsAtmosphere" ng-model="atmosphere"/>
Use engine's atmospheric stats
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="payloadDecoupler" id="settingsPayloadDecoupler" ng-model="payloadDecoupler"/>
Add decoupler between payload
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="lastStageSingle" id="settingsLastStageSingle" ng-model="lastStageSingle"/>
Last stage must be a single stack
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="tankDiametersEqual" id="settingsTankDiametersEqual" ng-model="tankDiametersEqual" ng-change="onTankDiametersEqualChange()"/>
All tanks & stack decouplers in a stage must be the same diameter
</label>
<div class="checkbox">
<label>
<input type="checkbox" name="tankDiametersEqualEngineDiameter" id="settingsTankDiametersEqualEngineDiameter" ng-model="tankDiametersEqualEngineDiameter" ng-disabled="!tankDiametersEqual"/>
<span class="ellipsis">...</span> as the engines
</label>
<div class="checkbox">
<label>
<input type="checkbox" name="tankDiametersGreaterThenEngineDiameter" id="settingsTankDiametersGreaterThenEngineDiameter" ng-model="tankDiametersGreaterThenEngineDiameter" ng-disabled="!tankDiametersEqual || !tankDiametersEqualEngineDiameter"/>
<span class="ellipsis">...</span> or larger
</label>
</div>
</div>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="gimbal" id="settingsGimbal" ng-model="gimbal"/>
Each stage must have a gimbaling engine
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="throttleable" id="settingsThrottleable" ng-model="throttleable"/>
Last stage must have a throttleable engine
</label>
</div>
</div>
</div>
<div class="actions row">
<div class="col-sm-offset-5 col-sm-7">
<button class="btn btn-primary" ng-disabled="settings.$invalid" ng-click="search()">Search</button>
<p class="help-block warning" ng-if="!webworkersSupported">This browser does not support web workers, searching will be slow!</p>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<label>Available Parts</label>
<div class="availableParts partPacks partList well">
<div class="partPack partListItem checkbox" ng-repeat="pack in packTree">
<input type="checkbox" ng-model="pack.enabled" ng-change="onPartListItemChange(pack)"/><span class="packName">{{pack.name}}</span>
<div class="partTypes partList">
<div class="partType partListItem" ng-repeat="type in pack.parts">
<input type="checkbox" ng-model="type.enabled" ng-change="onPartListItemChange(type, pack)"/><span>{{type.name}}</span>
<div class="partItems partList">
<div class="partItem partListItem" ng-repeat="part in type.parts">
<input type="checkbox" ng-model="part.enabled" ng-change="onPartListItemChange(part, type, pack)"/><span>{{part.name}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<div class="donate">
<div class="alert alert-warning">
<h4>Find this tool useful? Like to see it continually supported?</h4>
<p>
I am a self-employed software developer who built this tool in my free time.
Unfortunately, I can't work on stuff like this all the time as I have to make money to eat and live.
With your support, I can continue working on this and other great tools for Kerbal Space Program that everyone can benefit from!
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value="6E5RDXCCFK2KC"/>
<p class="donate-line">
Every little bit helps. So please, consider donating to my cause:
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" class="btn" border="0" name="submit" alt="Donate via PayPal" style="vertical-align:middle;"/>
</p>
</form>
<p>Thanks!</p>
</div>
</div>
<div class="searchProgress alert alert-info text-center" ng-show="bestStagingsArgs">
<h2 ng-if="bestStagingsArgs.maxStages > 1">Found {{bestStagingsValid}} Valid Rocket Designs<small ng-if="bestStagingsInvalid"> (and {{bestStagingsCount}} Invalid)</small></h2>
<h2 ng-if="bestStagingsArgs.maxStages <= 1">Most Optimal Rocket Design Found!</h2>
<div class="actions pull-right">
<button class="btn btn-danger" ng-click="stop()" ng-hide="!searching || bestStagingsArgs.maxStages <= 1">Stop</button>
</div>
</div>
<div class="searchResults">
<details class="panel panel-default" ng-repeat="staging in bestStagings" ng-open="$first">
<summary class="panel-heading">
<div class="attempt panel-heading-pill">Attempt #{{staging.attempt}}</div>
<div class="stages panel-heading-pill nav-pills">Stages: {{staging.stages.length-1}}</div>
<div class="partCount panel-heading-pill nav-pills" ng-class="{strong: staging.optimization == 'partCount'}">Part Count: {{staging.partCount}}</div>
<div class="cost panel-heading-pill nav-pills" ng-class="{strong: staging.optimization == 'cost'}">Cost: {{staging.cost}}</div>
<div class="mass panel-heading-pill nav-pills" ng-class="{strong: staging.optimization == 'mass'}">Mass: {{staging.mass.toFixed(3)}} <abbr title="Payload Fraction">({{(staging.payloadFraction * 100).toPrecision(3)}}%)</abbr></div>
<div class="deltaV panel-heading-pill nav-pills">Delta-V: {{Math.round(staging.deltaV)}}</div>
<div class="time panel-heading-pill nav-pills">Time: {{staging.time.toFixed(1)}}</div>
</summary>
<table class="panel-table table">
<thead>
<tr>
<th class="stage">Stage</th>
<th class="parts">Part</th>
<th class="stageMultiplier">x</th>
<th class="cost">Cost</th>
<th class="mass">Mass (<math><mi>t</mi></math>)</th>
<th class="deltaV">Delta-V (<math><mi>m</mi><mo>/</mo><mi>s</mi></math>)</th>
<th class="twr">TWR</th>
<th class="time">Time (<math><mi>s</mi></math>)</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stage in staging.stages | orderBy:'-stage'">
<td class="stage">
<div class="stageNumber">{{$index}}</div>
<small ng-if="stage.asparagus">Asparagus</small>
</td>
<td class="parts partList">
<ol>
<li class="decouplers" ng-repeat="part in stage.decouplers">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
<li class="payload" ng-if="stage.payload > 0">Payload: {{stage.payload}}t</li>
<li class="others" ng-repeat="part in stage.others">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
<li class="lfoTanks" ng-repeat="part in stage.lfoTanks">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
<li class="branches" ng-repeat="part in stage.branches">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
<li class="lfoEngines" ng-repeat="part in stage.lfoEngines">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
<li class="boosters" ng-repeat="part in stage.boosters">{{part.name}}<span class="multiplier" ng-if="part.count > 1"> x{{part.count}}</span></li>
</ol>
</td>
<td class="stageMultiplier"><span ng-if="stage.multiplier > 1">x{{stage.multiplier}}</span></td>
<td class="cost">{{stage.costStage}} / {{stage.costTotal}}</td>
<td class="mass">{{stage.massStage.toFixed(3)}} / {{stage.massTotal.toFixed(3)}}</td>
<td class="deltaV">{{Math.round(stage.deltaVStage)}} / {{Math.round(stage.deltaVTotal)}}</td>
<td class="twr">{{stage.twr.toFixed(2)}}</td>
<td class="time">{{stage.timeStage.toFixed(1)}} / {{stage.timeTotal.toFixed(1)}}</td>
</tr>
</tbody>
</table>
</details>
</div>
</div>
<div class="page-footer">
<p class="text-center">© 2013 Gary Court - All rights reserved - Licensed under the <a href="LICENSE">BSD License</a> - <a href="CHANGELOG.md">Changelog</a></p>
</div>
</div>
</body>
</html>