Skip to content

Commit

Permalink
fixing bindTarget method to only consider tissue cells
Browse files Browse the repository at this point in the history
  • Loading branch information
allison-li-1016 committed Jan 23, 2025
1 parent 5a43a2f commit 6a605ca
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/arcade/patch/agent/cell/PatchCellCART.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,14 @@ public PatchCellTissue bindTarget(
double kDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23);
PatchGrid grid = (PatchGrid) sim.getGrid();

// get all agents from this location
Bag allAgents = new Bag(grid.getObjectsAtLocation(loc));
// get all tissue agents from this location
Bag allAgents = new Bag();
getTissueAgents(allAgents, grid.getObjectsAtLocation(loc));

// get all agents from neighboring locations
for (Location neighborLocation : loc.getNeighbors()) {
Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation));
for (Object agent : bag) {
Cell cell = (Cell) agent;
// add all tissue agents from neighboring locations
if (cell instanceof PatchCellTissue) allAgents.add(cell);
}
getTissueAgents(allAgents, bag);
}

// remove self
Expand Down Expand Up @@ -316,4 +313,19 @@ public AntigenFlag getAntigenFlag() {
public boolean getActivationStatus() {
return this.activated;
}

/**
* Adds only tissue cells to the provided bag. Helper method for bindTarget.
*
* @param tissueAgents the bag to add tissue cells into
* @param possibleAgents the bag of possible agents to check for tissue cells
*/
private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) {
for (Object agent : possibleAgents) {
Cell cell = (Cell) agent;
if (cell instanceof PatchCellTissue) {
tissueAgents.add(cell);
}
}
}
}

0 comments on commit 6a605ca

Please sign in to comment.