Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Aspects = {
- aer = {
- name = "Aer",
- tier = 1
- },
- aqua = {
- name = "Aqua",
- tier = 1
- },
- ignis = {
- name = "Ignis",
- tier = 1
- },
- ordo = {
- name = "Ordo",
- tier = 1
- },
- perditio = {
- name = "Perditio",
- tier = 1
- },
- terra = {
- name = "Terra",
- tier = 1
- },
- gelum = {
- name = "Gelum",
- tier = 2
- },
- lux = {
- name = "Lux",
- tier = 2
- },
- motus = {
- name = "Motus",
- tier = 2
- },
- permutatio = {
- name = "Permutatio",
- tier = 2
- },
- potentia = {
- name = "Potentia",
- tier = 2
- },
- tempestas = {
- name = "Tempestas",
- tier = 2
- },
- vacuos = {
- name = "Vacuos",
- tier = 2
- },
- venenum = {
- name = "Venenum",
- tier = 2
- },
- victus = {
- name = "Victus",
- tier = 2
- },
- vitreus = {
- name = "Vitreus",
- tier = 2
- },
- herba = {
- name = "Herba",
- tier = 3
- },
- iter = {
- name = "Iter",
- tier = 3
- },
- limus = {
- name = "Limus",
- tier = 3
- },
- metallum = {
- name = "Metallum",
- tier = 3
- },
- mortuus = {
- name = "Mortuus",
- tier = 3
- },
- sano = {
- name = "Sano",
- tier = 3
- },
- tempus = {
- name = "Tempus",
- tier = 3
- },
- vinculum = {
- name = "Vinculum",
- tier = 3
- },
- volatus = {
- name = "Volatus",
- tier = 3
- },
- bestia = {
- name = "Bestia",
- tier = 4
- },
- fames = {
- name = "Fames",
- tier = 4
- },
- praecantatio = {
- name = "Praecantatio",
- tier = 4
- },
- tenebrae = {
- name = "Tenebrae",
- tier = 4
- },
- arbor = {
- name = "Arbor",
- tier = 4
- },
- infernus = {
- name = "Infernus",
- tier = 5
- },
- auram = {
- name = "Auram",
- tier = 5
- },
- examinis = {
- name = "Examinis",
- tier = 5
- },
- spiritus = {
- name = "Spiritus",
- tier = 5
- },
- superbia = {
- name = "Superbia",
- tier = 5
- },
- vitium = {
- name = "Vitium",
- tier = 5
- },
- alienis = {
- name = "Alienis",
- tier = 6
- },
- gula = {
- name = "Gula",
- tier = 6
- },
- cognito = {
- name = "Cognito",
- tier = 6
- },
- sensus = {
- name = "Sensus",
- tier = 6
- },
- corpus = {
- name = "Corpus",
- tier = 7
- },
- desidia = {
- name = "Desidia",
- tier = 8
- },
- humanus = {
- name = "Humanus",
- tier = 10
- },
- invidia = {
- name = "Invidia",
- tier = 10
- },
- luxuria = {
- name = "Luxuria",
- tier = 11
- },
- instrumentum = {
- name = "Instrumentum",
- tier = 11
- },
- perfodio = {
- name = "Perfodio",
- tier = 11
- },
- telum = {
- name = "Telum",
- tier = 12
- },
- tutamen = {
- name = "Tutamen",
- tier = 12
- },
- messis = {
- name = "Messis",
- tier = 13
- },
- ira = {
- name = "Ira",
- tier = 13
- },
- machina = {
- name = "Machina",
- tier = 13
- },
- lucrum = {
- name = "Lucrum",
- tier = 14
- },
- pannus = {
- name = "Pannus",
- tier = 15
- },
- fabrico = {
- name = "Fabrico",
- tier = 21
- },
- meto = {
- name = "Meto",
- tier = 24
- }
- }
- -- Links
- Aspects.venenum.links = { Aspects.aqua, Aspects.perditio }
- Aspects.pannus.links = { Aspects.instrumentum, Aspects.bestia }
- Aspects.perditio.links = { Aspects.vacuos, Aspects.gelum, Aspects.venenum, Aspects.permutatio, Aspects.mortuus, Aspects.vitium, Aspects.vinculum }
- Aspects.humanus.links = { Aspects.bestia, Aspects.cognito, Aspects.messis, Aspects.perfodio, Aspects.instrumentum, Aspects.lucrum, Aspects.fabrico }
- Aspects.lux.links = { Aspects.aer, Aspects.ignis, Aspects.tenebrae }
- Aspects.telum.links = { Aspects.instrumentum, Aspects.ignis, Aspects.ira }
- Aspects.corpus.links = { Aspects.mortuus, Aspects.bestia, Aspects.luxuria }
- Aspects.potentia.links = { Aspects.ordo, Aspects.ignis, Aspects.praecantatio }
- Aspects.vacuos.links = { Aspects.aer, Aspects.perditio, Aspects.tenebrae, Aspects.alienis, Aspects.praecantatio, Aspects.fames, Aspects.superbia, Aspects.gula, Aspects.tempus }
- Aspects.praecantatio.links = { Aspects.vacuos, Aspects.potentia, Aspects.auram, Aspects.vitium, Aspects.infernus }
- Aspects.spiritus.links = { Aspects.victus, Aspects.mortuus, Aspects.cognito, Aspects.sensus, Aspects.desidia }
- Aspects.examinis.links = { Aspects.motus, Aspects.mortuus }
- Aspects.tutamen.links = { Aspects.instrumentum, Aspects.terra }
- Aspects.vinculum.links = { Aspects.motus, Aspects.perditio, Aspects.desidia }
- Aspects.superbia.links = { Aspects.volatus, Aspects.vacuos }
- Aspects.fames.links = { Aspects.victus, Aspects.vacuos, Aspects.lucrum, Aspects.luxuria, Aspects.gula, Aspects.invidia }
- Aspects.gelum.links = { Aspects.ignis, Aspects.perditio }
- Aspects.aer.links = { Aspects.vacuos, Aspects.lux, Aspects.tempestas, Aspects.motus, Aspects.volatus, Aspects.auram, Aspects.arbor, Aspects.sensus }
- Aspects.vitreus.links = { Aspects.terra, Aspects.ordo, Aspects.metallum }
- Aspects.limus.links = { Aspects.victus, Aspects.aqua }
- Aspects.vitium.links = { Aspects.praecantatio, Aspects.perditio }
- Aspects.tenebrae.links = { Aspects.vacuos, Aspects.lux, Aspects.alienis }
- Aspects.victus.links = { Aspects.aqua, Aspects.terra, Aspects.mortuus, Aspects.spiritus, Aspects.sano, Aspects.limus, Aspects.herba, Aspects.bestia, Aspects.fames }
- Aspects.lucrum.links = { Aspects.humanus, Aspects.fames }
- Aspects.ignis.links = { Aspects.lux, Aspects.gelum, Aspects.potentia, Aspects.cognito, Aspects.telum, Aspects.infernus, Aspects.ira }
- Aspects.tempestas.links = { Aspects.aer, Aspects.aqua }
- Aspects.meto.links = { Aspects.messis, Aspects.instrumentum }
- Aspects.sano.links = { Aspects.victus, Aspects.ordo }
- Aspects.messis.links = { Aspects.herba, Aspects.humanus, Aspects.meto }
- Aspects.iter.links = { Aspects.motus, Aspects.terra }
- Aspects.permutatio.links = { Aspects.perditio, Aspects.ordo }
- Aspects.infernus.links = { Aspects.ignis, Aspects.praecantatio }
- Aspects.tempus.links = { Aspects.vacuos, Aspects.ordo }
- Aspects.aqua.links = { Aspects.tempestas, Aspects.victus, Aspects.venenum, Aspects.limus }
- Aspects.motus.links = { Aspects.aer, Aspects.ordo, Aspects.volatus, Aspects.iter, Aspects.bestia, Aspects.examinis, Aspects.machina, Aspects.vinculum }
- Aspects.perfodio.links = { Aspects.humanus, Aspects.terra }
- Aspects.alienis.links = { Aspects.vacuos, Aspects.tenebrae }
- Aspects.metallum.links = { Aspects.terra, Aspects.vitreus }
- Aspects.ordo.links = { Aspects.motus, Aspects.vitreus, Aspects.potentia, Aspects.permutatio, Aspects.sano, Aspects.instrumentum, Aspects.tempus }
- Aspects.desidia.links = { Aspects.vinculum, Aspects.spiritus }
- Aspects.fabrico.links = { Aspects.humanus, Aspects.instrumentum }
- Aspects.cognito.links = { Aspects.ignis, Aspects.spiritus, Aspects.humanus }
- Aspects.terra.links = { Aspects.vitreus, Aspects.victus, Aspects.metallum, Aspects.iter, Aspects.herba, Aspects.perfodio, Aspects.tutamen }
- Aspects.sensus.links = { Aspects.aer, Aspects.spiritus }
- Aspects.ira.links = { Aspects.telum, Aspects.ignis }
- Aspects.bestia.links = { Aspects.motus, Aspects.victus, Aspects.corpus, Aspects.humanus, Aspects.pannus }
- Aspects.volatus.links = { Aspects.aer, Aspects.motus, Aspects.superbia }
- Aspects.instrumentum.links = { Aspects.humanus, Aspects.ordo, Aspects.meto, Aspects.telum, Aspects.tutamen, Aspects.fabrico, Aspects.pannus, Aspects.machina }
- Aspects.auram.links = { Aspects.praecantatio, Aspects.aer }
- Aspects.herba.links = { Aspects.victus, Aspects.terra, Aspects.arbor, Aspects.messis }
- Aspects.luxuria.links = { Aspects.corpus, Aspects.fames }
- Aspects.gula.links = { Aspects.fames, Aspects.vacuos }
- Aspects.invidia.links = { Aspects.sensus, Aspects.fames }
- Aspects.arbor.links = { Aspects.aer, Aspects.herba }
- Aspects.mortuus.links = { Aspects.victus, Aspects.perditio, Aspects.spiritus, Aspects.corpus, Aspects.examinis }
- Aspects.machina.links = { Aspects.motus, Aspects.instrumentum }
- -- colors
- Aspects.venenum.colors = { text = colors.lime, background = colors.black }
- Aspects.pannus.colors = { text = colors.yellow, background = colors.white }
- Aspects.perditio.colors = { text = colors.lightGray, background = colors.gray }
- Aspects.humanus.colors = { text = colors.pink, background = colors.yellow }
- Aspects.lux.colors = { text = colors.orange, background = colors.yellow }
- Aspects.telum.colors = { text = colors.red, background = colors.lightGray }
- Aspects.corpus.colors = { text = colors.pink, background = colors.red }
- Aspects.potentia.colors = { text = colors.cyan, background = colors.white }
- Aspects.praecantatio.colors = { text = colors.pink, background = colors.magenta }
- Aspects.spiritus.colors = { text = colors.gray, background = colors.black }
- Aspects.examinis.colors = { text = colors.green, background = colors.gray }
- Aspects.tutamen.colors = { text = colors.cyan, background = colors.lightBlue }
- Aspects.vinculum.colors = { text = colors.pink, background = colors.brown }
- Aspects.superbia.colors = { text = colors.purple, background = colors.black }
- Aspects.fames.colors = { text = colors.red, background = colors.gray }
- Aspects.gelum.colors = { text = colors.lightBlue, background = colors.white }
- Aspects.aer.colors = { text = colors.white, background = colors.yellow }
- Aspects.vitreus.colors = { text = colors.white, background = colors.lightBlue }
- Aspects.limus.colors = { text = colors.lime, background = colors.yellow }
- Aspects.vitium.colors = { text = colors.magenta, background = colors.purple }
- Aspects.tenebrae.colors = { text = colors.black, background = colors.black }
- Aspects.victus.colors = { text = colors.magenta, background = colors.red }
- Aspects.lucrum.colors = { text = colors.yellow, background = colors.orange }
- Aspects.ignis.colors = { text = colors.yellow, background = colors.red }
- Aspects.tempestas.colors = { text = colors.gray, background = colors.white }
- Aspects.vacuos.colors = { text = colors.gray, background = colors.lightGray }
- Aspects.meto.colors = { text = colors.brown, background = colors.orange }
- Aspects.sano.colors = { text = colors.red, background = colors.magenta }
- Aspects.messis.colors = { text = colors.brown, background = colors.yellow }
- Aspects.iter.colors = { text = colors.brown, background = colors.red }
- Aspects.permutatio.colors = { text = colors.gray, background = colors.green }
- Aspects.infernus.colors = { text = colors.orange, background = colors.red }
- Aspects.tempus.colors = { text = colors.gray, background = colors.purple }
- Aspects.aqua.colors = { text = colors.lightBlue, background = colors.cyan }
- Aspects.motus.colors = { text = colors.white, background = colors.gray }
- Aspects.perfodio.colors = { text = colors.brown, background = colors.gray }
- Aspects.alienis.colors = { text = colors.brown, background = colors.purple }
- Aspects.metallum.colors = { text = colors.brown, background = colors.lightGray }
- Aspects.ordo.colors = { text = colors.white, background = colors.lightGray }
- Aspects.desidia.colors = { text = colors.black, background = colors.gray }
- Aspects.fabrico.colors = { text = colors.green, background = colors.lightGray }
- Aspects.cognito.colors = { text = colors.pink, background = colors.lightGray }
- Aspects.terra.colors = { text = colors.lime, background = colors.green }
- Aspects.sensus.colors = { text = colors.cyan, background = colors.blue }
- Aspects.ira.colors = { text = colors.red, background = colors.black }
- Aspects.bestia.colors = { text = colors.gray, background = colors.brown }
- Aspects.volatus.colors = { text = colors.lightGray, background = colors.white }
- Aspects.instrumentum.colors = { text = colors.gray, background = colors.blue }
- Aspects.auram.colors = { text = colors.magenta, background = colors.pink }
- Aspects.herba.colors = { text = colors.green, background = colors.lime }
- Aspects.luxuria.colors = { text = colors.white, background = colors.pink }
- Aspects.gula.colors = { text = colors.yellow, background = colors.brown }
- Aspects.invidia.colors = { text = colors.lime, background = colors.gray }
- Aspects.arbor.colors = { text = colors.green, background = colors.brown }
- Aspects.mortuus.colors = { text = colors.pink, background = colors.gray }
- Aspects.machina.colors = { text = colors.purple, background = colors.gray }
- monitor = peripheral.find("monitor")
- monitor.clear()
- monitor.setTextScale(0.5)
- maxX, maxY = monitor.getSize()
- buttons = {}
- for _, v in pairs(Aspects) do
- table.sort(v.links, function(a, b) return a.tier < b.tier end)
- end
- sortedAspects = {}
- for _, v in pairs(Aspects) do
- sortedAspects[#sortedAspects+1] = v
- end
- table.sort(sortedAspects, function(a, b) return a.tier < b.tier end)
- function goDeeper(carry, goal, depth)
- solutions = {}
- if depth == 0 then
- if carry.name == goal.name then return true, {{goal}} end
- else
- for _, v in pairs(carry.links) do
- result, newSolutions = goDeeper(v, goal, depth - 1)
- if result == true then
- for _, solution in newSolutions do
- solution[#solution+1] = carry
- solutions[#solutions+1] = solution
- end
- end
- end
- if #solutions > 0 then
- return true, solutions
- else
- return false
- end
- end
- end
- function findCheapest(a1, a2, iterations)
- solutions = goDeeper(a1, a2, iterations)
- print(textutils.serialize(solutions))
- end
- function tryButton(x, y)
- for _, button in pairs(buttons) do
- if x >= button.x and x <= button.x + button.w and y == button.y then
- return unpack(button.response)
- end
- end
- return "not a button at "..tostring(x)..", "..tostring(y)
- end
- function makeButton(x, y, w, response)
- buttons[#buttons+1] = {x = x, y = y, w = w, response = response}
- end
- function drawButton(x, y, text, textColor, backColor)
- monitor.setCursorPos(x, y)
- monitor.setTextColor(textColor)
- monitor.setBackgroundColor(backColor)
- monitor.write(" "..text.." ")
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- end
- function makeAspectButton(aspect, x, y)
- drawButton(x, y, aspect.name, aspect.colors.text, aspect.colors.background)
- makeButton(x, y, string.len(aspect.name) + 2, {"aspect", aspect})
- end
- function makeAspectButtons()
- x = 2
- y = 2
- for _, aspect in pairs(sortedAspects) do
- if x + string.len(aspect.name) + 2 > maxX then
- x = 2
- y = y + 2
- end
- makeAspectButton(aspect, x, y)
- x = x + string.len(aspect.name) + 3
- end
- return x, y
- end
- while 1 do
- if step == "prep1" then
- buttons = {}
- currentAspect = nil
- currentAspect2 = nil
- monitor.clear()
- _, y = makeAspectButtons()
- x = 2
- y = y + 2
- monitor.setCursorPos(x, y)
- monitor.write("Select an aspect to start")
- step = "input1"
- end
- if step == "input1" then
- event, _, xPos, yPos = os.pullEvent("monitor_touch")
- response, aspect = tryButton(xPos, yPos)
- if aspect then
- currentAspect = aspect
- step = "prep2"
- end
- end
- if step == "prep2" then
- buttons = {}
- currentAspect2 = nil
- monitor.clear()
- _, y = makeAspectButtons()
- x = 2
- y = y + 2
- monitor.setCursorPos(x, y)
- monitor.write("Select another aspect")
- x = 2
- y = y + 2
- monitor.setCursorPos(x, y)
- monitor.write("Current selection: ")
- x = 22
- drawButton(x, y, currentAspect.name, currentAspect.colors.text, currentAspect.colors.background)
- y = y + 2
- drawButton(x, y, "Cancel", colors.red, colors.white)
- makeButton(x, y, 8, "cancel")
- step = "input1"
- end
- if step == "input2" then
- event, _, xPos, yPos = os.pullEvent("monitor_touch")
- response, aspect = tryButton(xPos, yPos)
- if aspect then
- currentAspect2 = aspect
- step = "prep3"
- else
- if response == "cancel" then
- step = "prep1"
- end
- end
- end
- if step == "prep3" then
- buttons = {}
- monitor.clear()
- x = 2
- y = 2
- for i = 1, 9, 1 do
- drawButton(x, y, tostring(i), colors.black, colors.white)
- makeButton(x, y, 3, {"number", i})
- end
- x = 2
- y = y + 2
- monitor.setCursorPos(x, y)
- monitor.write("Select the number of aspects between the two")
- x = 2
- y = y + 2
- monitor.setCursorPos(x, y)
- monitor.write("Current selection: ")
- x = 22
- drawButton(x, y, currentAspect.name, currentAspect.colors.text, currentAspect.colors.background)
- x = x + string.len(currentAspect.name) + 2
- y = y + 2
- drawButton(2, y, "Cancel", colors.red, colors.white)
- makeButton(2, y, 8, "cancel")
- drawButton(10, y, "Undo", colors.yellow, colors.black)
- makeButton(10, y, 6, "undo")
- step = "input3"
- end
- if step == "input3" then
- event, _, xPos, yPos = os.pullEvent("monitor_touch")
- response, number = tryButton(xPos, yPos)
- if number then
- iterations = number
- step = "prep3"
- elseif response == "cancel" then
- step = "prep1"
- elseif response == "undo" then
- step = "prep2"
- end
- end
- if step == "calc1" then
- monitor.clear()
- monitor.setCursorPos(2, 2)
- monitor.write("Calculating...")
- solutions = findCheapest(currentAspect, currentAspect2, iterations + 2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement