Class PolycraftComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.polycraft.PolycraftComponent

public class PolycraftComponent extends DiarcComponent
  • Constructor Details

    • PolycraftComponent

      public PolycraftComponent()
  • Method Details

    • parseArgs

      protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine)
      Description copied from class: DiarcComponent
      Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.zs
      Overrides:
      parseArgs in class DiarcComponent
    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      Command line options available in sub-class. This should be paired with a parseArgs implementation.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • init

      protected void init()
      Description copied from class: DiarcComponent
      Perform 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:
      init in class DiarcComponent
    • initializeBeliefs

      public Set<Term> 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

      public List<Map<Variable,Symbol>> observeDiscrepancies(Term state)
      Checks for inventory novelties and at(object,x,y) novelties in agent's local area.
      Returns:
    • isInCurrentRoom

      public boolean isInCurrentRoom(Predicate location)
      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

      public Set<Predicate> filterPointsNotInCurrentRoom(Set<Predicate> locations)
      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

      public void reportNovelties(Set<? extends Term> novelties)
      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

      public Justification senseRecipe()
    • senseHint

      public Justification senseHint()
    • characterize

      public Justification characterize(String identifier)
    • reportNovelty

      public Justification reportNovelty(Integer level, String message)
    • giveUp

      public Justification giveUp()
    • smoothTurn

      public Justification smoothTurn(Symbol turnAngle)
    • smoothMove

      public Justification smoothMove(Symbol direction)
    • breakBlock

      public Justification breakBlock()
    • placeItem

      public Justification placeItem(Symbol itemSymbol)
    • craft

      public Justification craft(Term recipe)
    • teleport

      public Justification teleport(Symbol targetX, Symbol targetY, Symbol distance)
    • selectItem

      public Justification selectItem(Symbol item)
    • use

      public Justification use()
    • collect

      public Justification collect()
    • delete

      public Justification delete(Symbol itemSymbol)
    • nop

      public Justification nop()
    • interact

      public Justification interact(Symbol otherActor, boolean expectTrades)
    • trade

      public Justification trade(Integer traderID, Term tradeRecipe)
    • observeNextTo

      public List<Map<Variable,Symbol>> observeNextTo(Term state)
      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

      public List<Map<Variable,Symbol>> observeFacingObject(Term state)
      Try to observe if facing_obj(self,X,one) or facing_obj(self,X,two) is true.
      Parameters:
      state -
      Returns:
    • observeState

      public List<Map<Variable,Symbol>> observeState(Term state)
    • observeEquality

      public List<Map<Variable,Symbol>> observeEquality(Term state)
    • writeSenseAllJsonToFile

      public String writeSenseAllJsonToFile(String filePreFix)
      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>.json and the filepath is the return value.
      Parameters:
      filePreFix -
      Returns:
      output file path
    • createVisionGraphAssertions

      public Set<Predicate> createVisionGraphAssertions(String model_output)
    • setGameOver

      public void setGameOver(boolean goalAchieved)
    • getGraphAssertions

      public List<Predicate> getGraphAssertions()
    • getVisionAssertions

      public List<Predicate> getVisionAssertions()
    • fillAction

      public String fillAction(ActionDBEntry a, String arg, boolean bytwo)