Package cz.cuni.mff.abacs.burglar.logics.objects.positions

Examples of cz.cuni.mff.abacs.burglar.logics.objects.positions.Position


   * @return positions in the room.
   */
  public List<Position> getPositions() {
    List<Position> ret = new LinkedList<Position>();
    for(Integer id : this._positionIds){
      Position pos = this._referenceMap.getPosition(id);
      if(pos != null){
        ret.add(pos);
      }
    }
    return ret;
View Full Code Here


    int id = examined.getId();
   
    // add the knowledge about the position if it did not exist so far:
   
    if(this._positionsFar.containsKey(id)){
      Position remembered = this._positionsFar.get(id);
      if(remembered.matchesFromFar(examined) == false){
        this._positionsFar.remove(id);
       
        Position ourCopy = examined.examinedFromFar();
        this._positionsFar.put(id, ourCopy);
        if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER))
          this.seenContents((Container)ourCopy);
       
        seenSomethingNew = true;
      }
     
      return seenSomethingNew;
    }
   
    if(this._positionsNear.containsKey(id)){
      Position remembered = this._positionsNear.get(id);
      if(remembered.matchesFromFar(examined) == false){
        Position oldPosition = this._positionsNear.remove(id);
       
        Position ourCopy = examined.examinedFromFar();
        this._positionsFar.put(id, ourCopy);
        if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER)){
          this.seenContents((Container)ourCopy);
          // don't forget the old items either:
          ((Container)ourCopy).addItems(((Container)oldPosition).getItems());
        }
       
        seenSomethingNew = true;
      }
     
      return seenSomethingNew;
    }
   
    // no list contains it yet:
   
    Position ourCopy = examined.examinedFromFar();
    this._positionsFar.put(id, ourCopy);
    if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER))
      this.seenContents((Container)ourCopy);
   
    seenSomethingNew = true;
   
    // add parent room to room list:
View Full Code Here

  public boolean seenFromNear(Position examined) {
    boolean seenSomethingNew = false;
    int id = examined.getId();
   
    if(this._positionsFar.containsKey(id)){
      Position remembered = this._positionsFar.remove(id);
      if(remembered.matchesFromClose(examined)){
        this._positionsNear.put(id, remembered);
      }else{
       
        Position ourCopy = examined.examinedFromNear();
        this._positionsNear.put(id, ourCopy);
        if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER))
          this.seenContents((Container)ourCopy);
       
        seenSomethingNew = true;
      }
     
      return seenSomethingNew;
    }
   
    if(this._positionsNear.containsKey(id)){
      Position remembered = this._positionsNear.get(id);
      if(remembered.matchesFromClose(examined) == false){
        this._positionsNear.remove(id);
       
        Position ourCopy = examined.examinedFromNear();
        this._positionsNear.put(id, ourCopy);
        if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER))
          this.seenContents((Container)ourCopy);
       
        seenSomethingNew = true;
      }
     
      return seenSomethingNew;
    }
   
    Position ourCopy = examined.examinedFromNear();
    this._positionsNear.put(id, ourCopy);
    if(ourCopy.isTypeOf(BaseInterface.Type.CONTAINER))
      this.seenContents((Container)ourCopy);
   
    seenSomethingNew = true;
   
    // add parent room to room list:
View Full Code Here

 
  /**
   * Returns whether the position matches with something in the belief base.
   */
  public boolean matches(Position examined) {
    Position own = this._positionsFar.get(examined.getId());
    if(own != null)
      return own.matchesFromClose(examined);
   
    own = this._positionsNear.get(examined.getId());
    if(own != null)
      return own.matchesFromClose(examined);
   
    return false;
  }
View Full Code Here

TOP

Related Classes of cz.cuni.mff.abacs.burglar.logics.objects.positions.Position

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.