@@ -36,7 +36,7 @@ def __init__(self, fit):
3636 self .hgm = fit .ship .getModifiedItemAttr ("heatGenerationMultiplier" )
3737 self .harm = self .calcHeatAbsorbtionRateModifier ()
3838 self .slotfactor = self .calcSlotFactor ()
39- self .simTime = 120
39+ self .simTime = 600
4040
4141 def getSlotPos (self , mod ): # get rack position of mod, 0-7
4242 rack = []
@@ -57,65 +57,17 @@ def calcHeatAbsorbtionRateModifier(self):
5757
5858 return harm
5959
60- """
61- HANGAR.ShipInfoThermodynamics.prototype.getHARM = function() {
62- var harm = [0,0,0];
63- var rack = ["hs", "ms", "ls"];
64-
65- for(var i = 0; i < rack.length; i++) {
66-
67- for(var j = 1; j <= 8; j++) {
68- // if slot and slot is overheated
69- if(this.shipinfo.ship.slots[rack[i]+j] && this.fitwindow.slots[rack[i]+j].find(" .sloticon").hasClass("heat") ) {
70- harm[i] += this.shipinfo.ship.slots[rack[i]+j].heatAbsorbtionRateModifier;
71- }
72- }
73- }
74-
75- return harm;
76- };
77- """
78-
7960 def calcSlotFactor (self ):
8061 slots = self .fit .ship .getModifiedItemAttr ("hiSlots" ) + self .fit .ship .getModifiedItemAttr ("medSlots" ) + self .fit .ship .getModifiedItemAttr ("lowSlots" )
8162 empty = self .fit .getSlotsFree (3 ) + self .fit .getSlotsFree (2 ) + self .fit .getSlotsFree (1 ) # FittingSlot.HIGH doesn"t work here?
8263 rigslots = self .fit .getNumSlots (4 )
8364
84- return (slots - empty ) / (slots + rigslots )
85-
86- """
87- HANGAR.ShipInfoThermodynamics.prototype.getSlotFactor = function() {
88- var slots = 0;
89- var emptyslots = 0;
90- for(var i = 1; i <= 8; i++) {
91-
92- var hs = this.fitwindow.slots["hs"+i];
93- var ms = this.fitwindow.slots["ms"+i];
94- var ls = this.fitwindow.slots["ls"+i];
95-
96- if(hs.hasClass("highslot") ) {
97- slots++;
98- if(!hs.hasClass("occupied") || hs.hasClass("offline") ) {
99- emptyslots++;
100- }
101- }
102- if(ms.hasClass("midslot") ) {
103- slots++;
104- if(!ms.hasClass("occupied") || ms.hasClass("offline") ) {
105- emptyslots++;
106- }
107- }
108- if(ls.hasClass("lowslot") ) {
109- slots++;
110- if(!ls.hasClass("occupied") || ls.hasClass("offline") ) {
111- emptyslots++;
112- }
113- }
114- }
115-
116- return (slots-emptyslots)/(slots + this.shipinfo.ship.data.rigSlots);
117- };
118- """
65+ offline = 0
66+ for mod in self .fit .modules :
67+ if (mod .state == FittingModuleState .OFFLINE and mod .slot in [1 , 2 , 3 ]): # only count offline low, med, hi mods
68+ offline += 1
69+
70+ return (slots - empty - offline ) / (slots + rigslots )
11971
12072 def calcDamageProbability (self , mod , t ): # get chance the module is damaged when overheated at time t
12173 keys = ["" , "heatAttenuationLow" , "heatAttenuationMed" , "heatAttenuationHi" ]
@@ -141,41 +93,6 @@ def calcDamageProbability(self, mod, t): # get chance the module is damaged when
14193
14294 return res
14395
144- """
145- HANGAR.ShipInfoThermodynamics.prototype.getDamageProb = function(slot, t) {
146- var rack = slot[0] == "h" ? "hs" : slot[0] == "m" ? "ms" : "ls";
147- var harmNdx = rack === "hs" ? 0 : rack === "ms" ? 1 : 2;
148- var att = rack == "hs" ? this.shipinfo.ship.data.heatAttenuationHi :
149- rack == "ms" ? this.shipinfo.ship.data.heatAttenuationMed :
150- this.shipinfo.ship.data.heatAttenuationLow ?
151- this.shipinfo.ship.data.heatAttenuationLow : 0.25;
152-
153- var slotpos = parseInt( slot.substr(2) );
154- var rackheat = 1 + -Math.pow(Math.E, (-t * this.hgm * this.harm[harmNdx]));
155-
156- var prob = [];
157- for(var i = 1; i <= 8; i++) {
158- if(rack+i == slot) continue;
159- if(this.shipinfo.ship.slots[ rack+i ] && this.shipinfo.ship.slots[ rack+i ].state === "overload"){
160- var pos = Math.abs(i - slotpos);
161- prob.push( Math.pow(att, pos)*this.slotfactor*rackheat );
162- }
163- }
164-
165- var p = 1;
166- for(var i = 0; i < prob.length; i++) {
167- p *= (1-prob[i]);
168- }
169-
170- var selfprob = this.slotfactor * rackheat;
171- if(p === 1) {
172- return selfprob;
173- } else {
174- return 1 - p*(1-selfprob);
175- }
176- };
177- """
178-
17996 def calcBurnCycles (self , mod ): # estimates the number of cycles a module will OH before it burns out
18097 speed = mod .getModifiedItemAttr ("speed" )
18198 duration = mod .getModifiedItemAttr ("duration" )
@@ -188,12 +105,13 @@ def calcBurnCycles(self, mod): # estimates the number of cycles a module will OH
188105 p = self .calcDamageProbability (mod , t )
189106 fp .append (p )
190107
191- if f"{ p :.2f } " == f"{ lastp :.2f } " :
108+ if f"{ p :.5f } " == f"{ lastp :.5f } " :
192109 break
193110
194111 t += inc
195112 lastp = p
196113
114+ # http://jsfiddle.net/kkspy/86/
197115 E = 0 # expected wait to failure
198116 n = math .ceil (mod .getModifiedItemAttr ("hp" ) / mod .getModifiedItemAttr ("heatDamage" )) # fault tolerance
199117 a = [1 ]
@@ -214,45 +132,6 @@ def calcBurnCycles(self, mod): # estimates the number of cycles a module will OH
214132
215133 return math .floor (E )
216134
217- """
218- HANGAR.ShipInfoThermodynamics.prototype.calcBurnCycles = function(slot) {
219- var fp = [];
220- var p = 0, lastp = 0;
221- var mod = this.shipinfo.ship.slots[slot];
222- var inc = mod.speed ? mod.speed/1000 : mod.duration/1000;
223- var t = inc;
224-
225- while(t < this.simTime) {
226- p = this.getDamageProb(slot, t);
227- fp.push(p);
228- if(p.toFixed(2) === lastp.toFixed(2)) break;
229- t += inc;
230- lastp = p;
231- }
232-
233- //http://jsfiddle.net/kkspy/86/
234- var E = 0;
235- var n = Math.ceil(mod.hp / mod.heatDamage);
236- var a = [1];
237- for(var i = 1; i < n;i++) { a.push(0); }
238-
239- for(var t = 0; t < fp.length; t++) {
240- E += (t+1)*fp[t]*a[n-1];
241- for(var k = n-1; k > 0; k--) {
242- a[k] = (1-fp[t])*a[k] + fp[t]*a[k-1];
243- }
244- a[0] = (1-fp[t])*a[0];
245- }
246-
247- t--;
248- for(var k = 0; k < n; k++) {
249- E += ( t+1 + (n-k)*(1/fp[t]))*a[k];
250- }
251-
252- return Math.floor(E);
253- };
254- """
255-
256135class Heat (ViewColumn ):
257136 name = "Heat"
258137
0 commit comments