public void handleAction(int action) {

    try {

      if (action == Action.GO_FORWARD) {

        if (environment.getBump() == true) environment.setBump(false);

        agent.goForward();
        environment.placeAgent(agent);

        if (environment.checkDeath() == true) {

          currScore += deathCost;
          simulationRunning = false;

          agent.setIsDead(true);
        } else {
          currScore += actionCost;
        }

        if (environment.getScream() == true) environment.setScream(false);

        lastAction = Action.GO_FORWARD;
      } else if (action == Action.TURN_RIGHT) {

        currScore += actionCost;
        agent.turnRight();
        environment.placeAgent(agent);

        if (environment.getBump() == true) environment.setBump(false);
        if (environment.getScream() == true) environment.setScream(false);

        lastAction = Action.TURN_RIGHT;
      } else if (action == Action.TURN_LEFT) {

        currScore += actionCost;
        agent.turnLeft();
        environment.placeAgent(agent);

        if (environment.getBump() == true) environment.setBump(false);
        if (environment.getScream() == true) environment.setScream(false);

        lastAction = Action.TURN_LEFT;
      } else if (action == Action.GRAB) {

        if (environment.grabGold() == true) {

          currScore += goldCost;
          simulationRunning = false;

          agent.setHasGold(true);
        } else currScore += actionCost;

        environment.placeAgent(agent);

        if (environment.getBump() == true) environment.setBump(false);
        if (environment.getScream() == true) environment.setScream(false);

        lastAction = Action.GRAB;
      } else if (action == Action.SHOOT) {

        if (agent.shootArrow() == true) {

          if (environment.shootArrow() == true) environment.setScream(true);

          currScore += shootCost;
        } else {

          if (environment.getScream() == true) environment.setScream(false);

          currScore += actionCost;
        }

        environment.placeAgent(agent);

        if (environment.getBump() == true) environment.setBump(false);

        lastAction = Action.SHOOT;
      } else if (action == Action.NO_OP) {

        environment.placeAgent(agent);

        if (environment.getBump() == true) environment.setBump(false);
        if (environment.getScream() == true) environment.setScream(false);

        lastAction = Action.NO_OP;
      }

    } catch (Exception e) {

      System.out.println("An exception was thrown: " + e);
    }
  }