Пример #1
0
  public void step() throws IncorrectNodeException {
    super.step();

    // Get the agent
    Object agent = m_tree.getAgent();
    GEBT_MarioAgent mario = (GEBT_MarioAgent) agent;

    m_nodeStatus = BTConstants.NODE_STATUS_FAILURE;

    int aheadStartPos = GEBT_MarioAgent.MARIO_Y - 2;
    int aheadEndPos = GEBT_MarioAgent.MARIO_Y - 1;
    boolean obsUp =
        mario.isBreakable(
            GEBT_MarioAgent.MARIO_X - 5, GEBT_MarioAgent.MARIO_X - 1, aheadStartPos, aheadEndPos);

    if (obsUp) {
      m_nodeStatus = BTConstants.NODE_STATUS_SUCCESS;
    }

    // report
    m_parent.update(m_nodeStatus);
  }
Пример #2
0
  public void step() throws IncorrectNodeException {
    super.step();

    // Get the agent
    Object agent = m_tree.getAgent();
    GEBT_MarioAgent mario = (GEBT_MarioAgent) agent;

    int marioPos = mario.getCellsRun();
    m_detectedTrapPos =
        (mario.inTrap() && mario.isRightTrap()) ? mario.trapPos() : m_detectedTrapPos;

    int trapHeight = mario.heightTrapRight();
    boolean marioOnGround = mario.amIOnGround();
    boolean trapIsThere =
        mario.isObstacle(trapHeight, trapHeight, GEBT_MarioAgent.MARIO_Y, GEBT_MarioAgent.MARIO_Y);

    m_nodeStatus = BTConstants.NODE_STATUS_FAILURE;

    if (!trapIsThere && marioOnGround) {
      m_nodeStatus = BTConstants.NODE_STATUS_SUCCESS;
      boolean isForbidden = mario.isGapForbidden(marioPos);
      if (isForbidden) {
        mario.deleteForbiddenGap(marioPos);
        m_detectedTrapPos = marioPos + 1;
      }
    } else if (trapIsThere && marioOnGround) {
      m_nodeStatus = BTConstants.NODE_STATUS_FAILURE;
      mario.addForbiddenGap(marioPos, m_detectedTrapPos);
    }

    // report
    m_parent.update(m_nodeStatus);
  }