Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions agentspeak/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ def add_belief(self, term, scope):
if term.functor is None:
raise AslError("expected belief literal")

# Add source(self) annotation if not already present
has_source = any(ann.functor == "source" for ann in term.annots)
if not has_source:
term = term.with_annotation(
agentspeak.Literal("source", (agentspeak.Literal("self"), ))
)

self.beliefs[(term.functor, len(term.args))].add(term)

def test_belief(self, term, intention):
Expand Down
3 changes: 2 additions & 1 deletion agentspeak/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def _fail(agent, term, intention):
@actions.add(".my_name", 1)
@agentspeak.optimizer.function_like
def _my_name(agent, term, intention):
if agentspeak.unify(term.args[0], Literal(agent.name), intention.scope, intention.stack):
# MRP: sustituido Literal(agent.name) por str(agent.name).
if agentspeak.unify(term.args[0], str(agent.name), intention.scope, intention.stack):
yield


Expand Down
4 changes: 2 additions & 2 deletions examples/counting/counting.asl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ max_count(5).
-+actual_count(NewCount);
!count.

+!count : actual_count(X) & max_count(Y) & X >= Y. /*
+!count : actual_count(X) & max_count(Y) & X >= Y <-
.my_name(Name);
.print(Name, " terminated count"). */
.print(Name, " terminated count").