Hi Johannes,

On Mon, Dec 10, 2018 at 10:48 AM Johannes Castner <[email protected]> wrote:
>
> I'm trying to develop a system with users who have accounts with points in 
> them ...how do I associate a user concept and particular instantiations of 
> users with accounts which have a NumberNode in them which is denoted in 
> "points"?
> I have this so far:
>
> (define User (ConceptNode "User" (stv 0.01 1)))
> (define account (PredicateNode "account"))
> (define Animal (ConceptNode "Animal" (stv 0.1 1)))
> (define alive (PredicateNode "alive" (stv 0.01 1))) ; something is alive
> (define user_animal (InheritanceLink User Animal (stv 1 1))) ; all users are 
> animals; defined by us (no market needed)
> (define animal_alive (EvaluationLink alive (ListLink Animal) (stv 0.9 1))) ; 
> most animals we will encounter are alive
> ;(define create-account (QuantityLink (ConceptNode "points") (NumberNode 
> 100000)))
>
> ; all users have an account
> (EvaluationLink
>     account
>     (ListLink
>         User
>     )
> )
>
>
> How do I say that an account has points in it, that  can be updated and that 
> a user has that account etc?  I'm sorry, I'm still rather new to Atomese and 
> I've been trying to figure this out but I'm seriously stuck. Please help!
>

Let me try to answer by supplying some non-answers.  So, first atomese
is sort-of meant to be a low-level-language that humans would not
ordinarily write, but rather that other programs and algos would read,
write and transform. That said, its OK to do what you're doing. No
problem there.

Next, atomese is meant to be free-form: you don't have to declare a
structure (or a "class") before using it.  You can just dump in data,
in some arbitrary form, and then later search through it.  So, for
your example, you might say something like this:

(EvaluationLink
    (PredicateNode "has an account")
    (ListLink (ConceptNode "Joe")))

(EvaluationLink
    (PredicateNode "has some points")
    (ListLink (ConceptNode "Joe") (NumberNode 23)))

(Inheritance (ConceptNode "Joe") (ConceptNode "animal"))

and lets say you want to find all users $X that are animals and have 23 points:

(GetLink
      (AndLink
           (EvaluationLink (Predicate "has an account")   (ListLink
(Variable "$X")))
           (EvaluationLink (PredicateNode "has some points")
                    (ListLink (Variable "$X") (NumberNode 23)))
            (Inheritance (VariableNode "$X") (ConceptNode "animal"))))

so if you run (cog-execute! (GetLink ...)) you should get back
(SetLink (ConceptNode "Joe"))

You can try creating Alice who has 24 points, and Bob who is not an
animal, in which case the Get should still return only Joe.

These examples are all written in scheme. And I think the above is
fairly easy to understand. But if you want to create big, complex
programs, and you are learning scheme for the first time, then you
might find this hard to do. ... learning a language for the first
time, and also writing a big project in it .. is not a recipe for good
code.  ... and so you might want to use python, instead, if the goal
is to build an app, quick..

I kind of dread suggesting python ... in the long run, learning scheme
is "better for you", it opens your mind to functional programming, and
a whole different way of thinking about software, and about
objects/object-oriented -programming, and about data, and what it
means for something to be "data", etc.  So its good for you.  But if
you're in a hurry to just write an app .. use python.  The
examples/python directory has some examples.

BTW, the create-account would be a function:

(define (create-an-account the-users-name initial-points)
        (EvaluationLink (Predicate "has an account")   (ListLink
(Concept the-users-name)))
         (EvaluationLink (PredicateNode "has some points")
                    (ListLink (Concept the-users-name) (NumberNode
initial-points)))
            (Inheritance (Concept the-users-name) (ConceptNode "animal")))

and you'd call you function like this:

(create-an-account "Alice" 24)

Also, by the way, to change to point total, you'd have to either
delete the old point total, or use StateLink.  If you don't delete the
old point total, you'll just have same person, with several different
amounts of points.

--linas



-- 
cassette tapes - analog TV - film cameras - you

-- 
You received this message because you are subscribed to the Google Groups 
"opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/opencog.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/opencog/CAHrUA34ZvYYHJP_anXwump0yGtwrk_jyJ6EGBoKXZhgC1sc2CA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to