Advertisement
hbar

scaler.py

Nov 14th, 2013
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. import matplotlib.image as mpimg
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import matplotlib.cm as cm
  5. from datetime import timedelta
  6.  
  7.  
  8. img = mpimg.imread("notch.png")
  9. counts = [0 for i in range(9)]
  10. materials = [
  11.             "Cobblestone",
  12.             "Compressed Cobblestone",
  13.             "Double Compressed Cobblestone",
  14.             "Triple Compressed Cobblestone",
  15.             "Quadruple Compressed Cobblestone",
  16.             "Quintuple Compressed Cobblestone",
  17.             "Sextuple Compressed Cobblestone",
  18.             "Septuple Compressed Cobblestone",
  19.             "Octuple Compressed Cobblestone"
  20.             ]
  21. materials.reverse()
  22. materials = map(lambda x: x.rjust(32),materials)
  23.  
  24. for r in range(len(img)):
  25.     for c in range(len(img[0])):
  26.         pixel = int(round(img[r][c]*8+1))
  27.         counts[pixel-1] += 1
  28.         img[r][c] = pixel
  29.  
  30. f = open("notch.txt","w")
  31. for r in range(len(img)):
  32.     for c in range(len(img[0])):
  33.             f.write(str(int(img[r][c])))
  34.     f.write("\n")
  35. f.close()
  36.  
  37. cobble = 0
  38. print "Required materials:"
  39. for i,c in enumerate(counts):
  40.     print " {}: {} ({} stacks + {})".format(materials[i],c,*divmod(c,64))
  41.     cobble += c*(9**(9-i))
  42. print
  43. t = timedelta(seconds=(cobble/(20.0*64)))
  44. if t.days > 1:
  45.     time = ["days", t.days]
  46. elif t.hours > 1:
  47.     time = ["hours", t.hours]
  48. elif t.minutes > 1:
  49.     time = ["minutes", t.minutes]
  50. else:
  51.     time = ["seconds", t.seconds]
  52.  
  53. print "    Total number of Cobblestone required: %d (will take %.1f %s at 64 cobblestone/tick)." % (cobble, time[1], time[0])
  54.  
  55. img = (1/9.0)*img
  56. plt.imshow(img, cmap=cm.Greys_r)
  57. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement