77 lines
2.1 KiB
Lua
77 lines
2.1 KiB
Lua
-- A unique group
|
|
local classes = {}
|
|
classes.input = {}
|
|
classes.output = {}
|
|
local function class()
|
|
return {}
|
|
end
|
|
classes.after = class()
|
|
classes.next = class()
|
|
classes.chain = class()
|
|
classes.inside = class()
|
|
for char in "$abcdefghijklmnopqrstuvwxyz ":gmatch(".") do
|
|
classes.input[char] = class()
|
|
classes.output[char] = class()
|
|
end
|
|
|
|
-- Relation of a class holdin a value between nexus of symbolic index
|
|
local function nex(class,v,...)
|
|
local this = {class = class, value = value, up = {}, at = {},...}
|
|
for index,item in ipairs({...}) do
|
|
this.at[item] = index
|
|
table.insert(item.up,this)
|
|
end
|
|
return this
|
|
end
|
|
|
|
-- implication trees, but what about the actions behind them? and things that don't really exist?
|
|
-- imagination allows things that aren't possible to be possible in our heads at least.
|
|
-- an implication tree in a sense.
|
|
|
|
local function update(root)
|
|
-- Objective: find nexus pieces that relate to cookies
|
|
-- find the cookies and try to build classes about them
|
|
-- try to crunch those classes and find similarities
|
|
|
|
end
|
|
|
|
local function action(root)
|
|
-- Objective: build hypothetical scenarios from nexus
|
|
-- the ones with output classes are most preferred since they can be acted upon
|
|
|
|
end
|
|
|
|
-- Main loop
|
|
local previous_chain
|
|
while true do
|
|
local input = io.read()
|
|
if input == "end" then return end
|
|
local actor
|
|
if input:match("^~") then
|
|
actor = input.output
|
|
input = input:match("[^#]*")
|
|
elseif input:match("[^@]*") then
|
|
actor = input.input
|
|
input = input:match("[^P]*")
|
|
elseif input:match("^#") then
|
|
print("null")
|
|
return
|
|
elseif input:match("^;") then
|
|
previous_chain = null
|
|
end
|
|
local previous
|
|
local chain = nex(classes.chain,1)
|
|
if previous_chain then
|
|
nex(classes.after,1,previous_chain,chain)
|
|
end
|
|
for char in input:gmatch(".") do
|
|
if classes[char] then
|
|
local object = nex(actor[char],1)
|
|
nex(classes.inside,1,object,chain)
|
|
if previous then nex(classes.next,1,previous,object) end
|
|
previous = object
|
|
end
|
|
end
|
|
update(chain)
|
|
action(chain)
|
|
end |