Shady - experimental POSH-like engine.

Shady is a new engine using if-then rules. posh is ugly piece of code that is maintaining compatibility with the version written in lisp and later in Python. That must stop, it is not pretty (in fact, it is distasteful), it has many features that are not used (goals in competences, nested APs) and very few people even have an idea they are there (default goals and such) or even why they are there.

Our students often complain about posh, so do I. I believe that much simples tree engine with simple node structure will be easier to learn and to use. This idea was proposed by Jakub Gemrot alongside with my tasks for master thesis, but I am beat tonight, so it is time for some fun instead of productuive work.

What is difference from posh?

Grammar

fuzzy : '(' node ')'

# NAME is a string in quotes, e.g. "root" or "run on hills"
node : '(' 'node' NAME DESCR (connection)+ ')'

# priority is a call 
connection : '(' PRIORITY trigger call ')'

# Trigger is something that returns either 1 or 0 (instead of true/false)
trigger : '(' 'not' trigger ')'
           '(' 'and' (trigger)+ ')'
           '(' 'or' (trigger)+ ')'
           '(' '>' value value ')'
           '(' '>=' value value ')'
           '(' '=' value value ')'
           '(' '=<' value value ')'
           '(' '<' value value ')'
           call

# Something that returns numerical value, either parameter, constant or call
value : call
        | parameter

 
# call function and return numerical value
call : '(' NAME (PARAMETER)* ')'

parameter : argument | string | number

ARG: '*' (DIGIT)+ '*'
STRING: 
INT: 
NUMBER:

Example :   
(
    (node "root" "Root node for rabbit"
        ((fix 100)  ((hungry)) ("look for food") )
        ((fix 50)   ((succeed)) ("run around") )
        ((scared)   ((succeed)) ("run from closest enemy"))
    )
    
    (node "look for food" "Go around the forrest and look for edible stuff"
        ((fix 10) ) 
    )
)

How is target of call determined: