예제 #1
0
  /**
   * \brief Models a mechanical interaction between two located agents. Implemented by extending
   * classes (LocatedAgent)
   *
   * <p>Models a mechanical interaction between two located agents. Implemented by extending classes
   * (LocatedAgent)
   *
   * @param MUTUAL Whether movement is shared between two agents or applied only to this one
   * @param shoveOnly Boolean noting whether this action is shoving (false) or pulling (shrinking
   *     biofilm) (true)
   * @param seq Whether the move should be applied immediately or wait until the end of the step
   * @param gain Double noting change in position
   * @return The move to be applied once the shoving or pull calculations have been performed
   */
  public double interact(boolean MUTUAL, boolean shoveOnly, boolean seq, double gain) {
    boolean willShove = false;

    move();

    // rebuild your neighbourhood
    if (shoveOnly) getPotentialShovers(getInteractDistance());
    else getPotentialShovers(getInteractDistance() + getShoveRadius());

    Iterator<LocatedAgent> iter = _myNeighbors.iterator();
    while (iter.hasNext()) {
      if (shoveOnly) willShove |= addPushMovement(iter.next(), MUTUAL, gain);
      else willShove |= addSpringMovement(iter.next(), MUTUAL, gain);
    }
    _myNeighbors.clear();

    // Check interaction with surface
    if (_isAttached & !shoveOnly) {}

    willShove = isMoving();

    if (seq) return move();
    else return 0;
  }
예제 #2
0
  /**
   * \brief Find a sibling of this agent
   *
   * <p>Find a sibling of this agent
   *
   * @param indexSpecies The index used to reference this species in the simulation dictionary
   */
  public void findCloseSiblings(int indexSpecies) {
    int nNb;
    boolean test;
    double shoveDist;
    LocatedAgent aNb;

    getPotentialShovers(getInteractDistance());
    nNb = _myNeighbors.size();

    for (int iNb = 0; iNb < nNb; iNb++) {
      aNb = _myNeighbors.removeFirst();
      // test EPS-species
      test = (indexSpecies == aNb.speciesIndex);

      // Test distance
      shoveDist = 2 * (getShoveRadius() + aNb.getShoveRadius());
      test = test && computeDifferenceVector(_location, aNb.getLocation()) <= shoveDist;

      if (test & aNb != this) _myNeighbors.addLast(aNb);
    }
  }