Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactor = peripheral.wrap("BiggerReactors_Reactor_1")
- local sleepTime = 3
- local step = 20
- local epsilon = 0.0001
- local rodCount = reactor.controlRodCount()
- local bestRatio = 0
- local bestConfig = {}
- -- Activer le réacteur si besoin
- if not reactor.active() then
- reactor.setActive(true)
- sleep(2)
- end
- -- Utilitaires
- local function applyConfig(config)
- for i = 0, rodCount - 1 do
- reactor.getControlRod(i).setLevel(config[i] or 0)
- end
- end
- local function testConfig(config)
- applyConfig(config)
- sleep(sleepTime)
- local transitioned = reactor.coolantTank().transitionedLastTick()
- local burned = reactor.fuelTank().burnedLastTick()
- local ratio = transitioned / (burned + epsilon)
- print("Test config: [" .. table.concat(config, ", ") .. "]")
- print(" Vapeur: " .. transitioned .. " mB/t | Fuel: " .. burned .. " | Ratio: " .. ratio)
- if ratio > bestRatio then
- bestRatio = ratio
- bestConfig = { table.unpack(config) }
- end
- end
- -- Méthode 1 : bruteforce toutes combinaisons
- local function bruteForce(index, current)
- if index >= rodCount then
- testConfig(current)
- return
- end
- for level = 0, 100, step do
- current[index] = level
- bruteForce(index + 1, current)
- end
- end
- -- Méthode 2 : empilement progressif
- local function progressiveStack()
- local config = {}
- for i = 0, rodCount - 1 do config[i] = 0 end
- for i = 0, rodCount - 1 do
- for level = 0, 100, step do
- config[i] = level
- testConfig(config)
- end
- config[i] = 100 -- verrouille la rod à 100 pour la suite
- end
- end
- -- Menu de sélection
- print("=== Optimiseur Bigger Reactor ===")
- print("1. Test complet (toutes les combinaisons)")
- print("2. Empilement progressif des rods")
- write("Choisis une méthode (1 ou 2) : ")
- local input = read()
- if input == "1" then
- print("\n▶ Lancement de l'optimisation complète...")
- bruteForce(0, {})
- elseif input == "2" then
- print("\n▶ Lancement de l'empilement progressif...")
- progressiveStack()
- else
- print("❌ Choix invalide. Fin du programme.")
- return
- end
- -- Appliquer la meilleure config
- print("\n✅ Meilleure configuration trouvée :")
- for i = 0, rodCount - 1 do
- print(" Rod #" .. i .. ": " .. bestConfig[i] .. "%")
- reactor.getControlRod(i).setLevel(bestConfig[i])
- end
Advertisement
Add Comment
Please, Sign In to add comment