Advertisement
CelticCoder

predictSimpleQuarry

Nov 13th, 2023 (edited)
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Quarry Dimension Input and Mining Program
  2.  
  3. -- Get the dimensions
  4. function input(newWidth, newLength, newDepth)
  5.     width = newWidth
  6.     length = newLength
  7.     depth = newDepth
  8.     fuelcost = 0
  9. end
  10.  
  11. function getFuelCost()
  12.     return fuelcost
  13. end
  14.  
  15. -- Function to Mine to Depth
  16. function mineDepth()
  17.   for i = 1, depth do
  18.     fuelcost = fuelcost + 1
  19.   end
  20.   for j = 1, depth do
  21.     fuelcost = fuelcost + 1
  22.   end
  23. end
  24.  
  25. -- Function to mine a layer
  26. function mine(width, length)
  27.   for i = 1, length do
  28.     for j = 1, width do
  29.       mineDepth()
  30.       fuelcost = fuelcost + 1
  31.     end
  32.     if i < length then
  33.       if i % 2 == 1 then
  34.         mineDepth()
  35.         fuelcost = fuelcost + 1
  36.       else
  37.         mineDepth()
  38.         fuelcost = fuelcost + 1
  39.       end
  40.     end
  41.   end
  42. end
  43.  
  44.  
  45. function toStart()
  46.     if length % 2 == 1 then
  47.         for i = 1, width do
  48.             fuelcost = fuelcost + 1
  49.         end
  50.     end
  51.     for j = 2, length do
  52.             fuelcost = fuelcost + 1
  53.     end
  54.     fuelcost = fuelcost + 1
  55. end
  56.  
  57.  
  58. function predict(newWidth, newLength, newDepth)
  59.     input(newWidth, newLength, newDepth)
  60.     fuelcost = fuelcost + 1
  61.     mine(width, length)
  62.     mineDepth()
  63.     toStart()
  64.     return fuelcost
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement