Created
February 20, 2014 21:05
-
-
Save binary132/9123192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cell | |
def initialize | |
@name=:nak | |
@eu=384000 | |
@time=150 | |
end | |
attr_reader :name, :eu, :time | |
end | |
class Reactor | |
def initialize( howmuchEu, time, cells, name, eupt ) | |
@eu=howmuchEu | |
@time=time | |
@cells=cells | |
@name=name | |
@eupt=eupt | |
@times=Time.at(@time).gmtime.strftime('%R:%S') | |
end | |
def to_s | |
"#{@name}:\n Total EU per cycle: #{@eu}\n EU/t: #{@eupt}\n Cycle duration:#{@times}" | |
end | |
attr_reader :eu, :time, :cells, :name, :eupt | |
end | |
class Efficiency | |
def initialize( reactorKind, reactor, cell ) | |
@kind=reactorKind | |
@reactor=reactor | |
@tEff=24*cell.time/(reactor.time.to_f) | |
@reducedEupt=reactor.eupt-128 | |
@euEff=24*cell.eu/(reactor.eu.to_f) | |
end | |
def to_s | |
"#{@reactor}\n Freeze/cycle: #{@tEff}\n Reduced rate:#{@reducedEupt}\n EU efficiency per cycle:#{@euEff}" | |
end | |
attr_reader :kind, :reactor, :tEff, :reducedEupt, :euEff | |
end | |
nak=Cell.new | |
effs={ } | |
reactors=[[79349600, 9017, 24, :"1u", 440], | |
[67334400, 3006, 24, :"2u", 1120], | |
[58425600, 1074, 24, :"4u", 2720], | |
[67334400,15030, 24, :"2t", 224], | |
[58398400, 5367, 24, :"4t", 544]].each.map {|args| Reactor.new(*args)} | |
# effs will be a list of efficiency objects | |
effs=reactors.each.map{|reactor| effs[reactor.name]=Efficiency.new(reactor.name,reactor,nak)} | |
effs.sort! {|a, b| a.euEff <=> b.euEff} | |
puts effs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment