blob: 26f237956c6d8a9822fe737b19f9295deca715f1 [file] [log] [blame]
package org.metaabm.gen.test;
/**
* Basic Movement Agent Java Implementation.
*
* Generated by metaabm system: May 13, 2009 11:53:51 AM PDT in project: org.metaabm.gen.repast.test (testing) */
import static org.junit.Assert.*;
public class BasicMovementAgent {
/**
*
*/
private int vision = 20;
/**
*
*/
private boolean movingTowardGoal = true;
/**
*
*/
private boolean success = false;
/**
* Constructs a new Basic Movement Agent.
*/
public BasicMovementAgent() {
createUniqueID();
}
//todo, make this a useful value for evaluating compatibility of different versions of generated classes
private static final long serialVersionUID = 89989998L;
private String uniqueID;
public String getUID() {
return uniqueID;
}
public void createUniqueID() {
uniqueID = org.apache.commons.lang.RandomStringUtils
.randomAlphanumeric(5);
}
/**
* Clones the agent, ensuring that a unique id is assigned.
*/
public Object clone() {
try {
BasicMovementAgent clone = (BasicMovementAgent) super.clone();
clone.createUniqueID();
return clone;
} catch (Exception e) {
throw new RuntimeException("Unexpected cloning exception: " + e);
}
}
@org.junit.Test
public void dummy() {
assertTrue(true);
}
/**
* Most recent version.
*/
private BasicMovementModel basicMovementModelList = null;
/**
* Gets the Basic Movement Model property for .
* @return Most recent version.
*/
public BasicMovementModel getBasicMovementModel() {
return basicMovementModelList;
}
/**
* Sets the Basic Movement Model property for .
* Most recent version.
* @param _basicMovementModel the new Basic Movement Model value
*/
public void setBasicMovementModel(BasicMovementModel _basicMovementModel) {
basicMovementModelList = _basicMovementModel;
}
public double randomInRange(double minValue, double maxValue) {
return repast.simphony.random.RandomHelper.nextDoubleFromTo(minValue,
maxValue);
}
public double randomToLimit(double maxValue) {
return repast.simphony.random.RandomHelper.nextDoubleFromTo(0.0,
maxValue);
}
public int randomToLimit(int maxValue) {
return repast.simphony.random.RandomHelper.nextIntFromTo(0, maxValue);
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -0)
public void moveToRandomAvailable() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToRandomAvailable_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> availableCellAvailableQueryQuery = null;
repast.simphony.query.Query<Object> availableCellAvailableQueryQueryAvailable = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
repast.simphony.space.grid.GridPoint location = grid
.getLocation(object);
if (location != null) {
java.util.Iterator locIter = grid
.getObjectsAt(
location
.toIntArray(null))
.iterator();
if (locIter.hasNext()) {
locIter.next();
if (!locIter.hasNext()) {
return true;
}
}
}
return false;
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
availableCellAvailableQueryQuery = availableCellAvailableQueryQueryAvailable;
java.util.Iterator availableCellAvailableQueryIter = availableCellAvailableQueryQuery
.query().iterator();
if (availableCellAvailableQueryIter.hasNext()) {
java.util.List availableCellAvailableQueryList = org.apache.commons.collections15.IteratorUtils
.toList(availableCellAvailableQueryIter);
final BasicCell availableCell = (BasicCell) availableCellAvailableQueryList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, availableCellAvailableQueryList.size() - 1));
int[] movetoBasicMovementAgentinGridCopyLoc = grid.getLocation(
availableCell).toIntArray(null);
grid.moveTo(this, movetoBasicMovementAgentinGridCopyLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToRandomAvailable_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -1)
public void moveToRandomNoAvailableCheck() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToRandomNoAvailableCheck_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> basicMovementAgentCopyCopyCopyQuery = null;
repast.simphony.query.Query<Object> basicMovementAgentCopyCopyCopyQueryAvailable = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
return object instanceof BasicMovementAgent;
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
basicMovementAgentCopyCopyCopyQuery = basicMovementAgentCopyCopyCopyQueryAvailable;
java.util.Iterator basicMovementAgentCopyCopyCopyIter = basicMovementAgentCopyCopyCopyQuery
.query().iterator();
if (basicMovementAgentCopyCopyCopyIter.hasNext()) {
java.util.List basicMovementAgentCopyCopyCopyList = org.apache.commons.collections15.IteratorUtils
.toList(basicMovementAgentCopyCopyCopyIter);
final BasicMovementAgent basicMovementAgentCopyCopyCopy = (BasicMovementAgent) basicMovementAgentCopyCopyCopyList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
basicMovementAgentCopyCopyCopyList.size() - 1));
int[] moveBasicMovementAgentLoc = grid.getLocation(
basicMovementAgentCopyCopyCopy).toIntArray(null);
grid.moveTo(this, moveBasicMovementAgentLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToRandomNoAvailableCheck_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -2)
public void moveToNeighbor() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToNeighbor_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> spaceNeighborQuery = null;
spaceNeighborQuery = new repast.simphony.query.space.grid.GridWithin(
grid, this, 1);
repast.simphony.query.Query<Object> spaceNeighborQueryAgentClass = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
return (object instanceof BasicCell);
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
spaceNeighborQuery = new repast.simphony.query.AndQuery<Object>(
spaceNeighborQuery, spaceNeighborQueryAgentClass);
java.util.Iterator spaceNeighborIter = spaceNeighborQuery.query()
.iterator();
if (spaceNeighborIter.hasNext()) {
java.util.List spaceNeighborList = org.apache.commons.collections15.IteratorUtils
.toList(spaceNeighborIter);
final BasicCell neighboringSpace = (BasicCell) spaceNeighborList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, spaceNeighborList.size() - 1));
int[] movetoPerson1inTerritoryCopyLoc = grid.getLocation(
neighboringSpace).toIntArray(null);
grid.moveTo(this, movetoPerson1inTerritoryCopyLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToNeighbor_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -3)
public void moveToAvailableNeighbor() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToAvailableNeighbor_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Query = null;
basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Query = new repast.simphony.query.space.grid.GridWithin(
grid, this, 1);
repast.simphony.query.Query<Object> basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_QueryAvailable = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
repast.simphony.space.grid.GridPoint location = grid
.getLocation(object);
if (location != null) {
java.util.Iterator locIter = grid
.getObjectsAt(
location
.toIntArray(null))
.iterator();
if (locIter.hasNext()) {
locIter.next();
if (!locIter.hasNext()) {
return true;
}
}
}
return false;
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Query = new repast.simphony.query.AndQuery<Object>(
basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Query,
basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_QueryAvailable);
java.util.Iterator basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Iter = basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Query
.query().iterator();
if (basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Iter
.hasNext()) {
java.util.List basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_List = org.apache.commons.collections15.IteratorUtils
.toList(basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_Iter);
final BasicCell basicMovementAgentCopy = (BasicCell) basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_List
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
basicMovementAgentCopy_NeighborQueryAnd_Unspecified_QueryCopy_List
.size() - 1));
int[] movetoBasicMovementAgentinGridLoc = grid.getLocation(
basicMovementAgentCopy).toIntArray(null);
grid.moveTo(this, movetoBasicMovementAgentinGridLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToAvailableNeighbor_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -4)
public void moveToNearestGoal() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToNearestGoal_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
if (isMovingTowardGoal()) {
{
repast.simphony.query.Query<Object> identityNearGoalAndIsNearestCopyQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell goalinArea = (BasicCell) object;
return (goalinArea.isGoal2());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> identityNearGoalAndIsNearestCopyQuery = null;
identityNearGoalAndIsNearestCopyQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator identityNearGoalAndIsNearestCopyComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(
Math.abs(gs.getX() - gt.getX()), Math
.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection identityNearGoalAndIsNearestCopyList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection identityNearGoalAndIsNearestCopyMins = new java.util.ArrayList();
Object minAgent = java.util.Collections.min(
identityNearGoalAndIsNearestCopyList,
identityNearGoalAndIsNearestCopyComp);
while (minAgent != null) {
identityNearGoalAndIsNearestCopyMins.add(minAgent);
identityNearGoalAndIsNearestCopyList
.remove(minAgent);
Object nextAgent = java.util.Collections.min(
identityNearGoalAndIsNearestCopyList,
identityNearGoalAndIsNearestCopyComp);
if (nextAgent != null
&& identityNearGoalAndIsNearestCopyComp
.compare(minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return identityNearGoalAndIsNearestCopyMins;
}
};
identityNearGoalAndIsNearestCopyQuery = new repast.simphony.query.AndQuery<Object>(
identityNearGoalAndIsNearestCopyQuery,
identityNearGoalAndIsNearestCopyQueryCondition);
java.util.Iterator identityNearGoalAndIsNearestCopyIter = identityNearGoalAndIsNearestCopyQuery
.query().iterator();
if (identityNearGoalAndIsNearestCopyIter.hasNext()) {
java.util.List identityNearGoalAndIsNearestCopyList = org.apache.commons.collections15.IteratorUtils
.toList(identityNearGoalAndIsNearestCopyIter);
final BasicCell goalinArea = (BasicCell) identityNearGoalAndIsNearestCopyList
.get(repast.simphony.random.RandomHelper
.nextIntFromTo(0,
identityNearGoalAndIsNearestCopyList
.size() - 1));
int[] aMoveCopyLoc = grid.getLocation(goalinArea)
.toIntArray(null);
grid.moveTo(this, aMoveCopyLoc);
}
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToNearestGoal_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -5)
public void moveTowardNearestAgent() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestAgent_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> spaceNearestAndOtherPersonAndSpaceTowardCopyQuery = null;
spaceNearestAndOtherPersonAndSpaceTowardCopyQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator spaceNearestAndOtherPersonAndSpaceTowardCopyComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(Math.abs(gs.getX() - gt.getX()),
Math.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection spaceNearestAndOtherPersonAndSpaceTowardCopyList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection spaceNearestAndOtherPersonAndSpaceTowardCopyMins = new java.util.ArrayList();
Object minAgent = java.util.Collections.min(
spaceNearestAndOtherPersonAndSpaceTowardCopyList,
spaceNearestAndOtherPersonAndSpaceTowardCopyComp);
while (minAgent != null) {
spaceNearestAndOtherPersonAndSpaceTowardCopyMins
.add(minAgent);
spaceNearestAndOtherPersonAndSpaceTowardCopyList
.remove(minAgent);
Object nextAgent = java.util.Collections
.min(
spaceNearestAndOtherPersonAndSpaceTowardCopyList,
spaceNearestAndOtherPersonAndSpaceTowardCopyComp);
if (nextAgent != null
&& spaceNearestAndOtherPersonAndSpaceTowardCopyComp
.compare(minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return spaceNearestAndOtherPersonAndSpaceTowardCopyMins;
}
};
repast.simphony.query.Query<Object> spaceNearestAndOtherPersonAndSpaceTowardCopyQueryAgentClass = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
return (object instanceof BasicMovementAgent);
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
spaceNearestAndOtherPersonAndSpaceTowardCopyQuery = new repast.simphony.query.AndQuery<Object>(
spaceNearestAndOtherPersonAndSpaceTowardCopyQuery,
spaceNearestAndOtherPersonAndSpaceTowardCopyQueryAgentClass);
java.util.Iterator spaceNearestAndOtherPersonAndSpaceTowardCopyIter = spaceNearestAndOtherPersonAndSpaceTowardCopyQuery
.query().iterator();
if (spaceNearestAndOtherPersonAndSpaceTowardCopyIter.hasNext()) {
java.util.List spaceNearestAndOtherPersonAndSpaceTowardCopyList = org.apache.commons.collections15.IteratorUtils
.toList(spaceNearestAndOtherPersonAndSpaceTowardCopyIter);
final BasicMovementAgent otherPerson = (BasicMovementAgent) spaceNearestAndOtherPersonAndSpaceTowardCopyList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
spaceNearestAndOtherPersonAndSpaceTowardCopyList
.size() - 1));
int[] movetoPerson1inTerritoryLoc = grid.getLocation(
otherPerson).toIntArray(null);
grid.moveTo(this, movetoPerson1inTerritoryLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestAgent_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -6)
public void moveTowardNearestGoal() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestGoal_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell selectNearestToward = (BasicCell) object;
return (selectNearestToward.isGoal2());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQuery = null;
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator identityNearGoalCopyCopyAndIsNearestAndSpaceTowardComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(Math.abs(gs.getX() - gt.getX()),
Math.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection identityNearGoalCopyCopyAndIsNearestAndSpaceTowardMins = new java.util.ArrayList();
Object minAgent = java.util.Collections
.min(
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList,
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardComp);
while (minAgent != null) {
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardMins
.add(minAgent);
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList
.remove(minAgent);
Object nextAgent = java.util.Collections
.min(
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList,
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardComp);
if (nextAgent != null
&& identityNearGoalCopyCopyAndIsNearestAndSpaceTowardComp
.compare(minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return identityNearGoalCopyCopyAndIsNearestAndSpaceTowardMins;
}
};
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQuery = new repast.simphony.query.AndQuery<Object>(
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQuery,
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQueryCondition);
java.util.Iterator identityNearGoalCopyCopyAndIsNearestAndSpaceTowardIter = identityNearGoalCopyCopyAndIsNearestAndSpaceTowardQuery
.query().iterator();
if (identityNearGoalCopyCopyAndIsNearestAndSpaceTowardIter
.hasNext()) {
java.util.List identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList = org.apache.commons.collections15.IteratorUtils
.toList(identityNearGoalCopyCopyAndIsNearestAndSpaceTowardIter);
final BasicCell selectNearestToward = (BasicCell) identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
identityNearGoalCopyCopyAndIsNearestAndSpaceTowardList
.size() - 1));
int[] aMoveCopyCopyLoc = grid.getLocation(selectNearestToward)
.toIntArray(null);
grid.moveTo(this, aMoveCopyCopyLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveTowardNearestGoal_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -7)
public void moveWithEvaluate() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveWithEvaluate_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> actPerson1_VisionoverOneAndNeighborQuery_QueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicMovementAgent) {
BasicMovementAgent actPerson1 = (BasicMovementAgent) object;
return true;
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> actPerson1_VisionoverOneAndNeighborQuery_Query = null;
actPerson1_VisionoverOneAndNeighborQuery_Query = new repast.simphony.query.space.grid.GridWithin(
grid, this, 1);
actPerson1_VisionoverOneAndNeighborQuery_Query = new repast.simphony.query.AndQuery<Object>(
actPerson1_VisionoverOneAndNeighborQuery_Query,
actPerson1_VisionoverOneAndNeighborQuery_QueryCondition);
java.util.Iterator actPerson1_VisionoverOneAndNeighborQuery_Iter = actPerson1_VisionoverOneAndNeighborQuery_Query
.query().iterator();
if (actPerson1_VisionoverOneAndNeighborQuery_Iter.hasNext()) {
java.util.List actPerson1_VisionoverOneAndNeighborQuery_List = org.apache.commons.collections15.IteratorUtils
.toList(actPerson1_VisionoverOneAndNeighborQuery_Iter);
final BasicMovementAgent actPerson1 = (BasicMovementAgent) actPerson1_VisionoverOneAndNeighborQuery_List
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
actPerson1_VisionoverOneAndNeighborQuery_List
.size() - 1));
int[] movetoActPerson1inTerritoryLoc = grid.getLocation(
actPerson1).toIntArray(null);
grid.moveTo(this, movetoActPerson1inTerritoryLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveWithEvaluate_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -8)
public void moveTwice() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveTwice_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
if (isMovingTowardGoal()) {
{
repast.simphony.query.Query<Object> identityGoalAndIsNearestCopyCopyCopyQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell goalinArea2 = (BasicCell) object;
return (goalinArea2.isGoal());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> identityGoalAndIsNearestCopyCopyCopyQuery = null;
identityGoalAndIsNearestCopyCopyCopyQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator identityGoalAndIsNearestCopyCopyCopyComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(
Math.abs(gs.getX() - gt.getX()), Math
.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection identityGoalAndIsNearestCopyCopyCopyList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection identityGoalAndIsNearestCopyCopyCopyMins = new java.util.ArrayList();
Object minAgent = java.util.Collections.min(
identityGoalAndIsNearestCopyCopyCopyList,
identityGoalAndIsNearestCopyCopyCopyComp);
while (minAgent != null) {
identityGoalAndIsNearestCopyCopyCopyMins
.add(minAgent);
identityGoalAndIsNearestCopyCopyCopyList
.remove(minAgent);
Object nextAgent = java.util.Collections.min(
identityGoalAndIsNearestCopyCopyCopyList,
identityGoalAndIsNearestCopyCopyCopyComp);
if (nextAgent != null
&& identityGoalAndIsNearestCopyCopyCopyComp
.compare(minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return identityGoalAndIsNearestCopyCopyCopyMins;
}
};
identityGoalAndIsNearestCopyCopyCopyQuery = new repast.simphony.query.AndQuery<Object>(
identityGoalAndIsNearestCopyCopyCopyQuery,
identityGoalAndIsNearestCopyCopyCopyQueryCondition);
java.util.Iterator identityGoalAndIsNearestCopyCopyCopyIter = identityGoalAndIsNearestCopyCopyCopyQuery
.query().iterator();
if (identityGoalAndIsNearestCopyCopyCopyIter.hasNext()) {
java.util.List identityGoalAndIsNearestCopyCopyCopyList = org.apache.commons.collections15.IteratorUtils
.toList(identityGoalAndIsNearestCopyCopyCopyIter);
final BasicCell goalinArea2 = (BasicCell) identityGoalAndIsNearestCopyCopyCopyList
.get(repast.simphony.random.RandomHelper
.nextIntFromTo(0,
identityGoalAndIsNearestCopyCopyCopyList
.size() - 1));
{
repast.simphony.query.Query<Object> isIdentityNearGoalAndIsNearestCopyCopyQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(
Object object) {
if (object instanceof BasicCell) {
BasicCell closestNearGoal = (BasicCell) object;
return (closestNearGoal
.isGoal2());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> isIdentityNearGoalAndIsNearestCopyCopyQuery = null;
isIdentityNearGoalAndIsNearestCopyCopyQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator isIdentityNearGoalAndIsNearestCopyCopyComp = new java.util.Comparator<Object>() {
public int distance(Object source,
Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(Math.abs(gs.getX()
- gt.getX()), Math.abs(gs
.getY()
- gt.getY()));
}
public int compare(Object agent1,
Object agent2) {
return distance(goalinArea2, agent1)
- distance(goalinArea2, agent2);
}
};
final java.util.Collection isIdentityNearGoalAndIsNearestCopyCopyList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection isIdentityNearGoalAndIsNearestCopyCopyMins = new java.util.ArrayList();
Object minAgent = java.util.Collections
.min(
isIdentityNearGoalAndIsNearestCopyCopyList,
isIdentityNearGoalAndIsNearestCopyCopyComp);
while (minAgent != null) {
isIdentityNearGoalAndIsNearestCopyCopyMins
.add(minAgent);
isIdentityNearGoalAndIsNearestCopyCopyList
.remove(minAgent);
Object nextAgent = java.util.Collections
.min(
isIdentityNearGoalAndIsNearestCopyCopyList,
isIdentityNearGoalAndIsNearestCopyCopyComp);
if (nextAgent != null
&& isIdentityNearGoalAndIsNearestCopyCopyComp
.compare(minAgent,
nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return isIdentityNearGoalAndIsNearestCopyCopyMins;
}
};
isIdentityNearGoalAndIsNearestCopyCopyQuery = new repast.simphony.query.AndQuery<Object>(
isIdentityNearGoalAndIsNearestCopyCopyQuery,
isIdentityNearGoalAndIsNearestCopyCopyQueryCondition);
java.util.Iterator isIdentityNearGoalAndIsNearestCopyCopyIter = isIdentityNearGoalAndIsNearestCopyCopyQuery
.query().iterator();
if (isIdentityNearGoalAndIsNearestCopyCopyIter
.hasNext()) {
java.util.List isIdentityNearGoalAndIsNearestCopyCopyList = org.apache.commons.collections15.IteratorUtils
.toList(isIdentityNearGoalAndIsNearestCopyCopyIter);
final BasicCell closestNearGoal = (BasicCell) isIdentityNearGoalAndIsNearestCopyCopyList
.get(repast.simphony.random.RandomHelper
.nextIntFromTo(0,
isIdentityNearGoalAndIsNearestCopyCopyList
.size() - 1));
int[] movetoAreainTerritoryLoc = grid.getLocation(
closestNearGoal).toIntArray(null);
grid.moveTo(this, movetoAreainTerritoryLoc);
}
}
}
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveTwice_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -9)
public void andWithOrGoal() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_andWithOrGoal_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> aOGoalOrGoal2AndNearestQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell andOrAgent = (BasicCell) object;
return (andOrAgent.isGoal() && andOrAgent
.isGoal2());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> aOGoalOrGoal2AndNearestQuery = null;
aOGoalOrGoal2AndNearestQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator aOGoalOrGoal2AndNearestComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(Math.abs(gs.getX() - gt.getX()),
Math.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection aOGoalOrGoal2AndNearestList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection aOGoalOrGoal2AndNearestMins = new java.util.ArrayList();
Object minAgent = java.util.Collections.min(
aOGoalOrGoal2AndNearestList,
aOGoalOrGoal2AndNearestComp);
while (minAgent != null) {
aOGoalOrGoal2AndNearestMins.add(minAgent);
aOGoalOrGoal2AndNearestList.remove(minAgent);
Object nextAgent = java.util.Collections.min(
aOGoalOrGoal2AndNearestList,
aOGoalOrGoal2AndNearestComp);
if (nextAgent != null
&& aOGoalOrGoal2AndNearestComp.compare(
minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return aOGoalOrGoal2AndNearestMins;
}
};
aOGoalOrGoal2AndNearestQuery = new repast.simphony.query.AndQuery<Object>(
aOGoalOrGoal2AndNearestQuery,
aOGoalOrGoal2AndNearestQueryCondition);
java.util.Iterator aOGoalOrGoal2AndNearestIter = aOGoalOrGoal2AndNearestQuery
.query().iterator();
if (aOGoalOrGoal2AndNearestIter.hasNext()) {
java.util.List aOGoalOrGoal2AndNearestList = org.apache.commons.collections15.IteratorUtils
.toList(aOGoalOrGoal2AndNearestIter);
final BasicCell andOrAgent = (BasicCell) aOGoalOrGoal2AndNearestList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, aOGoalOrGoal2AndNearestList.size() - 1));
int[] aOMoveLoc = grid.getLocation(andOrAgent).toIntArray(null);
grid.moveTo(this, aOMoveLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_andWithOrGoal_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -10)
public void andWithAndGoal() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_andWithAndGoal_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> aAGoalAndGoal2AndNearestQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell andAndAgent = (BasicCell) object;
return (andAndAgent.isGoal() && andAndAgent
.isGoal2());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> aAGoalAndGoal2AndNearestQuery = null;
aAGoalAndGoal2AndNearestQuery = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return java.util.Collections.EMPTY_LIST;
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
final java.util.Comparator aAGoalAndGoal2AndNearestComp = new java.util.Comparator<Object>() {
public int distance(Object source, Object target) {
repast.simphony.space.grid.GridPoint gs = grid
.getLocation(source);
repast.simphony.space.grid.GridPoint gt = grid
.getLocation(target);
return Math.min(Math.abs(gs.getX() - gt.getX()),
Math.abs(gs.getY() - gt.getY()));
}
public int compare(Object agent1, Object agent2) {
return distance(this, agent1)
- distance(this, agent2);
}
};
final java.util.Collection aAGoalAndGoal2AndNearestList = org.apache.commons.collections15.IteratorUtils
.toList(other.iterator());
final java.util.Collection aAGoalAndGoal2AndNearestMins = new java.util.ArrayList();
Object minAgent = java.util.Collections.min(
aAGoalAndGoal2AndNearestList,
aAGoalAndGoal2AndNearestComp);
while (minAgent != null) {
aAGoalAndGoal2AndNearestMins.add(minAgent);
aAGoalAndGoal2AndNearestList.remove(minAgent);
Object nextAgent = java.util.Collections.min(
aAGoalAndGoal2AndNearestList,
aAGoalAndGoal2AndNearestComp);
if (nextAgent != null
&& aAGoalAndGoal2AndNearestComp.compare(
minAgent, nextAgent) == 0) {
minAgent = nextAgent;
} else {
minAgent = null;
}
}
return aAGoalAndGoal2AndNearestMins;
}
};
aAGoalAndGoal2AndNearestQuery = new repast.simphony.query.AndQuery<Object>(
aAGoalAndGoal2AndNearestQuery,
aAGoalAndGoal2AndNearestQueryCondition);
java.util.Iterator aAGoalAndGoal2AndNearestIter = aAGoalAndGoal2AndNearestQuery
.query().iterator();
if (aAGoalAndGoal2AndNearestIter.hasNext()) {
java.util.List aAGoalAndGoal2AndNearestList = org.apache.commons.collections15.IteratorUtils
.toList(aAGoalAndGoal2AndNearestIter);
final BasicCell andAndAgent = (BasicCell) aAGoalAndGoal2AndNearestList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, aAGoalAndGoal2AndNearestList.size() - 1));
int[] aAMoveLoc = grid.getLocation(andAndAgent)
.toIntArray(null);
grid.moveTo(this, aAMoveLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_andWithAndGoal_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -11)
public void moveToGoalWithin() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_moveToGoalWithin_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> identityGoalCopyAndWithin_Vision_AndAreaWithGoalQueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicCell) {
BasicCell areaWithGoal = (BasicCell) object;
return (areaWithGoal.isGoal());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> identityGoalCopyAndWithin_Vision_AndAreaWithGoalQuery = null;
identityGoalCopyAndWithin_Vision_AndAreaWithGoalQuery = new repast.simphony.query.space.grid.GridWithin(
grid, this, getVision());
identityGoalCopyAndWithin_Vision_AndAreaWithGoalQuery = new repast.simphony.query.AndQuery<Object>(
identityGoalCopyAndWithin_Vision_AndAreaWithGoalQuery,
identityGoalCopyAndWithin_Vision_AndAreaWithGoalQueryCondition);
java.util.Iterator identityGoalCopyAndWithin_Vision_AndAreaWithGoalIter = identityGoalCopyAndWithin_Vision_AndAreaWithGoalQuery
.query().iterator();
if (identityGoalCopyAndWithin_Vision_AndAreaWithGoalIter.hasNext()) {
java.util.List identityGoalCopyAndWithin_Vision_AndAreaWithGoalList = org.apache.commons.collections15.IteratorUtils
.toList(identityGoalCopyAndWithin_Vision_AndAreaWithGoalIter);
final BasicCell areaWithGoal = (BasicCell) identityGoalCopyAndWithin_Vision_AndAreaWithGoalList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
identityGoalCopyAndWithin_Vision_AndAreaWithGoalList
.size() - 1));
int[] moveInVisionLoc = grid.getLocation(areaWithGoal)
.toIntArray(null);
grid.moveTo(this, moveInVisionLoc);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_moveToGoalWithin_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -12)
public void setConditionNeighbor() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_setConditionNeighbor_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_QueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicMovementAgent) {
BasicMovementAgent basicMovementAgent = (BasicMovementAgent) object;
return (basicMovementAgent.isSuccess());
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Query = null;
basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Query = new repast.simphony.query.space.grid.GridWithin(
grid, this, 1);
basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Query = new repast.simphony.query.AndQuery<Object>(
basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Query,
basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_QueryCondition);
java.util.Iterator basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Iter = basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Query
.query().iterator();
if (basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Iter
.hasNext()) {
java.util.List basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_List = org.apache.commons.collections15.IteratorUtils
.toList(basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_Iter);
final BasicMovementAgent basicMovementAgent = (BasicMovementAgent) basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_List
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
basicMovementAgent_NeighborQueryAndIdentitySuccessQuery_List
.size() - 1));
basicMovementAgent.setSuccess(true);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_setConditionNeighbor_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -13)
public void setConditionStateAgentNeighbor() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_setConditionStateAgentNeighbor_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_QueryCondition = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
if (object instanceof BasicMovementStateAgent) {
BasicMovementStateAgent setStateConditionNeighbor = (BasicMovementStateAgent) object;
return (setStateConditionNeighbor
.getState() == StateEnum.option1);
} else {
return false;
}
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
repast.simphony.query.Query<Object> setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Query = null;
setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Query = new repast.simphony.query.space.grid.GridWithin(
grid, this, getVision());
setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Query = new repast.simphony.query.AndQuery<Object>(
setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Query,
setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_QueryCondition);
java.util.Iterator setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Iter = setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Query
.query().iterator();
if (setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Iter
.hasNext()) {
java.util.List setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_List = org.apache.commons.collections15.IteratorUtils
.toList(setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_Iter);
final BasicMovementStateAgent setStateConditionNeighbor = (BasicMovementStateAgent) setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_List
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0,
setStateConditionNeighbor_Within_Vision_QueryAndStateIdenticalOption1Query_List
.size() - 1));
setStateConditionNeighbor.setState(StateEnum.option2);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_setConditionStateAgentNeighbor_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* .
*/
@org.junit.Test
@repast.simphony.engine.schedule.ScheduledMethod(start = 1, interval = 1, priority = -80)
public void setRandomNeighborValue() {
final repast.simphony.context.Context context = repast.simphony.util.ContextUtils
.getContext(this);
final repast.simphony.space.grid.Grid grid = (repast.simphony.space.grid.Grid) context
.getProjection("Grid");
/*PROTECTED REGION ID(BasicMovementAgent_setRandomNeighborValue_Pre) ENABLED START*/
//Pre-Conditions Here
/*PROTECTED REGION END*/
{
repast.simphony.query.Query<Object> basicMovementAgentCopyCopyNeighborQueryQuery = null;
basicMovementAgentCopyCopyNeighborQueryQuery = new repast.simphony.query.space.grid.GridWithin(
grid, this, 1);
repast.simphony.query.Query<Object> basicMovementAgentCopyCopyNeighborQueryQueryAgentClass = new repast.simphony.query.Query<Object>() {
public java.lang.Iterable<Object> query() {
return new repast.simphony.util.collections.FilteredIterator<Object>(
context.iterator(),
new org.apache.commons.collections15.Predicate() {
public boolean evaluate(Object object) {
return (object instanceof BasicMovementAgent);
}
});
}
public java.lang.Iterable<Object> query(
java.lang.Iterable<Object> other) {
return new repast.simphony.util.collections.FilteredIterator<Object>(
query().iterator(),
repast.simphony.query.QueryUtils
.createContains(other));
}
};
basicMovementAgentCopyCopyNeighborQueryQuery = new repast.simphony.query.AndQuery<Object>(
basicMovementAgentCopyCopyNeighborQueryQuery,
basicMovementAgentCopyCopyNeighborQueryQueryAgentClass);
java.util.Iterator basicMovementAgentCopyCopyNeighborQueryIter = basicMovementAgentCopyCopyNeighborQueryQuery
.query().iterator();
if (basicMovementAgentCopyCopyNeighborQueryIter.hasNext()) {
java.util.List basicMovementAgentCopyCopyNeighborQueryList = org.apache.commons.collections15.IteratorUtils
.toList(basicMovementAgentCopyCopyNeighborQueryIter);
final BasicMovementAgent basicMovementAgentCopyCopy = (BasicMovementAgent) basicMovementAgentCopyCopyNeighborQueryList
.get(repast.simphony.random.RandomHelper.nextIntFromTo(
0, basicMovementAgentCopyCopyNeighborQueryList
.size() - 1));
basicMovementAgentCopyCopy.setSuccess(true);
}
}
/*PROTECTED REGION ID(BasicMovementAgent_setRandomNeighborValue_Post) ENABLED START*/
//Post-Conditions Here
/*PROTECTED REGION END*/
}
/**
* Gets the Vision property for Basic Movement Agent.
* @return
*/
@repast.simphony.parameter.Parameter(displayName = "Vision", usageName = "vision", defaultValue = "20")
public int getVision() {
return vision;
}
/**
* Sets the Vision property for Basic Movement Agent.
*
* @param _vision the new Vision value
*/
public void setVision(int _vision) {
vision = _vision;
}
/**
* Gets the Moving Toward Goal property for Basic Movement Agent.
* @return
*/
@repast.simphony.parameter.Parameter(displayName = "Moving Toward Goal", usageName = "movingTowardGoal", defaultValue = "true")
public boolean isMovingTowardGoal() {
return movingTowardGoal;
}
/**
* Sets the Moving Toward Goal property for Basic Movement Agent.
*
* @param _movingTowardGoal the new Moving Toward Goal value
*/
public void setMovingTowardGoal(boolean _movingTowardGoal) {
movingTowardGoal = _movingTowardGoal;
}
/**
* Gets the Success property for Basic Movement Agent.
* @return
*/
@repast.simphony.parameter.Parameter(displayName = "Success", usageName = "success", defaultValue = "false")
public boolean isSuccess() {
return success;
}
/**
* Sets the Success property for Basic Movement Agent.
*
* @param _success the new Success value
*/
public void setSuccess(boolean _success) {
success = _success;
}
}