ASTRA Example: Belief Queries

The third example below show an ASTRA agent that uses the belief query plan operator.  It also includes an initial belief (as well as an initial goal).

01 agent Query {
02     module Console C;
03 
04     types eg {
05         formula is(string, string);
06     }
07 
08     initial !init();
09     initial is("rem", "happy");
10
11     rule +!init() {
12         C.println("starting");
13         query(is("rem", "happy"));
14         C.println("first hurdle passed");
15         query(is("rem", "sad"));
16         C.println("ending");
17     }
18 }

Notice that the query operator “?” is replaced by the “query” keyword in ASTRA. Additionally, for the first time, we see the introduction of the types … keyword. This keyword is used to specify the types of beliefs that are valid for a given program. They are used for type checking – if you use a belief that is not declared in this section of the program, the compiler will generate an error indicating that the belief has not been specified. The identifier “eg” is used to associate a unique label with the types. A program can have many type blocks.