* @return string problem
*/
public static String generateDiscoveringBurglarProblem(GameMap map) {
StringBuilder builder = new StringBuilder();
Burglar burglar = map.getBurglar();
// generate the header:
builder.append("(define (problem burglar)\n");
builder.append("\t(:domain burglar)\n");
// ----------------------------
// list the objects:
builder.append(STR_TAG_OBJECTS);
// sort positions by type:
List<Position> positions = burglar.getBeliefBase().getKnownPositions();
String strPositions = PDDLGenerator.generatePositionList(positions, true);
builder.append(strPositions);
// rooms:
List<Room> rooms = map.getRooms();
String strRooms = PDDLGenerator.generateRoomList(rooms);
builder.append(strRooms);
// items:
List<Item> items = map.getItems();
String strItems = PDDLGenerator.generateItemList(items);
builder.append(strItems);
// agents:
List<Agent> agents = new ArrayList<Agent>();
agents.add(burglar);
String strAgents = PDDLGenerator.generateAgentList(agents);
builder.append(strAgents);
builder.append(STR_TAG_END);
// ----------------------------
// init:
builder.append(STR_TAG_INIT);
// init position details:
for(Position pos : positions){
if(pos.isTypeOf(BaseObject.Type.DOOR)){
String posName = generateObjectName(pos);
if(((Lockable)pos).isClosed())
generateInlineTag(builder, STR_TAG_CLOSED, posName);
if(((Lockable)pos).isLocked())
generateInlineTag(builder, STR_TAG_LOCKED, posName);
if(((Lockable)pos).getKeyId() > 0){
generateInlineTag(
builder,
STR_TAG_NEEDS_KEY,
posName,
generateObjectName(((Lockable)pos).getKeyId())
);
}
Room[] connectedRooms = ((Door)pos).getRooms();
generateInlineTag(
builder,
STR_TAG_DOOR_CONNECTS,
posName,
generateObjectName(connectedRooms[0]),
generateObjectName(connectedRooms[1])
);
generateInlineTag(
builder,
STR_TAG_DOOR_CONNECTS,
posName,
generateObjectName(connectedRooms[1]),
generateObjectName(connectedRooms[0])
);
generateInlineTag(
builder,
STR_TAG_POSITION_IN,
posName,
generateObjectName(connectedRooms[0])
);
generateInlineTag(
builder,
STR_TAG_POSITION_IN,
posName,
generateObjectName(connectedRooms[1])
);
}
}
// init agent:
generateInlineTag(
builder,
STR_TAG_AGENT_NEAR,
generateObjectName(burglar),
generateDummyName(STR_TYPE_FLOOR)
);
generateInlineTag(
builder,
STR_TAG_POSITION_IN,
generateDummyName(STR_TYPE_FLOOR),
generateObjectName(burglar.getRoom())
);
generateInlineTag(
builder,
STR_TAG_AGENT_IN,
generateObjectName(burglar),
generateObjectName(burglar.getRoom())
);
generateInlineTag(
builder,
STR_TAG_VISITED,
generateObjectName(burglar),
generateObjectName(burglar.getRoom())
);
for(Item item : burglar.getItems()){
generateInlineTag(
builder,
STR_TAG_CONTAINS,
generateObjectName(burglar),
generateObjectName(item)
);
}
// finish init:
builder.append(STR_TAG_END);
// ----------------------------
// define goal:
builder.append("\t(:goal\n\t\t(and\n");
generateInlineTag(
builder,
'\t' + STR_TAG_AGENT_IN,
generateObjectName(burglar),
generateObjectName(burglar.getAimId())
);
generateInlineTag(
builder,
'\t' + STR_TAG_CONTAINS,
generateObjectName(burglar),
generateObjectName(burglar.getItemIdToCollect())
);
builder.append("\t\t)\n\t)\n");
// finish: