|
From: <jom...@us...> - 2010-07-22 13:57:01
|
Revision: 1604
http://jason.svn.sourceforge.net/jason/?rev=1604&view=rev
Author: jomifred
Date: 2010-07-22 13:56:55 +0000 (Thu, 22 Jul 2010)
Log Message:
-----------
add a method in environment to consult the percept list of agents
Modified Paths:
--------------
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/environment/Environment.java
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2010-07-03 20:38:32 UTC (rev 1603)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2010-07-22 13:56:55 UTC (rev 1604)
@@ -518,7 +518,7 @@
//System.out.println("*** "+bTerm+"="+bValue+" "+bTerm.isGround()+" "+u);
if (bValue == null) { // the case of !A with A not ground
String msg = h.getSrcInfo()+": "+ "Variable '"+bTerm+"' must be ground.";
- if (!generateGoalDeletion(conf.C.SI, JasonException.createBasicErrorAnnots("body_var_unground", msg)))
+ if (!generateGoalDeletion(conf.C.SI, JasonException.createBasicErrorAnnots("body_var_without_value", msg)))
logger.log(Level.SEVERE, msg);
return;
}
Modified: trunk/src/jason/environment/Environment.java
===================================================================
--- trunk/src/jason/environment/Environment.java 2010-07-03 20:38:32 UTC (rev 1603)
+++ trunk/src/jason/environment/Environment.java 2010-07-22 13:56:55 UTC (rev 1604)
@@ -140,8 +140,14 @@
/**
* Returns percepts for an agent. A full copy of both common
* and agent's percepts lists is returned.
+ *
+ * It returns null if the agent's perception doesn't changed since
+ * last call.
+ *
+ * This method is to be called by TS and should not be called
+ * by other objects.
*/
- public List<Literal> getPercepts(String agName) {
+ public List<Literal> getPercepts(String agName) { // TODO in a future release, call this method doPerception, and get simply returns the list
// check whether this agent needs the current version of perception
if (uptodateAgs.contains(agName)) {
@@ -172,7 +178,36 @@
return p;
}
-
+
+ /**
+ * Returns a copy of the perception for an agent.
+ *
+ * It is the same list returned by getPercepts, but
+ * doesn't consider the last call of the method.
+ */
+ public List<Literal> consultPercepts(String agName) {
+ int size = percepts.size();
+ List<Literal> agl = agPercepts.get(agName);
+ if (agl != null) {
+ size += agl.size();
+ }
+ List<Literal> p = new ArrayList<Literal>(size);
+
+ if (! percepts.isEmpty()) { // has global perception?
+ synchronized (percepts) {
+ // make a local copy of the environment percepts
+ // Note: a deep copy will be done by BB.add
+ p.addAll(percepts);
+ }
+ }
+ if (agl != null) { // add agent personal perception
+ synchronized (agl) {
+ p.addAll(agl);
+ }
+ }
+ return p;
+ }
+
/** Adds a perception for all agents */
public void addPercept(Literal per) {
if (per != null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|