-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFPplus.js
More file actions
735 lines (673 loc) · 28.3 KB
/
FPplus.js
File metadata and controls
735 lines (673 loc) · 28.3 KB
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
import { CompositeCost, ExponentialCost, FreeCost, LinearCost } from "../api/Costs";
import { Localization } from "../api/Localization";
import { BigNumber } from "../api/BigNumber";
import { theory, QuaternaryEntry } from "../api/Theory";
import { Utils } from "../api/Utils";
var id = "fractal_patterns_plus";
var name = "Fractal Patterns+";
var description =
"Mod of the official custom theory 'Fractal Patterns'.\n" +
"This mod allows you to experience post completion FP gameplay and reach divergence.\n" +
"To help you to reach divergence, new milestones were added. They speedup the theory by a factor of 3 but make s level cap.\n";
"Can you reach divergence and reach e20,000ρ? It might take you two years, but the journey and the goal are worth it."
var authors = "xlii (original FP developer)\nMathis S. (mod developer)";
var version = 7;
var releaseOrder = "6";
requiresGameVersion("1.4.33");
const e600 = BigNumber.from("1e600");
//const ee4 = BigNumber.from("ee4");
const ee6 = BigNumber.from("ee6");
const I32_MAX = 2**31-1;
var tauMultiplier = 4;
var currency = BigNumber.ZERO;
var quaternaryEntries;
var rhodot = BigNumber.ZERO;
let qdot = BigNumber.ZERO;
let rdot = BigNumber.ZERO;
var q = BigNumber.ONE;
var r = BigNumber.ONE;
var t_cumulative = BigNumber.ZERO;
var pubtime = 0;
var pubtime_actual = 0;
var A = BigNumber.ONE;
var tvar, c1, c2, q1, q2, r1, n1, s;
var fractalToggle;
var snexp, snboost, nboost, fractalTerm, sterm, expterm, speedupMs;
var autoremove_milestones;
var n = 1;
var prevN = 1;
var T_n = BigNumber.ONE;
var S_n = BigNumber.ONE;
var U_n = BigNumber.ONE;
var updateN_flag = true;
var adBoost = BigNumber.ONE;
var instant_rates = 0;
var instant_rates_actual = 0;
var stage = 1;
const speedup_points = [
2350, 2425, 2500, 2575, 2800,
3300, 3400, 3500, 3600, 3900,
4600, 4700, 4850, 4950, 5400,
6500, 6750];
const scaps = [
I32_MAX,
497, 494, 491, 488, 477,
465, 464, 463, 462, 461,
380, 378, 376, 360, 354,
352, 350
]
function formatNumber(number) {
if (number === BigNumber.ZERO) return "0";
if (number < 0.001) {
const l = number.log10().floor();
return `${number / BigNumber.TEN.pow(l)}\\text{e-${Math.abs(l)}}`;
}
return number.toString(3);
}
function formatRates(number) {
if (number >= 0.001 || number == 0) {
return number.toPrecision(5);
}
else {
return number.toExponential(4);
}
}
function formatRho(number) {
if (number >= ee6 || number < BigNumber.from(1e6)) {
return number.toString();
}
const log10 = number.log10().toNumber();
const exp = Math.floor(log10);
const dec = 10**(log10 - exp);
return `${dec.toPrecision(4)}e${exp}`;
}
function getTimeString(time) {
let mins = Math.floor(time / 60);
let secs = time - 60 * mins;
let hours = Math.floor(mins / 60);
mins -= hours * 60;
let days = Math.floor(hours / 24);
hours -= days * 24;
let years = Math.floor(days / 365);
days -= years * 365;
const days_f = days.toString().padStart(3, "0");
const hours_f = hours.toString().padStart(2, "0");
const mins_f = mins.toString().padStart(2, "0");
const secs_f = secs.toFixed(1).padStart(4, "0");
if (years > 0) {
return `${years}y ${days_f}d ${hours_f}h`;
}
else if (days > 0) {
return `${days}d ${hours_f}:${mins_f}`;
}
else {
return `${hours_f}:${mins_f}:${secs_f}`;
}
}
var init = () => {
currency = theory.createCurrency();
quaternaryEntries = [];
///////////////////
// Regular Upgrades
// tvar
{
let getDesc = (level) => "\\dot{t}=" + getTdot(level).toString(1);
tvar = theory.createUpgrade(0, currency, new ExponentialCost(1e4, Math.log2(1e4)));
tvar.getDescription = (_) => Utils.getMath(getDesc(tvar.level));
tvar.getInfo = (amount) => Utils.getMathTo(getDesc(tvar.level), getDesc(tvar.level + amount));
tvar.maxLevel = 4;
}
// c1
{
let getDesc = (level) => "c_1=" + getC1(level).toString(0);
c1 = theory.createUpgrade(1, currency, new FirstFreeCost(new ExponentialCost(10, Math.log2(1.4))));
c1.getDescription = (_) => Utils.getMath(getDesc(c1.level));
c1.getInfo = (amount) => Utils.getMathTo(getDesc(c1.level), getDesc(c1.level + amount));
}
// c2
{
let getDesc = (level) => "c_2=2^{" + level + "}";
let getInfo = (level) => "c_2=" + getC2(level).toString(0);
c2 = theory.createUpgrade(2, currency, new CompositeCost(15, new ExponentialCost(1e15, Math.log2(40)), new ExponentialCost(1e37, Math.log2(16.42))));
c2.getDescription = (_) => Utils.getMath(getDesc(c2.level));
c2.getInfo = (amount) => Utils.getMathTo(getInfo(c2.level), getInfo(c2.level + amount));
}
// q1
{
let getDesc = (level) => "q_1=" + formatNumber(getQ1(level));
let getInfo = (level) => "q_1=" + formatNumber(getQ1(level));
q1 = theory.createUpgrade(3, currency, new FirstFreeCost(new ExponentialCost(1e35, Math.log2(12))));
q1.getDescription = (_) => Utils.getMath(getDesc(q1.level));
q1.getInfo = (amount) => Utils.getMathTo(getInfo(q1.level), getInfo(q1.level + amount));
}
// q2
{
let getDesc = (level) => "q_2=2^{" + level + "}";
let getInfo = (level) => "q_2=" + getQ2(level).toString(0);
q2 = theory.createUpgrade(4, currency, new ExponentialCost(1e76, Math.log2(1e3)));
q2.getDescription = (_) => Utils.getMath(getDesc(q2.level));
q2.getInfo = (amount) => Utils.getMathTo(getInfo(q2.level), getInfo(q2.level + amount));
}
// r1
{
let getDesc = (level) => "r_1=" + formatNumber(getR1(level));
let getInfo = (level) => "r_1=" + formatNumber(getR1(level));
r1 = theory.createUpgrade(
5,
currency,
new CompositeCost(285, new FirstFreeCost(new ExponentialCost(1e80, Math.log2(25))), new FirstFreeCost(new ExponentialCost(BigNumber.from("1e480"), Math.log2(150))))
);
r1.getDescription = (_) => Utils.getMath(getDesc(r1.level));
r1.getInfo = (amount) => Utils.getMathTo(getInfo(r1.level), getInfo(r1.level + amount));
}
// n
{
let getDesc = (level) => "n=" + getN1(level).toString(0);
let getInfo = (level) => "n=" + getN1(level).toString(0);
n1 = theory.createUpgrade(6, currency, new ExponentialCost(1e4, Math.log2(3e6)));
n1.getDescription = (_) => Utils.getMath(getDesc(n1.level));
n1.getInfo = (amount) => Utils.getMathTo(getInfo(n1.level), getInfo(n1.level + amount));
n1.bought = (_) => (updateN_flag = true);
}
// s
{
let getDesc = (level) => "s=" + getS(level).toString(2);
let getInfo = (level) => "s=" + getS(level).toString(2);
s = theory.createUpgrade(9, currency, new ExponentialCost(BigNumber.from("1e730"), Math.log2(1e30)));
s.getDescription = (_) => Utils.getMath(getDesc(s.level));
s.getInfo = (amount) => Utils.getMathTo(getInfo(s.level), getInfo(s.level + amount));
s.bought = (_) => {
updateN_flag = true;
updateAvailability();
};
}
/////////////////////
// Permanent Upgrades
theory.createPublicationUpgrade(0, currency, 0);
theory.createBuyAllUpgrade(1, currency, 0);
theory.createAutoBuyerUpgrade(2, currency, 0);
{
autoremove_milestones = theory.createPermanentUpgrade(3, currency, new FreeCost);
autoremove_milestones.getDescription = (_) => `Autoremove speedup milestones: ${autoremove_milestones.level ? 'ON' : 'OFF'}`;
autoremove_milestones.getInfo = (_) => `Automatically remove speedup milestones if the next $s$ after the cap is affordable`;
autoremove_milestones.boughtOrRefunded = (_) => autoremove_milestones.level %= 2;
}
// Fractal Toggle
{
fractalToggle = theory.createPermanentUpgrade(4, currency, new FreeCost());
fractalToggle.getDescription = (_) => fractalToggle.level > 0 ? "Disable background" : "Enable background";
fractalToggle.getInfo = (_) => "Toggles the display of fractal background";
fractalToggle.boughtOrRefunded = (_) => {
fractalToggle.level = fractalToggle.level & 1;
backgroundTime = 0;
backgroundIndex = backgroundImages.length - 1;
backgroundInitialized = false;
backgroundImages[0].opacity = backgroundImages[1].opacity = backgroundImages[2].opacity = 0;
}
}
///////////////////////
//// Milestone Upgrades
theory.setMilestoneCost(new CustomCost((total) => BigNumber.from(tauMultiplier*getMilCustomCost(total))));
function getMilCustomCost(lvl) {
const unlocks = [Math.log10(5e22), 95, 175, 300, 385, 420, 550, 600, 700, 1500].concat(speedup_points);
return unlocks[Math.min(lvl, unlocks.length - 1)] * 0.075;
}
{
fractalTerm = theory.createMilestoneUpgrade(0, 2);
fractalTerm.getDescription = (_) => {
if (fractalTerm.level === 0) {
return "Add the Ulam-Warburton fractal";
}
return "Add the Sierpinski Triangle fractal";
};
fractalTerm.getInfo = (_) => {
if (fractalTerm.level === 0) {
return "Add the Ulam-Warburton fractal";
}
return "Add the Sierpinski Triangle fractal";
};
fractalTerm.boughtOrRefunded = (_) => {
theory.invalidatePrimaryEquation();
theory.invalidateTertiaryEquation();
updateAvailability();
quaternaryEntries = [];
};
fractalTerm.canBeRefunded = () => nboost.level === 0;
}
{
nboost = theory.createMilestoneUpgrade(2, 2);
nboost.getDescription = (_) => "Improve n variable scaling";
nboost.getInfo = (_) => "Improve n variable scaling";
nboost.boughtOrRefunded = (_) => {
theory.invalidatePrimaryEquation();
theory.invalidateSecondaryEquation();
theory.invalidateTertiaryEquation();
updateAvailability();
updateN_flag = true;
};
nboost.canBeRefunded = (_) => snexp.level === 0;
}
{
snexp = theory.createMilestoneUpgrade(1, 3);
snexp.description = Localization.getUpgradeIncCustomExpDesc("S_n", "0.6");
snexp.info = Localization.getUpgradeIncCustomExpInfo("S_n", "0.6");
snexp.boughtOrRefunded = (_) => {
updateAvailability();
theory.invalidatePrimaryEquation();
};
snexp.canBeRefunded = () => snboost.level === 0;
}
{
snboost = theory.createMilestoneUpgrade(3, 1);
snboost.getDescription = (_) => "$S_n$ returns total amount of triangles";
snboost.getInfo = (_) => "Count all triangles in the sierpinsky triangle";
snboost.boughtOrRefunded = (_) => theory.invalidatePrimaryEquation();
snboost.boughtOrRefunded = (_) => {
S_n = S(Math.floor(Math.sqrt(n)));
theory.invalidatePrimaryEquation();
updateAvailability();
};
snboost.canBeRefunded = (_) => sterm.level === 0;
}
{
sterm = theory.createMilestoneUpgrade(4, 1);
sterm.getDescription = () => "$\\text{Add the term }s\\;\\;\\&\\;\\downarrow T_n\\text{exponent by 2}$";
sterm.getInfo = () => "$\\text{Add the term }s\\;\\;\\&\\;\\downarrow T_n\\text{exponent by 2}$";
sterm.boughtOrRefunded = (_) => {
updateAvailability();
theory.invalidatePrimaryEquation();
};
sterm.canBeRefunded = (_) => expterm.level === 0;
}
{
expterm = theory.createMilestoneUpgrade(5, 1);
expterm.getDescription = () => "$\\text{Improve } \\dot{r} \\text{ equation}$";
expterm.getInfo = () => `$\\dot{r} = r_1(T_nU_n)^{\\log(\\sqrt{2U_n})}S_{\\lfloor \\sqrt{n} \\rfloor}^{${snexp.level > 0 ? getsnexp(snexp.level).toString(1) : ""}}$`;
expterm.boughtOrRefunded = (_) => {
updateAvailability();
theory.invalidatePrimaryEquation();
};
}
{
speedupMs = theory.createMilestoneUpgrade(6, 17);
speedupMs.getDescription = () =>
`Speedup the theory by $\\times 3$ but decreases $s$ level cap to $${scaps[Math.min(speedupMs.level + 1, 17)]}$`
speedupMs.boughtOrRefunded = (_) => {
updateAvailability();
theory.invalidatePrimaryEquation();
theory.invalidateSecondaryEquation();
}
}
updateAvailability();
};
function T(n) {
if (n === 0) return 0;
if (n > 100000) return BigNumber.from(U_n / 2); // this is to ensure statement limit doesn't screw us up
let log2N = Math.log2(n);
if (log2N % 1 === 0) return (2 ** (2 * log2N + 1) + 1) / 3;
let i = n - 2 ** Math.floor(log2N);
return (2 ** (2 * Math.floor(log2N) + 1) + 1) / 3 + 2 * T(i) + T(i + 1) - 1;
}
// U(n) calculation helper
// V(n) calculation is O(log n)
// U(n) can be found applying an affine transformation to V(n)
function V(n) {
if (n === 0) return 0;
const log2N = Math.log2(n);
if (log2N % 1 === 0) return 2 ** (2 * log2N);
const i = n - 2 ** Math.floor(log2N);
return 2 ** (2 * Math.floor(log2N)) + 3 * this.V(i);
}
function U(n) {
return (4/3)*V(n) - (1/3);
}
function S(n) {
if (n === 0) return BigNumber.ZERO;
if (snboost.level === 0) return BigNumber.THREE.pow(n - 1);
return BigNumber.from(1 / 3) * (BigNumber.TWO * BigNumber.THREE.pow(n) - BigNumber.THREE);
}
function approx(n) {
n++;
return BigNumber.from(1 / 6) * (BigNumber.TWO.pow(2 * n) + BigNumber.TWO);
}
function updateN() {
U_n = BigNumber.from(U(n));
T_n = BigNumber.from(T(n));
S_n = S(Math.floor(Math.sqrt(n)));
}
var updateAvailability = () => {
q1.isAvailable = fractalTerm.level > 0;
q2.isAvailable = fractalTerm.level > 0;
r1.isAvailable = fractalTerm.level > 1;
s.isAvailable = sterm.level > 0;
snexp.isAvailable = nboost.level === 2;
nboost.isAvailable = fractalTerm.level === 2;
snboost.isAvailable = snexp.level === 3;
sterm.isAvailable = snboost.level === 1;
expterm.isAvailable = sterm.level === 1;
speedupMs.isAvailable = expterm.level === 1;
s.maxLevel = scaps[speedupMs.level];
let max_speedup_milestones = 17;
while (s.level > scaps[max_speedup_milestones]) max_speedup_milestones--;
speedupMs.level = Math.min(speedupMs.level, max_speedup_milestones);
speedupMs.maxLevel = max_speedup_milestones;
speedupMs.isAvailable = speedupMs.isAvailable && speedupMs.maxLevel > 0;
};
var tick = (elapsedTime, multiplier) => {
const speedup = getspeedup(speedupMs.level);
multiplier = BigNumber.from(multiplier) * speedup;
const dt = BigNumber.from(elapsedTime * multiplier);
const bonus = theory.publicationMultiplier;
adBoost = multiplier;
if (c1.level === 0) return;
if (updateN_flag) {
prevN = n;
//n is clamped at 20000 because of computation reasons. takes ~40k days to reach (XLII)
// You need better algorithms :P
n = getN1(n1.level);
updateN();
updateN_flag = false;
theory.invalidateTertiaryEquation();
}
t_cumulative += getTdot(tvar.level) * dt;
pubtime += elapsedTime;
pubtime_actual += elapsedTime * speedup.toNumber();
A = fractalTerm.level > 0 ? approx(q2.level) : 1;
qdot = (getQ1(q1.level) * A * U_n.pow(7 + (sterm.level > 0 ? getS(s.level).toNumber() : 0))) / BigNumber.THOUSAND;
q += fractalTerm.level > 0 ? qdot * dt : 0;
if (expterm.level === 0) rdot = getR1(r1.level) * (T_n * U_n).pow(BigNumber.from(Math.log10(n))) * S_n ** getsnexp(snexp.level);
else rdot = getR1(r1.level) * (T_n * U_n).pow(Math.log10(U_n * 2) / 2) * S_n.pow(getsnexp(snexp.level));
r += fractalTerm.level > 1 ? rdot * dt : 0;
rhodot = bonus * getC1(c1.level) * getC2(c2.level) * T_n.pow(7 + (sterm.level > 0 ? getS(s.level).toNumber() - 2 : 0)) * t_cumulative;
rhodot *= fractalTerm.level > 0 ? q : BigNumber.ONE;
rhodot *= fractalTerm.level > 1 ? r : BigNumber.ONE;
const prev_tau = getTau();
currency.value += rhodot * dt;
const new_tau = getTau();
instant_rates = ((new_tau.log10() - prev_tau.log10()) / (elapsedTime / 3600)).toNumber();
instant_rates_actual = ((new_tau.log10() - prev_tau.log10()) / (elapsedTime * speedup.toNumber() / 3600)).toNumber();
if (autoremove_milestones.level == 1
&& speedupMs.level > 0
&& s.level == scaps[speedupMs.level]
&& currency.value * BigNumber.from(1.001) > s.cost.getCost(s.level + 1)) {
speedupMs.level--;
updateAvailability();
}
if (stage >= 2) theory.invalidatePrimaryEquation();
if (stage >= 2) theory.invalidateSecondaryEquation();
theory.invalidateTertiaryEquation();
theory.invalidateQuaternaryValues();
if (!game.isCalculatingOfflineProgress && fractalToggle.level == 1) {
updateBackgroundImage(elapsedTime);
}
};
var postPublish = () => {
q = BigNumber.ONE;
r = BigNumber.ONE;
rhodot = BigNumber.ZERO;
qdot = BigNumber.ZERO;
rdot = BigNumber.ZERO;
t_cumulative = BigNumber.ZERO;
pubtime = 0;
pubtime_actual = 0;
prevN = 1;
n = 1;
U_n = BigNumber.ONE;
T_n = BigNumber.ONE;
S_n = BigNumber.ONE;
//maxUDN = BigNumber.ONE; // WTF is this
updateN_flag = true;
A = BigNumber.ONE;
theory.invalidateTertiaryEquation();
theory.invalidateQuaternaryValues();
updateAvailability();
};
var getInternalState = () => `${q} ${r} ${t_cumulative} ${pubtime} ${pubtime_actual}`;
var setInternalState = (state) => {
let values = state.split(" ");
if (values.length > 0) q = parseBigNumber(values[0]);
if (values.length > 1) r = parseBigNumber(values[1]);
if (values.length > 2) t_cumulative = parseBigNumber(values[2]);
if (values.length > 3) pubtime = parseFloat(values[3]);
if (values.length > 4) pubtime_actual = parseFloat(values[4]);
updateN_flag = true;
};
var getPrimaryEquation = () => {
switch (stage) {
case 0: {
theory.primaryEquationHeight = 150;
theory.primaryEquationScale = 0.65;
let result = "T_{2^k+i}=\\begin{cases}\\frac{2^{2k+1}+1}{3}, & \\text{if } i = 0, \\\\ T_{2^k}+2T_i + T_{i+1}-1, & \\text{if } 1 \\leq i < 2^k \\end{cases}\\\\";
if (fractalTerm.level > 0) {
result += "u_0 = 0,\\ u_1 = 1,\\ \\dots,\\ u_n=4(3^{w_{n-1}-1})\\\\";
result += "w_n = n-\\sum_{k=1}^{\\infty}\\left\\lfloor\\frac{n}{2^k}\\right\\rfloor \\\\";
result += "U_n = \\sum_{i=0}^n u_i";
}
if (fractalTerm.level > 1) result += snboost.level === 0 ? ", \\qquad S_n = 3^{n-1}" : ", \\qquad S_n = 2(3^{n-1}) - 1";
return result;
}
case 1: {
theory.primaryEquationHeight = fractalTerm.level === 0 ? 60 : 110;
theory.primaryEquationScale = fractalTerm.level === 0 ? 1.2 : 0.97;
let result = `\\dot{\\rho} = c_1c_2`;
if (fractalTerm.level > 0) result += "q" + (fractalTerm.level > 1 ? "r" : "");
result += "t";
result += `T_n^{${7 - (sterm.level === 0 ? 0 : 2) + (sterm.level > 0 ? "+s" : "")}}`;
if (fractalTerm.level > 0) result += `\\\\\\\\ \\dot{q} = q_1AU_n^{7${sterm.level > 0 ? "+s" : ""}}/1000`;
if (fractalTerm.level > 1) {
if (expterm.level === 0) result += `\\\\\\\\ \\dot{r} = r_1(T_nU_n)^{\\log(n)}S_{\\lfloor \\sqrt{n} \\rfloor}^{${snexp.level > 0 ? getsnexp(snexp.level).toString(1) : ""}}`;
else result += `\\\\\\\\ \\dot{r} = r_1(T_nU_n)^{\\log(\\sqrt{2U_n})}S_{\\lfloor \\sqrt{n} \\rfloor}`;
}
return result;
}
case 2: {
theory.primaryEquationHeight = 65;
theory.primaryEquationScale = 0.9;
let result = ``;
result += `\\text{Current speed multiplier:} ${getspeedup(speedupMs.level)}\\\\`;
result += `\\text{Publication time: ${getTimeString(pubtime)}} \\\\`;
result += `\\text{Publication time (actual): ${getTimeString(pubtime_actual)}}`;
return result;
}
case 3: {
theory.primaryEquationHeight = 100;
theory.primaryEquationScale = 0.8;
let result = ``;
result += `\\rho = ${formatRho(currency.value)}\\\\`;
result += `\\dot{\\rho} = ${formatRho(rhodot * adBoost)}\\\\`;
result += `\\max{\\rho} = ${formatRho(getCurrencyFromTau(theory.tau)[0])}\\\\`;
result += `q = ${formatRho(q)}\\\\`;
result += `r = ${formatRho(r)}\\\\`;
return result;
}
}
return "";
};
var getSecondaryEquation = () => {
if (stage === 0) return "";
switch (stage) {
case 0: return "";
case 1: {
theory.secondaryEquationHeight = 50;
theory.secondaryEquationScale = 1;
let result = "\\begin{matrix}";
if (fractalTerm.level > 0) result += `A = (2-U_{q_2}/T_{q_2})^{-1} \\qquad `;
result += "\\\\ {}\\end{matrix}";
return result;
}
case 2: {
if (theory.tauPublished < BigNumber.ONE) return "";
theory.secondaryEquationHeight = 120;
theory.secondaryEquationScale = 0.95;
let result = "";
const dws = `\\,\\,`;
const th_cumulative = formatRates(((theory.tau.log10() - theory.tauPublished.log10()) / (pubtime / 3600)).toNumber());
const th_cumulative_actual = formatRates(((theory.tau.log10() - theory.tauPublished.log10()) / (pubtime_actual / 3600)).toNumber());
const rates_str = `\\tau/\\text{hr}${dws}\\text{rates}`;
result += `\\text{Cumulative}${dws}${rates_str}:\\\\`;
result += `\\text{Current:}${th_cumulative}\\\\`;
result += `\\text{Actual:}${th_cumulative_actual}\\\\`;
result += `\\text{Instant}${dws}${rates_str}:\\\\`;
result += `\\text{Current:}${formatRates(instant_rates)}\\\\`;
result += `\\text{Actual:}${formatRates(instant_rates_actual)}\\\\`;
return result;
}
case 3: {
theory.secondaryEquationHeight = 120;
theory.secondaryEquationScale = 0.95;
let result = ``;
const formatCost = (upg, cost) => `${upg}\\,\\,\\text{cost}\\,=${formatRho(cost)}\\\\`;
const getCost = (upg) => upg.cost.getCost(upg.level);
result += formatCost("c_1", getCost(c1));
result += formatCost("c_2", getCost(c2));
result += formatCost("q_1", getCost(q1));
result += formatCost("q_2", getCost(q2));
result += formatCost("r_1", getCost(r1));
result += formatCost("n", getCost(n1));
result += formatCost("s", getCost(s));
return result;
}
}
return "";
};
var getTertiaryEquation = () => {
let result = "\\begin{matrix}";
if (stage === 0) {
result += "T_n=" + T_n.toString(0);
if (fractalTerm.level > 0) result += ",&U_n=" + U_n.toString(0);
if (fractalTerm.level > 1) result += "\\\\\\\\ S_{\\lfloor \\sqrt{n} \\rfloor}=" + S_n.toString(0);
} else {
result += theory.latexSymbol + "=\\max\\rho^{0.3}";
}
result += "\\\\ {}\\end{matrix}";
return result;
};
var getQuaternaryEntries = () => {
// log(JSON.stringify(quaternaryEntries))
if (stage >= 2) return quaternaryEntries;
if (quaternaryEntries.length == 0) {
quaternaryEntries.push(new QuaternaryEntry(null, ''));
quaternaryEntries.push(new QuaternaryEntry("n", null));
if (stage === 0) {
if (fractalTerm.level > 0) quaternaryEntries.push(new QuaternaryEntry("\\dot{q}_{{}\\,}", null));
if (fractalTerm.level > 1) quaternaryEntries.push(new QuaternaryEntry("\\dot{r}_{{}\\,}", null));
quaternaryEntries.push(new QuaternaryEntry("\\dot{\\rho}_{{}\\,}", null));
} else {
quaternaryEntries.push(new QuaternaryEntry("t_{{}\\,}", null));
if (fractalTerm.level > 0) quaternaryEntries.push(new QuaternaryEntry("q", null));
if (fractalTerm.level > 1) quaternaryEntries.push(new QuaternaryEntry("r", null));
if (fractalTerm.level > 0) quaternaryEntries.push(new QuaternaryEntry("A_{{}\\,}", null));
}
quaternaryEntries.push(new QuaternaryEntry(null, ''));
}
quaternaryEntries[1].value = BigNumber.from(n).toString(0);
if (stage === 0) {
if (fractalTerm.level > 0) quaternaryEntries[2].value = (adBoost * qdot).toString(3);
if (fractalTerm.level > 1) quaternaryEntries[3].value = (adBoost * rdot).toString(3);
quaternaryEntries[fractalTerm.level + 2].value = (adBoost * rhodot).toString(3, 5);
} else {
quaternaryEntries[2].value = t_cumulative.toString(2);
if (fractalTerm.level > 0) quaternaryEntries[3].value = q.toString(2);
if (fractalTerm.level > 1) quaternaryEntries[4].value = r.toString(2);
if (fractalTerm.level > 0) quaternaryEntries[fractalTerm.level > 1 ? 5 : 4].value = A.toString(2);
}
return quaternaryEntries;
};
var canGoToPreviousStage = () => stage > 0;
var goToPreviousStage = () => {
stage--;
theory.invalidatePrimaryEquation();
theory.invalidateSecondaryEquation();
theory.invalidateTertiaryEquation();
quaternaryEntries = [];
theory.invalidateQuaternaryValues();
};
var canGoToNextStage = () => stage < 3;
var goToNextStage = () => {
stage++;
theory.invalidatePrimaryEquation();
theory.invalidateSecondaryEquation();
theory.invalidateTertiaryEquation();
quaternaryEntries = [];
theory.invalidateQuaternaryValues();
};
var lastTheme = null;
var backgroundImages = [ui.createImage({scale: 0.75, opacity: 0}) , ui.createImage({scale: 0.75, opacity: 0}) , ui.createImage({scale: 0.75, opacity: 0})];
var backgroundIndex = backgroundImages.length - 1;
var backgroundTime = 0;
var backgroundDisplayTime = 10;
var backgroundTransitionTime = 2;
var backgroundInitialized = false;
var fadeBackground = (image, opacity) => {
if (image.opacity != opacity)
image.fadeTo(opacity, backgroundTransitionTime * 1000, Easing.LINEAR);
}
var updateBackgroundImage = (elapsedTime) => {
if (lastTheme != game.settings.theme) {
if (game.settings.theme == Theme.LIGHT)
backgroundImages[0].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternToothpickSequenceLight.png");
else
backgroundImages[0].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternToothpickSequence.png");
if (game.settings.theme == Theme.LIGHT)
backgroundImages[1].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternUlamWarburtonLight.png");
else
backgroundImages[1].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternUlamWarburton.png");
if (game.settings.theme == Theme.LIGHT)
backgroundImages[2].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternSierpinskiTriangleLight.png");
else
backgroundImages[2].source = ImageSource.fromUri("https://raw.githubusercontent.com/conicgames/custom-theories/refs/heads/main/assets/FractalPatternSierpinskiTriangle.png");
lastTheme = game.settings.theme;
}
backgroundTime += elapsedTime;
var nextIndex = null;
if (backgroundIndex > fractalTerm.length || !backgroundInitialized && backgroundTime > 2)
nextIndex = 0;
if (backgroundTime > backgroundDisplayTime)
nextIndex = (backgroundIndex + 1) % Math.min(fractalTerm.level + 1, backgroundImages.length);
if (nextIndex != null) {
if (backgroundIndex != nextIndex)
fadeBackground(backgroundImages[backgroundIndex], 0);
backgroundIndex = nextIndex;
fadeBackground(backgroundImages[backgroundIndex], 1);
backgroundTime = 0;
backgroundInitialized = true;
}
}
var getEquationUnderlay = () => {
return ui.createGrid({
isVisible: () => fractalToggle.level == 1,
children: backgroundImages
});
}
var getPublicationMultiplier = (tau) => (tau.pow(1.324/tauMultiplier) * BigNumber.FIVE).max(BigNumber.ONE);
var getPublicationMultiplierFormula = (symbol) => "5" + symbol + "^{0.331}";
var getTau = () => currency.value.pow(0.075*tauMultiplier).max(e600)
var getCurrencyFromTau = (tau) => [tau.max(BigNumber.ONE).pow(1 / (0.075*tauMultiplier)), currency.symbol];
var get2DGraphValue = () => currency.value.sign * (BigNumber.ONE + currency.value.abs()).log10().toNumber();
let stepwiseSum = (level, base, length) => {
if (level <= length) return level;
level -= length;
let cycles = Math.floor(level / length);
let mod = level - cycles * length;
return base * (cycles + 1) * ((length * cycles) / 2 + mod) + length + level;
};
var getTdot = (level) => BigNumber.from(0.2 + level / 5);
var getC1 = (level) => Utils.getStepwisePowerSum(level, 150, 100, 0);
var getC2 = (level) => BigNumber.TWO.pow(level);
var getQ1 = (level) => (level === 0 ? BigNumber.ZERO : Utils.getStepwisePowerSum(level, 10, 10, 0) / BigNumber.from(1 + 1000 / level ** 1.5));
var getQ2 = (level) => BigNumber.TWO.pow(level);
var getR1 = (level) => (level === 0 ? BigNumber.ZERO : Utils.getStepwisePowerSum(level, 2, 5, 0) / BigNumber.from(1 + 1e9 / level ** 4));
var getN1 = (level) => {
const term2 = nboost.level > 0 ? Math.floor(stepwiseSum(Math.max(0, level - 30), 1, 35) * 2) : 0;
const term3 = nboost.level > 1 ? Math.floor(stepwiseSum(Math.max(0, level - 69), 1, 30) * 2.4) : 0;
return BigNumber.from(1 + stepwiseSum(level, 1, 40) + term2 + term3);
};
var getS = (level) => {
let cutoffs = [32, 39];
if (level < cutoffs[0]) return BigNumber.from(1 + level * 0.15);
if (level < cutoffs[1]) return BigNumber.from(getS(cutoffs[0] - 1) + 0.15 + (level - cutoffs[0]) * 0.2);
return BigNumber.from(getS(cutoffs[1] - 1) + 0.2 + (level - cutoffs[1]) * 0.15);
};
var getsnexp = (level) => BigNumber.from(1 + level * 0.6);
var getspeedup = (level) => BigNumber.THREE.pow(level);
init();