Example #1
0
  /* (non-Javadoc)
   * @see Environment.Environment#getPercept()
   */
  @Override
  public Percept getPercept() throws Exception {

    if (_bTrialOver) {
      throw new Exception("Trial over");
    }

    WumpusPercept p = new WumpusPercept();

    if (_tsWumpusMap.contains(currentLoc) || _tsPitMap.contains(currentLoc)) {
      p.setDead();
      _bAlive = false;
      _bTrialOver = true;
      return p;
    }

    Pair<Integer, Integer> left = leftGuy(currentLoc);
    Pair<Integer, Integer> right = rightGuy(currentLoc);
    Pair<Integer, Integer> top = topGuy(currentLoc);
    Pair<Integer, Integer> bottom = bottomGuy(currentLoc);

    if (_tsPitMap.contains(left)
        || _tsPitMap.contains(right)
        || _tsPitMap.contains(top)
        || _tsPitMap.contains(bottom)) {
      p.setBreezy();
    }

    if (_tsWumpusMap.contains(left)
        || _tsWumpusMap.contains(right)
        || _tsWumpusMap.contains(top)
        || _tsWumpusMap.contains(bottom)) {
      p.setSmelly();
    }

    if (_tsGoldMap.contains(currentLoc)) {
      p.setGlitter();
    }

    if (_bWumpusDied) {
      p.setScream();
      _bWumpusDied = false;
    }

    p.setLoc(currentLoc);

    return p;
  }