code samples (4)

Explicit Inferences

This is an example of an explicit inference: If I see you then you see me. Explicit inferences are executable code. They will execute when the conditions of the inference match something in the context: >> if i see you then you see me if You see Me then I see You. >> i see you You see Me. I see You. Infererence templates are retriggerable: >> if an animal sees the princess then the animal is happy if a animal sees…

Disbelief

It can be valuable to run Brainhat in a mode where it does not automatically believe everything it is told. This gives Brainhat the ability to evaluate knowledge against its own belief system. Let's start with an example where Brainhat believes everything it is told: $ ./run make: 'data' is up to date. Initializing >> i like you You like Me. >> debug xspeak 1 You say You like Me. You like Me. >> do i like you? yes. You like Me.

Heads or Tails

We teach Brainhat to play heads-or-tails. The first to reach a score of 5 wins: >> your score is 0. my score belonging to I is 0. >> my score is 0. your score belonging to You is 0. >> if i say heads then add 1 to your score. if You say head then add 1 number to my score. >> if i say tails then add 1 to my score. if You say tail then add 1 number to your score.

Where is the Ball?

This program is made up of three explicit inferences: $ ./run make: 'data' is up to date. Initializing >> if dog has toy and dog is in room then toy is in room. if dog has toy and dog is in room then toy is in room. >> if a dog sees a cat then dog drops toy and dog chases cat. if a dog sees a cat then dog drops toy and dog chases cat. >> if dog drops toy then…