python-agentspeak
                                
                                
                                
                                    python-agentspeak copied to clipboard
                            
                            
                            
                        Explanation freeze, grounded and intention.scope
Hi Niklas,
could you briefly explain what freezing a literal means and what part the intention scope plays? Does intention scope refer to the context which describes where a goal was raised? Is it possible to transfer the intention.scope to python so that when adding achievement goals or beliefs the scope can be heeded?
What does 'ground' refer to?
I looked the mentioned things up in the source code and googled everything but I don't get it so far. 😬
Thank you! :) Cornelius
This really needs some documentation.
scope is a dictionary that maps variables to their current bindings. Other than passing it to APIs that expect it, you should rarely have to deal with it directly. It will contain all variables that have been bound in the goal context, and all bindings that have been added in plan steps so far.
A ground expression is an expression with no free variables. For example foo(bar, 3) is uncondtionally ground. foo(X) is not ground (assuming that X hasn't been bound in the current scope).
agentspeak.is_ground(expression, scope) checks if an expression is ground in the current scope.
agentspeak.grounded(expression, scope) asserts that the expression is ground in the current scope and then substitutes all variables with values from the current scope.
Examples:
>>> import agentspeak
>>>
>>> X = agentspeak.Var()
>>>
>>> agentspeak.is_ground(X, {})
False
>>> agentspeak.is_ground(X, {X: 3})
True
>>> agentspeak.grounded(X, {})
agentspeak.AslError: term not ground
>>> agentspeak.grounded(X, {X: 3})
3
Freeze substitutes all variables from a given scope into the expression and evaluates it as far as possible. If free variables remain, it returns a structurally identical but independent copy. If you want to make a snapshot of an expression in the current scope, this is more efficient and more convenient than copying the entire scope.
On ground expressions, freeze is identical to grounded.
If anything is unclear, please ask for clarification.
Is it possible to transfer the intention.scope to python so that when adding achievement goals or beliefs the scope can be heeded?
Sorry, not sure I understand this question.
Hey Niklas,
thank you for the explanations, that helps a lot already. I am using my fork of the spade_bdi plugin for spade that is built on python-agentspeak. Some functionalities I need aren't included there so I write them and therefore need to interface with more low level parts of python-agentspeak.
Is it possible to transfer the intention.scope to python so that when adding achievement goals or beliefs the scope can be heeded?
Sorry, not sure I understand this question.
I misunderstood what the intention scope is and thought that there was a way of adding context to a belief. I didn't know that the scope refers to variables and their bindings.