Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- print("from the top of the circle going clockwise put the 4 numbers from 1-4 representing the mood of the npc")
- print("ie top:4(happiest) right:1(angriest) etc")
- print(nil)
- print("next 4 numbers represent the size of the filled in circle from top going clockwise")
- print("ie top:1(smallest effect) bottom:4(largest effect) etc")
- print(nil)
- print("example: 2143 4132")
- print(nil)
- function options(grid)
- highest = 0
- winner = ""
- for i=1,5 do
- for v = 1,5 do
- if v~=i then
- for e = 1,5 do
- if (e~=v) and (e~=i) then
- for r = 1,5 do
- if (r~=e) and (r~=i) and (r~=v) then
- for t = 1,5 do
- if (t~=r) and (t~=e) and (t~=i) and (t~=v) then
- local newValue = returnValue(""..i..v..e..r..t,grid)
- if newValue > highest then
- highest = newValue
- winner = ""..i..v..e..r..t
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- function shift(pos,times)
- local result = (pos-(times-1))%4
- if result == 0 then
- result = 4
- end
- return result
- end
- function createGrid()
- local grid = {}
- for i=1,5 do
- grid[i] = {}
- for v = 1,4 do
- grid[i][v] = evaluateScore( tonumber( sInput:sub(v,v) ), tonumber( sInput:sub(shift(v,i)+4,shift(v,i)+4)) )
- end
- end
- return grid
- end
- function evaluateScore(attitude,potency)
- local value = 0
- if attitude == 4 then
- value = 2
- elseif attitude == 3 then
- value = 1
- elseif attitude == 2 then
- value = -1
- elseif attitude == 1 then
- value = -2
- end
- return value * potency
- end
- function returnValue(strnum,grid)
- local result = 0
- for i=1,5 do
- local sel = tonumber(strnum:sub(i,i))
- if sel == 5 then
- result = result + 0
- else
- result = result + grid[i][sel]
- end
- end
- return result
- end
- local function translate(sNum)
- local num = tonumber(sNum)
- if num == 1 then
- return "Top"
- elseif num == 2 then
- return "Right"
- elseif num == 3 then
- return "Bottom"
- elseif num == 4 then
- return "Left"
- elseif num == 5 then
- return "Rotate"
- end
- end
- function split(num)
- sNum = tostring(num)
- local result = ""
- for i = 1,5 do
- if i==5 and translate(sNum:sub(i,i))=="Rotate" then
- result = result
- else
- result = result..translate(sNum:sub(i,i))
- end
- if i~=5 then
- result = result.." "
- end
- end
- return result
- end
- --options()
- --textutils.slowPrint(string3)
- --print(evaluateScore(3,2))
- --print(tonumber(sInput:sub(1,1)))
- while true do
- term.setTextColor(colors.yellow)
- sInput = read()
- sInput = sInput:gsub("%s","")
- term.setTextColor(colors.white)
- newGrid = createGrid()
- options(newGrid)
- if tostring(highest):sub(1,1) == "-" then
- print("Score: "..tostring(highest))
- else
- print("Score: +"..tostring(highest))
- end
- print(split(winner))
- end
- --print(returnValue(winner,newGrid))
- --textutils.pagedPrint(textutils.serialize(newGrid))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement