Details
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/AgentStarter.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/AgentStarter.java
index a29db1c..f15384b 100644
--- a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/AgentStarter.java
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/AgentStarter.java
@@ -38,7 +38,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
-import br.ufrgs.inf.bdi4jade.examples.helloworld.HelloWorldAgent;
+import br.ufrgs.inf.bdi4jade.examples.template.MyAgent;
/**
* @author ingrid
@@ -50,9 +50,11 @@ public class AgentStarter {
static {
agents = new HashMap<String, Agent>();
- agents.put(HelloWorldAgent.class.getSimpleName(), new HelloWorldAgent());
+ // agents.put(HelloWorldAgent.class.getSimpleName(), new
+ // HelloWorldAgent());
// agents.put(BDIAgent1.MY_NAME, new BDIAgent1());
// agents.put(BDIAgent2.MY_NAME, new BDIAgent2());
+ agents.put(MyAgent.class.getSimpleName(), new MyAgent());
};
public static void main(String[] args) {
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/helloworld/HelloWorldPlan.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/helloworld/HelloWorldPlan.java
index 3cee61f..64760c8 100644
--- a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/helloworld/HelloWorldPlan.java
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/helloworld/HelloWorldPlan.java
@@ -30,5 +30,6 @@ public class HelloWorldPlan extends OneShotBehaviour implements PlanBody {
public void init(PlanInstance planInstance) {
this.name = ((HelloWorldGoal) planInstance.getGoal()).getName();
+ this.endState = null;
}
}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/ping/PongPlan.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/ping/PongPlan.java
index 8463982..4ac0e98 100644
--- a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/ping/PongPlan.java
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/ping/PongPlan.java
@@ -66,6 +66,7 @@ public class PongPlan extends OneShotBehaviour implements PlanBody {
this.log = LogFactory.getLog(this.getClass());
MessageGoal goal = (MessageGoal) planInstance.getGoal();
pingMsg = goal.getMessage();
+ this.endState = null;
}
}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/planselection/TransportationPlanBody.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/planselection/TransportationPlanBody.java
index 0a21531..a179f2e 100644
--- a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/planselection/TransportationPlanBody.java
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/planselection/TransportationPlanBody.java
@@ -129,5 +129,6 @@ public class TransportationPlanBody extends OneShotBehaviour implements
.getValue();
this.preferences = (SoftgoalPreferences) planInstance.getBeliefBase()
.getBelief(SoftgoalPreferences.NAME);
+ this.endState = null;
}
}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/Constants.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/Constants.java
new file mode 100644
index 0000000..dbd7563
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/Constants.java
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template;
+
+import br.ufrgs.inf.bdi4jade.softgoal.NamedSoftgoal;
+import br.ufrgs.inf.bdi4jade.softgoal.Softgoal;
+
+/**
+ * @author ingrid
+ *
+ */
+public interface Constants {
+
+ // Softgoals
+ public static final Softgoal COMFORT = new NamedSoftgoal("COMFORT");
+ public static final Softgoal COST = new NamedSoftgoal("COST");
+ public static final Softgoal PERFORMANCE = new NamedSoftgoal("PERFORMANCE");
+ public static final Softgoal SAFETY = new NamedSoftgoal("SAFETY");
+ public static final Softgoal SECURITY = new NamedSoftgoal("SECURITY");
+
+ public static final Softgoal ALL_SOFTGOALS[] = { COMFORT, COST,
+ PERFORMANCE, SAFETY, SECURITY };
+
+}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/goal/MyGoal.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/goal/MyGoal.java
new file mode 100644
index 0000000..047846d
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/goal/MyGoal.java
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template.goal;
+
+import br.ufrgs.inf.bdi4jade.goal.Goal;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyGoal implements Goal {
+
+ private static final long serialVersionUID = -659551255690904618L;
+
+}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/MyAgent.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/MyAgent.java
new file mode 100644
index 0000000..d07970e
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/MyAgent.java
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template;
+
+import br.ufrgs.inf.bdi4jade.examples.template.goal.MyGoal;
+import br.ufrgs.inf.bdi4jade.examples.template.plan.MyPlan1;
+import br.ufrgs.inf.bdi4jade.examples.template.plan.MyPlan2;
+import br.ufrgs.inf.bdi4jade.preference.SoftgoalPreferences;
+import br.ufrgs.inf.bdi4jade.softgoal.Softgoal;
+import br.ufrgs.inf.bdi4jade.util.agent.UtilityBasedBDIAgent;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyAgent extends UtilityBasedBDIAgent {
+
+ private static final long serialVersionUID = 2712019445290687786L;
+
+ public MyAgent() {
+
+ }
+
+ protected void init() {
+ for (Softgoal softgoal : Constants.ALL_SOFTGOALS) {
+ this.addSoftgoal(softgoal);
+ }
+
+ this.getRootCapability().getPlanLibrary().addPlan(new MyPlan1());
+ this.getRootCapability().getPlanLibrary().addPlan(new MyPlan2());
+
+ initPreferences();
+
+ addGoal(new MyGoal());
+ }
+
+ public void initPreferences() {
+ SoftgoalPreferences preferences = (SoftgoalPreferences) this
+ .getRootCapability().getBeliefBase()
+ .getBelief(SoftgoalPreferences.NAME);
+
+ preferences.setPreferenceForSoftgoal(Constants.COMFORT, 0.1);
+ preferences.setPreferenceForSoftgoal(Constants.COST, 0.2);
+ preferences.setPreferenceForSoftgoal(Constants.PERFORMANCE, 0.15);
+ preferences.setPreferenceForSoftgoal(Constants.SAFETY, 0.4);
+ preferences.setPreferenceForSoftgoal(Constants.SECURITY, 0.15);
+ }
+
+}
\ No newline at end of file
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1.java
new file mode 100644
index 0000000..7e821a6
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1.java
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template.plan;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import br.ufrgs.inf.bdi4jade.examples.planselection.Softgoals;
+import br.ufrgs.inf.bdi4jade.examples.template.goal.MyGoal;
+import br.ufrgs.inf.bdi4jade.plan.PlanContribution;
+import br.ufrgs.inf.bdi4jade.softgoal.Softgoal;
+import br.ufrgs.inf.bdi4jade.util.plan.SimplePlan;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyPlan1 extends SimplePlan {
+
+ public MyPlan1() {
+ super(MyGoal.class, MyPlan1Body.class);
+
+ Map<Softgoal, List<PlanContribution>> contributions = (Map<Softgoal, List<PlanContribution>>) getMetadata(DefaultMetadata.CONTRIBUTIONS);
+
+ List<PlanContribution> sgContributions = null;
+
+ sgContributions = new ArrayList<PlanContribution>();
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.6, 0.0));
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.4, 1.0));
+ contributions.put(Softgoals.SAFETY, sgContributions);
+
+ sgContributions = new ArrayList<PlanContribution>();
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.2, 0.0));
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.8, 1.0));
+ contributions.put(Softgoals.PERFORMANCE, sgContributions);
+ }
+
+}
\ No newline at end of file
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1Body.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1Body.java
new file mode 100644
index 0000000..0b16e47
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan1Body.java
@@ -0,0 +1,39 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template.plan;
+
+import jade.core.behaviours.OneShotBehaviour;
+import br.ufrgs.inf.bdi4jade.plan.PlanBody;
+import br.ufrgs.inf.bdi4jade.plan.PlanInstance;
+import br.ufrgs.inf.bdi4jade.plan.PlanInstance.EndState;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyPlan1Body extends OneShotBehaviour implements PlanBody {
+
+ private static final long serialVersionUID = -3947024373151941681L;
+
+ private EndState endState;
+
+ @Override
+ public void action() {
+ // TODO Auto-generated method stub
+ this.endState = EndState.SUCCESSFUL;
+ }
+
+ @Override
+ public EndState getEndState() {
+ // TODO Auto-generated method stub
+ return endState;
+ }
+
+ @Override
+ public void init(PlanInstance planInstance) {
+ // TODO Auto-generated method stub
+ this.endState = null;
+ }
+
+}
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2.java
new file mode 100644
index 0000000..964efd8
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2.java
@@ -0,0 +1,39 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template.plan;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import br.ufrgs.inf.bdi4jade.examples.planselection.Softgoals;
+import br.ufrgs.inf.bdi4jade.examples.template.goal.MyGoal;
+import br.ufrgs.inf.bdi4jade.plan.PlanContribution;
+import br.ufrgs.inf.bdi4jade.softgoal.Softgoal;
+import br.ufrgs.inf.bdi4jade.util.plan.SimplePlan;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyPlan2 extends SimplePlan {
+
+ public MyPlan2() {
+ super(MyGoal.class, MyPlan2Body.class);
+
+ Map<Softgoal, List<PlanContribution>> contributions = (Map<Softgoal, List<PlanContribution>>) getMetadata(DefaultMetadata.CONTRIBUTIONS);
+ List<PlanContribution> sgContributions = null;
+
+ sgContributions = new ArrayList<PlanContribution>();
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.3, 0.0));
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.7, 1.0));
+ contributions.put(Softgoals.SAFETY, sgContributions);
+
+ sgContributions = new ArrayList<PlanContribution>();
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.5, 0.0));
+ sgContributions.add(new PlanContribution(Softgoals.SAFETY, 0.5, 1.0));
+ contributions.put(Softgoals.PERFORMANCE, sgContributions);
+ }
+
+}
\ No newline at end of file
diff --git a/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2Body.java b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2Body.java
new file mode 100644
index 0000000..4bd3f38
--- /dev/null
+++ b/bdi-jade-test/src/br/ufrgs/inf/bdi4jade/examples/template/plan/MyPlan2Body.java
@@ -0,0 +1,39 @@
+/**
+ *
+ */
+package br.ufrgs.inf.bdi4jade.examples.template.plan;
+
+import jade.core.behaviours.OneShotBehaviour;
+import br.ufrgs.inf.bdi4jade.plan.PlanBody;
+import br.ufrgs.inf.bdi4jade.plan.PlanInstance;
+import br.ufrgs.inf.bdi4jade.plan.PlanInstance.EndState;
+
+/**
+ * @author ingrid
+ *
+ */
+public class MyPlan2Body extends OneShotBehaviour implements PlanBody {
+
+ private static final long serialVersionUID = -3947024373151941681L;
+
+ private EndState endState;
+
+ @Override
+ public void action() {
+ // TODO Auto-generated method stub
+ this.endState = EndState.SUCCESSFUL;
+ }
+
+ @Override
+ public EndState getEndState() {
+ // TODO Auto-generated method stub
+ return endState;
+ }
+
+ @Override
+ public void init(PlanInstance planInstance) {
+ // TODO Auto-generated method stub
+ this.endState = null;
+ }
+
+}