|
From: <jom...@us...> - 2008-04-30 17:21:34
|
Revision: 1281
http://jason.svn.sourceforge.net/jason/?rev=1281&view=rev
Author: jomifred
Date: 2008-04-30 10:21:29 -0700 (Wed, 30 Apr 2008)
Log Message:
-----------
jason team: several changes!
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-moise/src/jmoise/broadcast.java
trunk/applications/jason-team/AC-Local-Dummies.mas2j
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/dummies.xml
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/test/MindView.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -17,21 +17,40 @@
// defines the agent's AgentSpeak code
ag.parseAScode(
"b(1). "+
+ "p(1,a). p(2,a). p(3,b). p(4,b). p(6,a). "+
"+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
- "+!test2 <- L=4; .while( .count(b(_)) < L, { ?b(X); +b(X+1) }); jason.asunit.print(end)."
+ "+!test2 <- L=4; .while( .count(b(_)) < L, { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
+
+ "+!test3 <- L=4; .for( p(N,a) & N < L, { jason.asunit.print(N) }); jason.asunit.print(end). "+
+
+ "+!test4 <- .for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
);
}
@Test
- public void test1() {
+ public void testWhile1() {
ag.addGoal("test1");
ag.assertBel("b(4)", 20);
}
@Test
- public void test2() {
+ public void testWhile2() {
ag.addGoal("test2");
ag.assertBel("b(4)", 30);
}
+
+ @Test
+ public void testFor1() {
+ ag.addGoal("test3");
+ ag.assertPrint("2", 10);
+ ag.assertPrint("end", 10);
+ }
+
+ @Test
+ public void testFor2() {
+ ag.addGoal("test4");
+ ag.assertPrint("4", 10);
+ ag.assertPrint("end", 10);
+ }
}
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -194,10 +194,10 @@
}
// notify others in the group about this new player
- updateMembersOE(gr.getAgentsInThisGroupAndSubGroups(), "play(" + sender + "," + roleId + "," + grId + ")", true, true);
+ updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", true, true);
// send players of this group to sender
- for (RolePlayer rp : gr.getPlayers()) {
+ for (RolePlayer rp : gr.getPlayers(null, true)) {
if (!rp.getPlayer().getId().equals(sender)) {
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + grId + ")", false, true);
}
@@ -216,7 +216,7 @@
GroupInstance gr = currentOE.findGroup(grId);
// notify other players
- updateMembersOE(gr.getAgentsInThisGroupAndSubGroups(), "play(" + sender + "," + roleId + "," + grId + ")", false, false);
+ updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", false, false);
}
}
Modified: trunk/applications/jason-moise/src/jmoise/broadcast.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/broadcast.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-moise/src/jmoise/broadcast.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -58,7 +58,7 @@
// try group
GroupInstance gi = oag.getOE().findGroup(target.toString());
if (gi != null) {
- for (OEAgent ag: gi.getAgents()) {
+ for (OEAgent ag: gi.getAgents(true)) {
if (!ag.getId().equals(oag.getAgName())) {
oag.sendMsg(new Message(ilf.toString(), null, ag.getId(), pcnt));
}
Modified: trunk/applications/jason-team/AC-Local-Dummies.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
@@ -15,32 +15,32 @@
host="localhost", port=12300, username=botagent1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy2 dummy.asl
[verbose=1,host="localhost", port=12300, username=botagent2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy3 dummy.asl
[verbose=1,host="localhost", port=12300, username=botagent3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy4 dummy.asl
[verbose=1,host="localhost", port=12300, username=botagent4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy5 dummy.asl
[verbose=1,host="localhost", port=12300, username=botagent5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy6 dummy.asl
[verbose=1,host="localhost", port=12300, username=botagent6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
aslSourcePath: "src/asl";
}
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
@@ -19,32 +19,32 @@
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
gaucho2 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
gaucho3 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
gaucho4 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
gaucho5 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
gaucho6 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
aslSourcePath: "src/asl";
Modified: trunk/applications/jason-team/dummies.xml
===================================================================
--- trunk/applications/jason-team/dummies.xml 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/dummies.xml 2008-04-30 17:21:29 UTC (rev 1281)
@@ -27,9 +27,9 @@
<!-- tasks the user can override in his/her c-build.xml script -->
<target name="user-init">
+ <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
<copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
<copy file="../jason-moise/lib/moise.jar" todir="lib" />
- <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
</target>
<target name="user-end">
</target>
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/gauchos.xml 2008-04-30 17:21:29 UTC (rev 1281)
@@ -27,9 +27,14 @@
<!-- tasks the user can override in his/her c-build.xml script -->
<target name="user-init">
+ <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
<copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
<copy file="../jason-moise/lib/moise.jar" todir="lib" />
- <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
+
+ <mkdir dir="tmp-ag-mind" />
+ <!--delete failonerror="no" includeEmptyDirs="true" verbose="false">
+ <fileset dir="tmp-ag-mind" includes="*.xml"/>
+ </delete-->
</target>
<target name="user-end">
</target>
@@ -98,6 +103,13 @@
<antcall target="user-end" />
</target>
+ <target name="mind-view" depends="compile" >
+ <java classname="test.MindView" failonerror="true" fork="yes" dir="${basedir}" >
+ <classpath refid="project.classpath"/>
+ <arg line="0"/>
+ </java>
+ </target>
+
<target name="clean" >
<delete failonerror="no" includeEmptyDirs="true" verbose="true">
<fileset dir="${basedir}" includes="**/*.class"/>
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-30 17:21:29 UTC (rev 1281)
@@ -7,11 +7,11 @@
steps(MaxSteps)
corral(UpperLeft.x,UpperLeft.y,DownRight.x,DownRight.y)
- Step:
+ Each step:
pos(X,Y,Step)
- cell(X,Y,Type)
- Type in { cow(Id), ally(Name), enemy(Id) }
- // the Id of enemy is not working
+ cow(Id,X,Y)
+ apply_pos(Name,X,Y)
+
End:
end_of_simulation(Result)
@@ -52,10 +52,6 @@
<- !decide_target.
-// add all cows in BB (used by the arch)
-+cell(X,Y,cow(_)) <- +cow(X,Y).
--cell(X,Y,cow(_)) <- -cow(X,Y).
-
/* -- decide a new target -- */
+!decide_target
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-30 17:21:29 UTC (rev 1281)
@@ -5,11 +5,10 @@
steps(MaxSteps)
corral(UpperLeft.x,UpperLeft.y,DownRight.x,DownRight.y)
- Step:
+ Each step:
pos(X,Y,Step)
- cell(X,Y,Type)
- Type in { cow(Id), ally(Name), enemy(Id) }
- // the Id of enemy is not working
+ cow(Id,X,Y)
+ apply_pos(Name,X,Y)
End:
end_of_simulation(Result)
@@ -94,16 +93,12 @@
+!share_seen_cows.
// simple implementation of share_cows (see TODO above)
-+cell(X,Y,cow(_))[source(percept)]
++cow(Id,X,Y)[source(percept)]
: .my_name(Me) & play(Me,_,Gr)
- <- C = cow(X,Y);
- +C;
- jmoise.broadcast(Gr, tell, C).
--cell(X,Y,cow(_))[source(percept)]
+ <- jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
+-cow(Id,X,Y)[source(percept)]
: .my_name(Me) & play(Me,_,Gr)
- <- C = cow(X,Y);
- -C;
- jmoise.broadcast(Gr, untell, C).
+ <- jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -139,6 +139,7 @@
Lock lock = new ReentrantLock();
Condition cycle = lock.newCondition();
long timestartcycle = 0;
+ long timeLastAction = 0;
int cycleCounter = 0;
@@ -183,13 +184,13 @@
w = "*** ";
}
- long timetoact = 0;
- if (timestartcycle > 0) {
- timetoact = System.currentTimeMillis() - timestartcycle;
+ String timetoact = ". ";
+ if (lastActionInCurrentCycle != null && timestartcycle > 0) {
+ timetoact = " (act in "+ (timeLastAction - timestartcycle) +" ms)";
}
timestartcycle = System.currentTimeMillis();
- logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getCycle()+ " (act in "+timetoact+" ms). "+notsent);
+ logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getCycle()+ timetoact + notsent);
setLastAct(lastActionInCurrentCycle);
lastActionInCurrentCycle = null;
}
@@ -213,7 +214,7 @@
}
@Override
- synchronized public void run() {
+ public void run() {
while (true) {
try {
lastAction = null;
@@ -222,6 +223,7 @@
lastActionInCurrentCycle = lastAction.getActionTerm().getTerm(0).toString();
proxy.sendAction(lastActionInCurrentCycle);
toExecute.offer(lastAction);
+ timeLastAction = System.currentTimeMillis();
}
} catch (InterruptedException e) {
return; // condition to stop the thread
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -2,7 +2,6 @@
import jason.asSyntax.Literal;
import jason.asSyntax.NumberTermImpl;
-import jason.asSyntax.Structure;
import jason.environment.grid.Location;
import java.util.ArrayList;
@@ -157,7 +156,8 @@
arq.initKnownCows();
- int enemyId = 1;
+ //int enemyId = 1;
+
// add in perception what is around
NodeList nl = perception.getElementsByTagName("cell");
for (int i=0; i < nl.getLength(); i++) {
@@ -178,17 +178,17 @@
// allies are managed by communication
//percepts.add(CowboyArch.createCellPerception(cellx, celly, CowboyArch.aALLY));
} else if (type.getAttribute("type").equals("enemy")) {
- Structure le = new Literal("enemy");
- le.addTerm(new NumberTermImpl( (enemyId++) )); // we need an id to work with UniqueBB
- percepts.add(CowboyArch.createCellPerception(cellx, celly, le));
+ //Structure le = new Literal("enemy");
+ //le.addTerm(new NumberTermImpl( (enemyId++) )); // we need an id to work with UniqueBB
+ //percepts.add(CowboyArch.createCellPerception(cellx, celly, le));
arq.enemyPerceived(absx, absy);
}
} else if (type.getNodeName().equals("cow")) {
int cowId = Integer.parseInt(type.getAttribute("ID"));
- Structure lc = new Literal("cow");
- lc.addTerm(new NumberTermImpl( cowId ));
- percepts.add(CowboyArch.createCellPerception(absx, absy, lc));
+ Literal lc = new Literal("cow");
+ lc.addTerms(new NumberTermImpl( cowId ), new NumberTermImpl( absx), new NumberTermImpl(absy));
+ percepts.add( lc); //CowboyArch.createCellPerception(absx, absy, lc));
//arq.cowPerceived(absx, absy);
} else if (type.getNodeName().equals("obstacle")) {
@@ -208,7 +208,7 @@
arq.startNextStep(step, percepts);
//if (logger.isLoggable(Level.FINE))
- logger.info("Request action for "+lpos+" / percepts: "+percepts);
+ logger.info("Request action for "+lpos+" / rid: "+rid+" / percepts: "+percepts);
} catch (Exception e) {
logger.log(Level.SEVERE, "error processing request",e);
}
@@ -216,7 +216,7 @@
public void sendAction(String action) {
try {
- logger.info("sending action "+action+" for step "+rid+" at "+arq.model.getAgPos(arq.getMyId()) );
+ logger.info("sending action "+action+" for rid "+rid+" at "+arq.model.getAgPos(arq.getMyId()) );
Document doc = documentbuilder.newDocument();
Element el_response = doc.createElement("message");
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -225,7 +225,7 @@
protected void addRestart() {
try {
logger.info("** Arch adding restart for "+getAgName());
- getTS().getC().create();
+ //getTS().getC().create();
getTS().getC().addAchvGoal(new Literal("restart"), Intention.EmptyInt);
lo2 = new Location(-1,-1); // to not restart again in the next cycle
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -93,7 +93,7 @@
return cows;
}
- private static final Literal cowLiteral = Literal.parseLiteral("cow(_,_)");
+ private static final Literal cowLiteral = Literal.parseLiteral("cow(Id,X,Y)");
private void updateCowsFromBB() {
if (bb == null) return;
@@ -112,8 +112,8 @@
if (i != null) {
while (i.hasNext()) {
Literal c = i.next();
- int x = (int)((NumberTerm)c.getTerm(0)).solve();
- int y = (int)((NumberTerm)c.getTerm(1)).solve();
+ int x = (int)((NumberTerm)c.getTerm(1)).solve();
+ int y = (int)((NumberTerm)c.getTerm(2)).solve();
addCow(x,y);
}
}
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-30 15:33:32 UTC (rev 1280)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -1,7 +1,10 @@
package arch;
import jason.environment.grid.Location;
+import jason.util.asl2xml;
+import java.io.File;
+import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
@@ -54,6 +57,14 @@
reset();
String fileName = "world-status.txt";
+ File dirmind = null;
+ try {
+ dirmind = new File("tmp-ag-mind");
+ dirmind.mkdir();
+ } catch (Exception e) {
+ dirmind = null;
+ }
+
PrintWriter out = null;
try {
out = new PrintWriter(fileName);
@@ -85,6 +96,15 @@
}
}
}
+
+ // store the agent'd mind
+ if (dirmind != null) {
+ String agmind = new asl2xml().transform(owner.getTS().getAg().getAgState());
+ FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+owner.getCycle()+".xml"));
+ outmind.write(agmind);
+ outmind.close();
+ }
+
logger.info(s.toString());
out.println(s.toString());
out.flush();
Added: trunk/applications/jason-team/src/java/test/MindView.java
===================================================================
--- trunk/applications/jason-team/src/java/test/MindView.java (rev 0)
+++ trunk/applications/jason-team/src/java/test/MindView.java 2008-04-30 17:21:29 UTC (rev 1281)
@@ -0,0 +1,136 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://www.dur.ac.uk/r.bordini
+// http://www.inf.furb.br/~jomi
+//
+//----------------------------------------------------------------------------
+
+package test;
+
+import jason.util.asl2html;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+import javax.swing.SwingUtilities;
+import javax.swing.border.TitledBorder;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+
+public class MindView {
+
+ public static void main(String[] args) throws Exception {
+ new MindView(Integer.parseInt(args[0]));
+ }
+
+ private int step = 1;
+ private asl2html agTransformerHtml = new asl2html("/xml/agInspection.xsl");
+ private DocumentBuilder builder;
+
+
+ public MindView(int step) throws ParserConfigurationException {
+ this.step = step;
+ builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ initComponents();
+ show();
+ }
+
+ // Interface components
+ JTextPane jTA = null;
+ JFrame frame;
+
+ void initComponents() {
+ frame = new JFrame();
+
+ JButton jBtNext = new JButton("Next");
+ jBtNext.setEnabled(true);
+ jBtNext.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step++;
+ show();
+ }
+ });
+ }
+ });
+ JButton jBtPrev = new JButton("Previous");
+ jBtPrev.setEnabled(true);
+ jBtPrev.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step--;
+ show();
+ }
+ });
+ }
+ });
+
+ jTA = new JTextPane();
+ jTA.setEditable(false);
+ jTA.setContentType("text/html");
+ jTA.setAutoscrolls(false);
+
+ JPanel spTA = new JPanel(new BorderLayout());
+ spTA.add(BorderLayout.CENTER, new JScrollPane(jTA));
+ spTA.setBorder(BorderFactory.createTitledBorder(BorderFactory
+ .createEtchedBorder(), "Agent Inspection", TitledBorder.LEFT, TitledBorder.TOP));
+
+ JPanel pAg = new JPanel(new BorderLayout());
+ pAg.add(BorderLayout.CENTER, spTA);
+
+
+ JPanel pButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ pButtons.add(jBtPrev);
+ pButtons.add(jBtNext);
+
+ frame.getContentPane().add(BorderLayout.SOUTH, pButtons);
+ frame.getContentPane().add(BorderLayout.CENTER, pAg);
+ frame.pack();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ int height = (int)(screenSize.height * 0.618);
+ frame.setBounds(80, 30, (int)(height*1.2), height);
+
+ frame.setVisible(true);
+ }
+
+ private void show() {
+ try {
+ frame.setTitle(":: Jason Mind Inspector :: "+step+" ::");
+ Document agState = builder.parse("tmp-ag-mind/"+step+".xml");
+ jTA.setText(agTransformerHtml.transform(agState));
+ } catch (Exception et) {
+ et.printStackTrace();
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|