diff --git a/src/asl/emotions.asl b/src/asl/emotions.asl index ef56da1b..447dbfb0 100644 --- a/src/asl/emotions.asl +++ b/src/asl/emotions.asl @@ -66,7 +66,7 @@ happiness(0)[target([])]. +!rewarded(L) : true <- !!rewarded(L). // +relativised commitment --happiness(X) : ~happiness(Y) & Y>9 <- +-happiness(X) : happiness(Y) & em_threshold(Z) & Y<=Z <- -rewarded(L); -self(happy); .succeed_goal(rewarded(L)). @@ -104,7 +104,7 @@ happiness(0)[target([])]. +!punished(L) : true <- !!punished(L). // + relativised commitment --anger(X) : ~anger(Y) & Y>9 <- +-anger(X) : anger(Y) & em_threshold(Z) & Y<=Z <- -self(angry); .add_plan(helpfullness); .succeed_goal(punished(L)). \ No newline at end of file diff --git a/src/asl/general_animal.asl b/src/asl/general_animal.asl index 63e07516..486e0af6 100644 --- a/src/asl/general_animal.asl +++ b/src/asl/general_animal.asl @@ -79,12 +79,12 @@ default_activity(farm_work). @communality +!X[_] : self(communal) & is_work(X) & not already_asked(X) <- ?animals(Animals); + +already_asked(X); for (.member(Animal, Animals)) { .print("Asking ", Animal, " to help with ", X) .send(Animal, achieve, help_with(X)); +asking(X, Animal); } - +already_asked(X); .suspend(X); !X. diff --git a/src/java/little_red_hen/jason/FarmEnvironment.java b/src/java/little_red_hen/jason/FarmEnvironment.java index d6a33d14..9c886c74 100644 --- a/src/java/little_red_hen/jason/FarmEnvironment.java +++ b/src/java/little_red_hen/jason/FarmEnvironment.java @@ -5,15 +5,14 @@ import jason.asSyntax.Literal; import jason.asSyntax.Structure; -import jason.environment.Environment; -import jason.runtime.MASConsoleGUI; +import jason.environment.TimeSteppedEnvironment; import jason.util.Pair; import little_red_hen.Agent; import little_red_hen.FarmModel; import little_red_hen.Launcher; import little_red_hen.PlotGraph; -public class FarmEnvironment extends Environment { +public class FarmEnvironment extends TimeSteppedEnvironment { static Logger logger = Logger.getLogger(FarmEnvironment.class.getName()); diff --git a/src/java/little_red_hen/jason/PlotAwareAgArch.java b/src/java/little_red_hen/jason/PlotAwareAgArch.java index ee4357bb..446eca79 100644 --- a/src/java/little_red_hen/jason/PlotAwareAgArch.java +++ b/src/java/little_red_hen/jason/PlotAwareAgArch.java @@ -1,10 +1,20 @@ package little_red_hen.jason; +import java.util.Iterator; + import jason.architecture.AgArch; import jason.asSemantics.Message; +import jason.asSemantics.Unifier; +import jason.asSyntax.ASSyntax; +import jason.asSyntax.Literal; +import jason.asSyntax.Term; +import jason.asSyntax.VarTerm; +import jason.bb.BeliefBase; import little_red_hen.PlotGraph; public class PlotAwareAgArch extends AgArch { + + static int DECAY_RATE = 1; @Override public void sendMsg(Message m) throws Exception { @@ -14,5 +24,33 @@ public void sendMsg(Message m) throws Exception { // plot it in the graph PlotGraph.getPlotListener().addRequest(m.getSender(), m.getReceiver(), m.getPropCont().toString()); } +// +// @Override +// public void reasoningCycleStarting() { +// BeliefBase belief_base = getTS().getAg().getBB(); +// +// // get names of emotion scales +// Iterator em_scale_it = belief_base.getCandidateBeliefs(Literal.parseLiteral("emotion_scale(X)"), +// new Unifier()); +// +// //for each scale extract literal of form: +// // em_scale(Value)[target(_), source(_)] +// while (em_scale_it.hasNext()) { +// Literal em_scale_general = em_scale_it.next(); //has no value or annotations attached +// Literal emotion_term = Literal.parseLiteral(em_scale_general.getTerm(0).toString()); +// +// Literal em_scale_concr = belief_base.getCandidateBeliefs(emotion_term, new Unifier()).next(); +// int value = Integer.valueOf(em_scale_concr.getTerm(0).toString()); +// +// if (value > 0) { +// int new_val = Integer.min(value-DECAY_RATE, 0); +// em_scale_concr.setTerm(0, ASSyntax.parseNumber(String.valueOf(new_val))); +//// belief_base.remove(em_scale_general); +//// belief_base.add(em_scale_concr); +// } +// } +// +// super.reasoningCycleStarting(); +// } }