Skip to content

LocatedAgent.interact() in need of rewriting #32

Description

@roughhawkbit

As it currently stands:

/**
     * \brief Models a mechanical interaction between two located agents. Implemented by extending classes (LocatedAgent)
     * 
     * 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;
    }

Issues:

  • the head comment is out of date. This is now an interaction between one locatedAgent and its neighbours.
  • if seq is true, move() gets called twice.
  • willShove is set but never actually used. The function isMoving() simply returns ( _movement < _totalRadius/10) and is only ever called here.
  • I cannot understand the logic of ignoring shoveRadius when only shoving, but including when not only shoving. Perhaps I'm missing something but it's not commented at all.
  • I don't know what exactly if (_isAttached&!shoveOnly) {} was intended for but it no longer does anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions