-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOriginal.java
More file actions
96 lines (82 loc) · 2.72 KB
/
Copy pathOriginal.java
File metadata and controls
96 lines (82 loc) · 2.72 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
import java.util.List;
import java.util.ArrayList;
System.out.println("Test");
public class Main
{
public static void main(String[] args)
{
Rack rack = new Rack(new ArrayList<>() {{
// 3 Crystalprocessor Mainframes and 1 Advanced Heat Vent as example
add(new Rack.RackComponent(18, -.35f));
add(new Rack.RackComponent(18, -.35f));
add(new Rack.RackComponent(18, -.35f));
add(new Rack.RackComponent(-1, 80f));
}},
// Overclock (=1 if not overclocked)
1.0f,
// Overvolt (=1 if not overvolted)
1.0f
);
int oldHeat = 0, newHeat = 10000;
while (Math.abs(newHeat - oldHeat) > 0)
{
oldHeat = newHeat;
rack.getComputation();
rack.onPostTick();
newHeat = rack.heat;
}
System.out.println("Final heat approx: " + newHeat);
}
private static class Rack
{
public int heat = 0;
List<RackComponent> components;
float overclock = 1;
float overvolt = 1;
public Rack(List<RackComponent> components, float overclock, float overvolt)
{
this.components = components;
this.overclock = overclock;
this.overvolt = overvolt;
}
public void onPostTick()
{
if (heat > 0)
{
float heatC = 0f;
for (RackComponent comp : components)
{
if (comp.heat < 0) {
heatC += comp.heat * (heat / 10000f);
}
heat += Math.max(-heat, Math.ceil(heatC));
}
heat -= Math.max(heat / 1000, 1);
}
else if (heat < 0)
{
heat -= Math.min(heat / 1000, -1);
}
}
public void getComputation()
{
float rackHeat = 0f;
for (RackComponent comp : components)
{
if (heat >= 0)
rackHeat += (1f + comp.heatCoeff * heat / 10000f) * (comp.heat > 0 ? comp.heat * overvolt * overclock * overclock : comp.heat);
}
heat += Math.ceil(rackHeat);
}
private static class RackComponent
{
public int heat;
public float heatCoeff;
public RackComponent(int initialHeat, float heatCoeff)
{
heat = initialHeat;
this.heatCoeff = heatCoeff;
}
}
}
}