Commit da0b8f98 authored by Alan White's avatar Alan White

fix heli issue with overR / atJ confusion, re-order the post-effects for goal task objects

parent 1ea81489
......@@ -199,6 +199,7 @@ This is a bit of a hack, as want to stimulate goals only under certain condition
-!cargoNeededGoal(J): true
<- .print("Not adding goal", J ,",", I).
//TODO handle overJ case... land!
@lhqSecureAlreadyInPos
+!moveAndSecure(A, O, K): dangerZone(O) & dangerZone(K) & atJ(A,O) & atJ(A, K)
<- secure("militaryhq", O).
......@@ -262,7 +263,7 @@ This is a bit of a hack, as want to stimulate goals only under certain condition
//allow use of heli for overJ case...
//performs a move cargo action, then 'releases' the cargo
@moveCargo//[atomic] //args; agent, agent loc, cargo name, cargo origin, cargo destination
@moveCargo //args; agent, agent loc, cargo name, cargo origin, cargo destination
+!moveCargo(A, O, C, K, J): not busy(A) & cargoAt(C, K) & atJ(A, O) & not atJ(A, K) &
location(O) & location(K) & location(J) & cargo(C)
<- !moveAndSecure(A, O, K);
......@@ -270,14 +271,14 @@ This is a bit of a hack, as want to stimulate goals only under certain condition
!moveAndSecure(A, K, J);
unload(A, J, C).
@moveCargoAtDest//[atomic] //args; agent, agent loc, cargo name, cargo origin, cargo destination
@moveCargoAtDest //args; agent, agent loc, cargo name, cargo origin, cargo destination
+!moveCargo(A, O, C, K, J): not busy(A) & cargoAt(C, K) & atJ(A, O) & atJ(A, K) &
location(O) & location(K) & location(J) & cargo(C) & not dangerZone(K)
<- load(A, K, C);
!moveAndSecure(A, K, J);
unload(A, J, C).
@secureThenMoveCargoAtDest//[atomic] //args; agent, agent loc, cargo name, cargo origin, cargo destination
@secureThenMoveCargoAtDest //args; agent, agent loc, cargo name, cargo origin, cargo destination
+!moveCargo(A, O, C, K, J): not busy(A) & cargoAt(C, K) & atJ(A, O) & atJ(A, K) &
location(O) & location(K) & location(J) & cargo(C) & dangerZone(K)
<- secure("militaryhq", K);
......@@ -296,8 +297,8 @@ This is a bit of a hack, as want to stimulate goals only under certain condition
/*
* Special case plans for where helicopter (A) is flying over junction O at start
*/
@heliMoveCargo//[atomic] //args; agent, agent loc, cargo name, cargo origin, cargo destination
+!moveCargo(A, O, C, K, J): not busy(A) & cargoAt(C, K) & overJ(A, O) & not atJ(A, K) & flying(A) &
@heliMoveCargoOverJ
+!moveCargo(A, O, C, K, J): not busy(A) & cargoAt(C, K) & overJ(A, O) & not atJ(A, O) & not atJ(A, K) & flying(A) &
location(O) & location(K) & location(J) & cargo(C) & airport(K)
<- !moveAndSecure(A, O, K);
load(A, K, C);
......
......@@ -29,7 +29,7 @@ public class CargoworldTaskFactory extends TaskFactory {
new String[]{
"location(O) & location(J) & not mortal(AGENT) & atJ(AGENT, O)",
"connection(O) & location(J) & not mortal(AGENT) & onR(AGENT, O)"},
new String[]{"+atJ(AGENT, J)", "-onR(AGENT, O)", "-atJ(AGENT,O)"});
new String[]{"-onR(AGENT, O)", "-atJ(AGENT,O)", "-overJ(AGENT,O)", "+atJ(AGENT, J)"});
}
if(tName.equals("moveAndSecure")){
//plan to form and follow a route; applies to moveAgent capability which includes
......@@ -38,13 +38,13 @@ public class CargoworldTaskFactory extends TaskFactory {
new String[]{
"location(J1) & location(J2) & not mortal(AGENT) & atJ(AGENT, J1)",
"connection(J1) & location(J2) & not mortal(AGENT) & onR(AGENT, J1)"},
new String[]{"+atJ(AGENT, J2)", "-onR(AGENT, J1)", "-atJ(AGENT, J1)", "-dangerZone(J1)", "-dangerZone(J2)"});
new String[]{"-onR(AGENT, J1)", "-atJ(AGENT, J1)", "-dangerZone(J1)", "-dangerZone(J2)", "+atJ(AGENT, J2)"});
}
else if(tName.equals("move")) {
g = new GoalTask(
Literal.parseLiteral("move(AGENT, RID, O, J)"),
new String[]{"atJ(AGENT, O)", "onR(AGENT, RID)"},
new String[]{"+atJ(AGENT, J)", "-onR(AGENT, O)", "-atJ(AGENT,O)"}
new String[]{"-onR(AGENT, O)", "-atJ(AGENT,O)", "+atJ(AGENT, J)"}
);
}
else if(tName.equals("unblock")) {
......@@ -127,7 +127,7 @@ public class CargoworldTaskFactory extends TaskFactory {
new String[]{
"location(O) & location(K) & cargoAt(C, K) & not cargoAt(C, J) & atJ(AGENT, O)",
"connection(O) & location(K) & cargoAt(C, K) & not cargoAt(C, J) & onR(AGENT, O)"}, //c is at K
new String[]{"+cargoAt(C, J)", "-cargoAt(C, K)"}); //note; goal is move, consume is later...
new String[]{"-cargoAt(C, K)", "+cargoAt(C, J)"}); //note; goal is move, consume is later...
}
/*
+!moveAndClear(AGENT, RID, START, END): registered(AGENT) & not busy(AGENT) & blocked(RID) & not mortal(AGENT) &
......@@ -155,19 +155,19 @@ public class CargoworldTaskFactory extends TaskFactory {
else if(tName.equals("takeOff")) {
g = new GoalTask(Literal.parseLiteral("takeOff(AGENT, TO)"),
new String[]{ "atJ(AGENT, TO) & not flying(AGENT)"},
new String[]{ "+flying(AGENT)", "+atJ(AGENT,LOC)"}); //latter constrains solution length...
new String[]{ "-atJ(AGENT,TO)", "+flying(AGENT)", "+overJ(AGENT,LOC)"}); //latter constrains solution length...
}
else if(tName.equals("land")) {
g = new GoalTask(Literal.parseLiteral("land(AGENT, LOC)"),
new String[]{ "atJ(AGENT,LOC) & flying(AGENT)"},
new String[]{ "-flying(AGENT)", "+atJ(AGENT,LOC)" });//latter constrains solution length...
new String[]{ "-overJ(AGENT,LOC)","-flying(AGENT)", "+atJ(AGENT,LOC)" });//latter constrains solution length...
}
else if(tName.equals("fly")) {
g = new GoalTask(Literal.parseLiteral("fly(AGENT, END)"),
new String[]{ "flying(AGENT)" },
new String[]{ "+atJ(AGENT, END)" });
new String[]{ "+overJ(AGENT,END)", "+atJ(AGENT, END)" });
}
/*
* Hazmat goals
......@@ -176,46 +176,7 @@ public class CargoworldTaskFactory extends TaskFactory {
g = new GoalTask(Literal.parseLiteral("decontaminate(AGENT, ROAD, START, END)"),
new String[]{ "atJ(AGENT,START) & toxic(START, END)"},
new String[]{ "-toxic(START,END)", "-toxic(END, START)", "+atJ(AGENT, END)" });
}
//crane
else if(tName.equals("loadOnto")) {
g = new GoalTask(
Literal.parseLiteral("loadOnto(AGENT, J, RECIPIENT, CARGO)"),
new String[]{ "crane(AGENT) & cargo(CARGO) & vehicle(RECIPIENT) & location(J) & " +
"atJ(AGENT, J) & atJ(RECIPIENT, J) & carryingCargo(AGENT) & " +
"not dangerZone(J) & loaded(AGENT, CARGO) & not mortal(AGENT) & " +
"not carryingCargo(RECIPIENT)"},
new String[]{ "-loaded(AGENT, CARGO)", "-carryingCargo(AGENT)",
"+loaded(RECIPIENT, CARGO)", "+carryingCargo(RECIPIENT)"});
}
else if(tName.equals("unloadFrom")) {
g = new GoalTask(
Literal.parseLiteral("unloadFrom(AGENT, J, GIVER, CARGO)"),
new String[]{ "crane(AGENT) & vehicle(GIVER) & location(J) & cargo(CARGO) & " +
"not dangerZone(J) & not mortal(AGENT) & carryingCargo(AGENT) & " +
"not carryingCargo(GIVER) & loaded(AGENT, CARGO)"},
new String[]{ "+loaded(AGENT, CARGO)", "+carryingCargo(AGENT)",
"-loaded(GIVER, CARGO)", "-carryingCargo(GIVER)"});
}
//crane (composite)
/*
+!transfer(AGENT, CARGO, LOC, FROM, TO):
not busy(AGENT) & not busy(FROM) & not busy(TO) & not mortal(AGENT) & not resting(AGENT) &
not dangerZone(LOC) & cargo(CARGO) & atJ(AGENT, LOC) & atJ(FROM, LOC) & atJ(TO, LOC) &
location(LOC) & loaded(FROM, CARGO) & not carryingCargo(TO) & not carryingCargo(AGENT)
<- unloadFrom(AGENT, LOC, FROM, CARGO); loadOnto(AGENT, LOC, TO, CARGO).
*/
else if(tName.equals("transfer")) {
g = new GoalTask(
Literal.parseLiteral("transfer(AGENT, CARGO, LOC, FROM, TO)"),
new String[]{ "not busy(AGENT) & not busy(FROM) & not busy(TO) & not mortal(AGENT) & "
+ "not resting(AGENT) & not dangerZone(LOC) & cargo(CARGO) & atJ(AGENT, LOC) & "
+ "atJ(FROM, LOC) & atJ(TO, LOC) & location(LOC) & loaded(FROM, CARGO) & "
+ "not carryingCargo(TO) & not carryingCargo(AGENT)"},
new String[]{ "+loaded(TO, CARGO)", "+carryingCargo(TO)",
"-loaded(FROM, CARGO)", "-carryingCargo(FROM)"});
}
/*
}/*
* Mil Hq (composite) goals
*/
//send a hazmat unit stationed at AGST and clear the road from RoadSt to RoadEnd
......
......@@ -36,7 +36,7 @@ public class UniversalConstants {
FAILURE_CHANCE_LOGGER_LEVEL = Level.FINE,
MP_LOGGING_LEVEL = Level.OFF,
MT_LOGGING_LEVEL = Level.OFF,
SIM_LOGGER_LEVEL = Level.OFF;
SIM_LOGGER_LEVEL = Level.INFO;
/**
* Configures whether or not any debug-specific stuff is done.
......
......@@ -103,7 +103,7 @@ public class Cargoworld extends Environment {
* MS time; if INACTIVITY_TIME has passed since last action, agents are
* deemed as idle
*/
public static final long INACTIVITY_TIMEOUT_PERIOD = 500;
public static final long INACTIVITY_TIMEOUT_PERIOD = 1500;
/**
* Time last action was attempted/completed
......
......@@ -465,12 +465,12 @@ public class WorldUi extends JFrame implements WindowListener, ActionListener {
Vector<String> vS = new Vector<String>();
for (String agKey : env.getVehicles().keySet()) {
Vehicle ag = (Vehicle) env.getVehicles().get(agKey);
if (ag.getHealth().equals(HealthState.damaged)) {
vS.add(ag.getId() + "(D)");
} else if (ag.getHealth().equals(HealthState.mortal)) {
vS.add(ag.getId() + "(M)");
} else {
vS.add(ag.getId());
if(ag == null) {
vS.add(agKey + "(not existing!)");
}
else {
vS.add(ag.getId() + (ag.getHealth().equals(HealthState.damaged)?"(D)":
(ag.getHealth().equals(HealthState.mortal)?"(M)":"")));
}
}
Collections.sort(vS);
......
......@@ -102,7 +102,7 @@ public class Watchdog implements Runnable {
}
else {
env.addDisplayString("Generating a new cargo demand - timeout");
logger.severe("Generating a new cargo demand - timeout");
logger.severe("Generating a new cargo demand - timeout - last action was " + env.getLastActionLiteral() + ":" + env.getLastActionResult());
if(demandsGenerated>0 && env.getLastActionResult().equals(ActionResult.pass) && !env.getLastActionLiteral().getFunctor().equals("consume") ) {
logger.severe("Timeout despite successful last action (" + env.getLastActionLiteral() + ")!");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment