From d180cc071b592940d4b4cf0283823d29578f1422 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 27 Aug 2019 19:16:51 -0400 Subject: some files to help me jog my memory elsewhere --- CORE1.cpp | 38 +++++++++++++++++++++++++++++++++++--- README.md | 5 ++--- dylfunc_call.cpp | 9 +++++++++ dylfunc_compile.cpp | 10 ++++++++++ pgsql_connect.cpp | 9 +++++++++ simple_recv.cpp | 13 +++++++++++++ simple_send.cpp | 10 ++++++++++ 7 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 dylfunc_call.cpp create mode 100644 dylfunc_compile.cpp create mode 100644 pgsql_connect.cpp create mode 100644 simple_recv.cpp create mode 100644 simple_send.cpp diff --git a/CORE1.cpp b/CORE1.cpp index ee0ffa6..64dc49d 100644 --- a/CORE1.cpp +++ b/CORE1.cpp @@ -67,6 +67,7 @@ using namespace opencog; void atomtest() { AtomSpace as; + // Handle subclasses a shared_ptr to Atom Handle h = as.add_node(CONCEPT_NODE, "Cat"); HandleSeq hseq = {h, h}; Handle dumbInheritance = as.add_link(INHERITANCE_LINK, hseq); @@ -157,7 +158,7 @@ void atomtest() // - ADD CODE TO ATOMS // we will want a sequence of substeps // raw strings interspersed with variable references - // - OUTPUT ATOMSPACE to see how it looks + // - OUTPUT ATOMSPACE to see how it looks <-- this was just to help a different state of work // - IMPLEMENT SOLVER USING PATTERNS // will need a way to // - get patterns matching requests @@ -463,9 +464,40 @@ int main() // map similarity between the structures of interacting with peers, and internal // structures. -// ONCE YOU CAN THINK: +// AFTER YOU CAN THINK RELIABLY: // when you find a good choice, be sure to use it to research how to make the bad // choice just as good. ((all things have inherent value)) -// be sure to generalize pattern work, with simple processes that work for many forms +// be sure to generalize patterns and pattern work,w/ simple processes that work for many forms + +// CUR TASK: send and receive a simple goal with habit to reach goal +// this is a subtask of process optimization +// it is communication between subprocesses +// +// goal: communicate with other process +// +// pre: +// $x is a process +// $y is a process +// $z is information +// $x knows $z +// $y does not know $z +// +// post: +// $y knows $z +// +// habit: +// +// we'll need a step reserializer. +// way to merge serialization and deserialization? +// 1. form patterns mapping between the two +// 2. make a general reserialization process that makes the missing pattern exist +// + +// CORE ROLES: +// - group learning: research how to research stuff +// - diversity: brainstorm new parts of learning to be researched +// - implement processes researching the parts of learning brainstormed +// diff --git a/README.md b/README.md index 2f99882..4fe45b2 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,9 @@ and it must be able to refer to itself usefully. 1. Choose a simple algorithm for collecting steps together to perform a task. 2. Choose a simple representation of steps to use for #1. 3. Implement #2 enough to use it to communicate a step to another process. - Once #3 works, the goal now is to efficiently produce a form of #1 as a collection of -processes that can develop themselves, so make sure to reuse your work, and do work that is -reusable, as much as possible. +processes that can develop themselves, using each other as their steps. Make sure to +reuse your work, and do work that is reusable, as much as possible. 4. Choose a simple algorithm for handling if something horrible goes wrong that must never be repeated (trauma). Consider storing a detailed log forever. Consider refusing to diff --git a/dylfunc_call.cpp b/dylfunc_call.cpp new file mode 100644 index 0000000..bbd2ea7 --- /dev/null +++ b/dylfunc_call.cpp @@ -0,0 +1,9 @@ +// this process loads a dynamic library built by dylfunc_compile +// and executes it with the passed data + +// we are moving towards judging that we no longer need dynamic loading +// and could just compile new code ... it seems valuable but slow-start. +// why not just build processes? +// need to structure input and output +// +// okay, let's look into atomspace serialization diff --git a/dylfunc_compile.cpp b/dylfunc_compile.cpp new file mode 100644 index 0000000..9023f97 --- /dev/null +++ b/dylfunc_compile.cpp @@ -0,0 +1,10 @@ + +// this process builds a dynamic library wrapping other code + +extern "C" void dylfunc_compile() +{ + // write a dylfunc for passed context content + // compile it with g++ -shared -fPIC source.cpp -o source.so +} + + diff --git a/pgsql_connect.cpp b/pgsql_connect.cpp new file mode 100644 index 0000000..bcf5852 --- /dev/null +++ b/pgsql_connect.cpp @@ -0,0 +1,9 @@ +// this process / function connects to a postgresql atomspace backend, creating it if needed + +#include + +extern "C" void pgsql_connect(opencog::Handle name) +{ + // TODO: please install postgresql-server + // then follow instructions in src/atomspaces/opencog/persist/sql/README.md +} diff --git a/simple_recv.cpp b/simple_recv.cpp new file mode 100644 index 0000000..4f82ab3 --- /dev/null +++ b/simple_recv.cpp @@ -0,0 +1,13 @@ +// receives information as a text line on stdin +// works on StringValue 'text' + +#include +#include + +extern "C" void simple_recv(opencog::Handle data) +{ + std::string s(4096); + std::cin.getline(&s[0], s.size(), std::endl); + opencog::Handle text = data.getAtomSpace()->add_node(opencog::STRING_VALUE, "text"); + data.setValue(text, new opencog::StringValue(s)); +} diff --git a/simple_send.cpp b/simple_send.cpp new file mode 100644 index 0000000..62820a0 --- /dev/null +++ b/simple_send.cpp @@ -0,0 +1,10 @@ +// sends information as a text line on stdout +// works on StringValue 'text' + +#include +#include +extern "C" void simple_send(opencog::Handle data) +{ + opencog::Handle text = data.getAtomSpace()->add_node(opencog::STRING_VALUE, "text"); + std::cout << data.getValue(text).to_string() << std::endl; +} -- cgit v1.2.3