Package edu.tufts.hrilab.polycraft
Class PolycraftComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.polycraft.PolycraftComponent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected classprotected classprotected class -
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.characterize(String identifier) collect()createVisionGraphAssertions(String model_output) fillAction(ActionDBEntry a, String arg, boolean bytwo) filterPointsNotInCurrentRoom(Set<Predicate> locations) Helper method to filter out locations that are not in the same room as our agent.giveUp()protected voidinit()Perform any component initialization.This initializes the map and belief based on the initial state of the game.booleanisInCurrentRoom(Predicate location) Convenience method to filterPointsNotInCurrentRoom when only a single location needs to be checked.nop()observeDiscrepancies(Term state) Checks for inventory novelties and at(object,x,y) novelties in agent's local area.observeEquality(Term state) observeFacingObject(Term state) Try to observe if facing_obj(self,X,one) or facing_obj(self,X,two) is true.observeNextTo(Term state) Try to observe the specified state in the world.observeState(Term state) protected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.voidreportNovelties(Set<? extends Term> novelties) Main entry point for reporting novelties to Polycraft.reportNovelty(Integer level, String message) selectItem(Symbol item) voidvoidsetGameOver(boolean goalAchieved) smoothMove(Symbol direction) smoothTurn(Symbol turnAngle) use()writeSenseAllJsonToFile(String filePreFix) Debug method to make it easy to log the raw SENSE_ALL JSON from anywhere in the system.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdown, shutdownComponent
-
Constructor Details
-
PolycraftComponent
public PolycraftComponent()
-
-
Method Details
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
initializeBeliefs
This initializes the map and belief based on the initial state of the game. Also detects and returns a set of detected pre-game novelties.- Returns:
-
senseNewMap
public void senseNewMap() -
observeDiscrepancies
Checks for inventory novelties and at(object,x,y) novelties in agent's local area.- Returns:
-
isInCurrentRoom
Convenience method to filterPointsNotInCurrentRoom when only a single location needs to be checked. Location predicate needs to be of form: at(O,locX,locY)- Parameters:
location-- Returns:
-
filterPointsNotInCurrentRoom
Helper method to filter out locations that are not in the same room as our agent. Useful for checking for at() discrepancies, since our agent can't observe outside its current room. Location predicates needs to be of form: at(O,locX,locY)- Parameters:
locations-- Returns:
-
reportNovelties
Main entry point for reporting novelties to Polycraft. This checks if the novelty has already been reported, gets the novelty level, reports new unreported novelties to Polycraft, and updates Belief of any reported novelties.- Parameters:
novelties-
-
senseRecipe
-
senseHint
-
characterize
-
reportNovelty
-
giveUp
-
smoothTurn
-
smoothMove
-
breakBlock
-
placeItem
-
craft
-
teleport
-
selectItem
-
use
-
collect
-
delete
-
nop
-
interact
-
trade
-
observeNextTo
Try to observe the specified state in the world. This method doesn't currently handle unbound variables in the next_to predicate.- Parameters:
state-- Returns:
-
observeFacingObject
Try to observe if facing_obj(self,X,one) or facing_obj(self,X,two) is true.- Parameters:
state-- Returns:
-
observeState
-
observeEquality
-
writeSenseAllJsonToFile
Debug method to make it easy to log the raw SENSE_ALL JSON from anywhere in the system. The output JSON will be written to/tmp/<filePreFix><rdn>.jsonand the filepath is the return value.- Parameters:
filePreFix-- Returns:
- output file path
-
createVisionGraphAssertions
-
setGameOver
public void setGameOver(boolean goalAchieved) -
getGraphAssertions
-
getVisionAssertions
-
fillAction
-