Advertisement
TurtleByte

Main Refactor

Mar 31st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. function main()
  2.     local function repeatPattern(pattern, last)
  3.         if last == nil then last = false end
  4.         local gain = 0.0
  5.         local round = 0
  6.         local score
  7.         repeat
  8.             score = getScore()
  9.             round = round + 1
  10.             print("Starting round " .. round .. " of pattern " .. table.concat(pattern, ","))
  11.             BandedWorm(pattern)
  12.             gain = getScore() - score
  13.         until gain < 0.01
  14.         PrintState()
  15.         if not last then InitializePuzzleState() end
  16.     end
  17.    
  18.     if GetParams() then
  19.         UUnweightedInitialScore = getScore()
  20.         for i = 1, 1000 do
  21.             mainloop = i
  22.             InitializePuzzleState()
  23.             print("#####################")
  24.             print("Starting main loop " .. mainloop)
  25.             repeatPattern({2, 5, 11, 3, 13, 4, 7, 1, 6})
  26.             repeatPattern({14, 8, 6, 7, 13, 12, 2, 10, 11})
  27.             repeatPattern({5, 7, 1, 3, 9, 6, 2, 4, 8})
  28.             repeatPattern({3, 6, 12, 4, 14, 5, 8, 2, 7})
  29.             repeatPattern({3, 8, 4, 5, 12, 6, 10, 2, 7}, true)
  30.         end
  31.         End()
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement