Created
March 16, 2010 01:53
-
-
Save adamtaylor/333560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void updatePercepts() { | |
// manual hack to work(?) for all the taxi agent | |
for(int i = 0;i<3;i++) { | |
int j = i + 1; | |
String name = "taxi" + j; | |
clearPercepts(name); | |
// get the robot location | |
Location lTaxi = model.getAgPos(i); | |
logger.info("taxi - "+name+ " - is at: "+lTaxi.x+" "+lTaxi.y); | |
// add agent location to its percepts | |
if (lTaxi.equals(model.lTaxiRank)) { | |
logger.info("taxi - "+name+ " - is at taxi rank"); | |
addPercept(name, at); | |
} | |
if (lTaxi.equals(model.lCinema)) { | |
addPercept(name, ac); | |
} | |
} | |
} | |
@Override | |
synchronized public boolean executeAction(String ag, Structure action) { | |
logger.info("["+ag+"] doing: "+action); | |
boolean result = false; | |
int agInt = Integer.parseInt(ag.substring(4,5)); | |
agInt = agInt - 1; | |
logger.info("agInt: "+agInt); | |
if (action.getFunctor().equals("move_towards")) { | |
String l = action.getTerm(0).toString(); | |
Location dest = null; | |
if (l.equals("taxirank")) { | |
dest = model.lTaxiRank; | |
} else if (l.equals("cinema")) { | |
dest = model.lCinema; | |
} | |
try { | |
result = model.moveTowards(dest,agInt); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
// rest of method... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment