Reimplemented nexus and classes ADTs.
This commit is contained in:
@@ -1,77 +1,40 @@
|
|||||||
-- A unique group
|
local ID = 1
|
||||||
local classes = {}
|
local c = {}
|
||||||
classes.input = {}
|
setmetatable(c,{__call = function(c)
|
||||||
classes.output = {}
|
local this = {}
|
||||||
local function class()
|
c[this] = {}
|
||||||
return {}
|
return this
|
||||||
|
end})
|
||||||
|
c.i = {}
|
||||||
|
c.o = {}
|
||||||
|
c.next = c()
|
||||||
|
for char in ("abcdefghijklmnopqrstuvwxyz $;"):match(".") do
|
||||||
|
c.i[char] = c()
|
||||||
end
|
end
|
||||||
classes.after = class()
|
local function n(class,data,...)
|
||||||
classes.next = class()
|
local this = {up = {},class = class,data = data}
|
||||||
classes.chain = class()
|
table.insert(c[class],this)
|
||||||
classes.inside = class()
|
return this
|
||||||
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
|
end
|
||||||
|
local i = {}
|
||||||
-- implication trees, but what about the actions behind them? and things that don't really exist?
|
setmetatable(i,{__call = function(i,this)
|
||||||
-- imagination allows things that aren't possible to be possible in our heads at least.
|
|
||||||
-- an implication tree in a sense.
|
end})
|
||||||
|
local prev
|
||||||
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
|
while true do
|
||||||
local input = io.read()
|
prev = n(c[";"],ID,nil)
|
||||||
if input == "end" then return end
|
local input = io.read()
|
||||||
local actor
|
local mode,input = io.read():match("([#P])(.*)")
|
||||||
if input:match("^~") then
|
local t = ({["$"]=c.i,["#"]=c.o})[mode]
|
||||||
actor = input.output
|
if t then
|
||||||
input = input:match("[^#]*")
|
for char in input:match(".") do
|
||||||
elseif input:match("[^@]*") then
|
if t[char] then
|
||||||
actor = input.input
|
local this = n(t[char],ID,nil)
|
||||||
input = input:match("[^P]*")
|
n(t.next,ID,prev,this)
|
||||||
elseif input:match("^#") then
|
i(this)
|
||||||
print("null")
|
prev = this
|
||||||
return
|
end
|
||||||
elseif input:match("^;") then
|
|
||||||
previous_chain = null
|
|
||||||
end
|
end
|
||||||
local previous
|
end
|
||||||
local chain = nex(classes.chain,1)
|
prev = n(t[";"],ID,nil)
|
||||||
if previous_chain then
|
end
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user