Advertisement
Guest User

Homing in on damage numbers

a guest
Aug 31st, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.23 KB | None | 0 0
  1. #input.txt
  2. Levi 1st    1.0 324 337 350 362 375 388 401
  3. Levi 3rd    1.15    372 387 402 417 432 447 461
  4. Levi Charge 1.50    485 505 524 544 563 582 602
  5. Suda 3rd    1.15**2 428 445 462 479 496 513 531
  6. Suda Charge 1.5*1.075   522 543 563 584 605 626 647
  7. Suda Charge Explosion   1.15*1.5    558 580 603 625 647 670 692
  8. Nitro   1.075   348 362 376 390 404 417 431
  9. Irontech    1.075**2    374 389 404 419 434 449 464
  10. BAB 1.075*1.15  400 416 432 448 464 480 496
  11.  
  12.  
  13. #script file
  14. require 'bigdecimal'
  15.  
  16. def num value # Use BigDecimal to minimize float errors
  17.   BigDecimal.new(value, 16) # Biggest precision allowed
  18. end
  19.  
  20. # Initialize
  21. attacks = File.open 'input.txt' do |file|
  22.   file.read.split(?\n).map do |line|
  23.     name, multiplier, *values = line.split(?\t)
  24.     values = values.map{|v| num(v.to_f)}
  25.     {
  26.       name: name,
  27.       multiplier: num(eval(multiplier)),
  28.       max: values.map{|v| v+0},
  29.       min: values.map{|v| v-1}
  30.     }
  31.   end
  32. end
  33.  
  34. # Make a copy
  35. control = attacks.map do |attack|
  36.   {
  37.     name: attack[:name],
  38.     multiplier: attack[:multiplier],
  39.     max: attack[:max].map{|v| v},
  40.     min: attack[:min].map{|v| v}
  41.   }
  42. end
  43.  
  44. def compare_min attacks, comparison
  45.   attacks[0][:min][0] = [attacks[0][:min][0], comparison].max
  46. end
  47.  
  48. def compare_max attacks, comparison
  49.   attacks[0][:max][0] = [attacks[0][:max][0], comparison].min
  50. end
  51.  
  52. def test attacks, control, exclude=nil
  53.   errors = false
  54.  
  55.   # Compare every level of bonus with every other level of bonus
  56.   attacks.each_with_index do |attack, i|
  57.     next if i == exclude
  58.     (0..6).each do |bonus|
  59.       multiplier = (num(1.0) + num(0.04) * bonus) * attack[:multiplier]
  60.  
  61.       attacks[0][:min][0] = [attacks[0][:min][0], attack[:min][bonus] / multiplier].max
  62.       attacks[0][:max][0] = [attacks[0][:max][0], attack[:max][bonus] / multiplier].min
  63.  
  64.       attack[:min][bonus] = [attacks[0][:min][0] * multiplier, attack[:min][bonus]].max
  65.       attack[:max][bonus] = [attacks[0][:max][0] * multiplier, attack[:max][bonus]].min
  66.  
  67.       if attack[:max][bonus] < control[i][:min][bonus] or attack[:min][bonus] > control[i][:max][bonus]
  68.         puts "Weird value detected!
  69.          #{attack[:name]}(#{bonus})(multiplier: #{multiplier.to_s(?F)})"
  70.       end
  71.  
  72.     end
  73.   end
  74. end
  75.  
  76.  
  77. test attacks, control
  78. test attacks, control # Second pass after levi 1st hit has been made as accurate as possible
  79.  
  80. puts attacks.map{ |attack|
  81.   "#{attack[:name]}
  82.  Min: #{attack[:min].map{|v| v.to_s(?F)}.join(', ')}
  83.  Max: #{attack[:max].map{|v| v.to_s(?F)}.join(', ')}
  84.  "
  85. }.join(?\n)
  86.  
  87. #output
  88. Weird value detected!
  89.           Levi 1st(3)(multiplier: 1.12)
  90. Levi 1st
  91.   Min: 323.214285714285714285714285715, 336.1428571428571428571428571436, 349.0714285714285714285714285722, 362.0000000000000000000000000008, 374.9285714285714285714285714294, 387.857142857142857142857142858, 400.7857142857142857142857142866
  92.   Max: 323.214285714285714285714285715, 336.1428571428571428571428571436, 349.0714285714285714285714285722, 362.0, 374.9285714285714285714285714294, 387.857142857142857142857142858, 400.7857142857142857142857142866
  93.  
  94. Levi 3rd
  95.   Min: 371.69642857142857142857142857225, 386.56428571428571428571428571514, 401.43214285714285714285714285803, 416.30000000000000000000000000092, 431.16785714285714285714285714381, 446.0357142857142857142857142867, 460.90357142857142857142857142959
  96.   Max: 371.69642857142857142857142857225, 386.56428571428571428571428571514, 401.43214285714285714285714285803, 416.30000000000000000000000000092, 431.16785714285714285714285714381, 446.0357142857142857142857142867, 460.90357142857142857142857142959
  97.  
  98. Levi Charge
  99.   Min: 484.8214285714285714285714285725, 504.2142857142857142857142857154, 523.6071428571428571428571428583, 543.0000000000000000000000000012, 562.3928571428571428571428571441, 581.785714285714285714285714287, 601.1785714285714285714285714299
  100.   Max: 484.8214285714285714285714285725, 504.2142857142857142857142857154, 523.6071428571428571428571428583, 543.0000000000000000000000000012, 562.3928571428571428571428571441, 581.785714285714285714285714287, 601.1785714285714285714285714299
  101.  
  102. Suda 3rd
  103.   Min: 427.4508928571428571428571428580875, 444.548928571428571428571428572411, 461.6469642857142857142857142867345, 478.745000000000000000000000001058, 495.8430357142857142857142857153815, 512.941071428571428571428571429705, 530.0391071428571428571428571440285
  104.   Max: 427.4508928571428571428571428580875, 444.548928571428571428571428572411, 461.6469642857142857142857142867345, 478.745000000000000000000000001058, 495.8430357142857142857142857153815, 512.941071428571428571428571429705, 530.0391071428571428571428571440285
  105.  
  106. Suda Charge
  107.   Min: 521.1830357142857142857142857154375, 542.030357142857142857142857144055, 562.8776785714285714285714285726725, 583.72500000000000000000000000129, 604.5723214285714285714285714299075, 625.419642857142857142857142858525, 646.2669642857142857142857142871425
  108.   Max: 521.1830357142857142857142857154375, 542.030357142857142857142857144055, 562.8776785714285714285714285726725, 583.72500000000000000000000000129, 604.5723214285714285714285714299075, 625.419642857142857142857142858525, 646.2669642857142857142857142871425
  109.  
  110. Suda Charge Explosion
  111.   Min: 557.544642857142857142857142858375, 579.84642857142857142857142857271, 602.148214285714285714285714287045, 624.45000000000000000000000000138, 646.751785714285714285714285715715, 669.05357142857142857142857143005, 691.355357142857142857142857144385
  112.   Max: 557.544642857142857142857142858375, 579.84642857142857142857142857271, 602.148214285714285714285714287045, 624.45000000000000000000000000138, 646.751785714285714285714285715715, 669.05357142857142857142857143005, 691.355357142857142857142857144385
  113.  
  114. Nitro
  115.   Min: 347.455357142857142857142857143625, 361.35357142857142857142857142937, 375.251785714285714285714285715115, 389.15000000000000000000000000086, 403.048214285714285714285714286605, 416.94642857142857142857142857235, 430.844642857142857142857142858095
  116.   Max: 347.455357142857142857142857143625, 361.35357142857142857142857142937, 375.251785714285714285714285715115, 389.15000000000000000000000000086, 403.048214285714285714285714286605, 416.94642857142857142857142857235, 430.844642857142857142857142858095
  117.  
  118. Irontech
  119.   Min: 373.514508928571428571428571429396875, 388.45508928571428571428571428657275, 403.395669642857142857142857143748625, 418.3362500000000000000000000009245, 433.276830357142857142857142858100375, 448.21741071428571428571428571527625, 463.157991071428571428571428572452125
  120.   Max: 373.514508928571428571428571429396875, 388.45508928571428571428571428657275, 403.395669642857142857142857143748625, 418.3362500000000000000000000009245, 433.276830357142857142857142858100375, 448.21741071428571428571428571527625, 463.157991071428571428571428572452125
  121.  
  122. BAB
  123.   Min: 399.57366071428571428571428571516875, 415.5566071428571428571428571437755, 431.53955357142857142857142857238225, 447.522500000000000000000000000989, 463.50544642857142857142857142959575, 479.4883928571428571428571428582025, 495.47133928571428571428571428680925
  124.   Max: 399.57366071428571428571428571516875, 415.5566071428571428571428571437755, 431.53955357142857142857142857238225, 447.522500000000000000000000000989, 463.50544642857142857142857142959575, 479.4883928571428571428571428582025, 495.47133928571428571428571428680925
  125.  
  126. [Finished in 0.2s]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement