@Test public void testClone() { LogoEnvPLS e2 = (LogoEnvPLS) e1.clone(); assertEquals(e1, e2); assertNotSame(e1,e2); assertEquals(e1.getClass(),e2.getClass()); }
@Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); if (!this.marks[x][y].isEmpty()) { for(Mark mark: this.marks[x][y]) { markSet[x][y].add((Mark) mark.clone()); } } } } Map<Pheromone, double[][]> pheromoneFieldCopy = new HashMap<>(); for( Map.Entry<Pheromone, double[][]> pheromone : this.pheromoneField.entrySet()) { pheromoneFieldCopy.put(pheromone.getKey(), (double[][]) pheromone.getValue().clone()); } return new LogoEnvPLS( width, height, xAxisTorus, yAxisTorus, turtleSet, markSet, pheromoneFieldCopy ); }
LogoEnvPLS extends AbstractLocalStateOfEnvironment implements Cloneable { @Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); if (!this.marks[x][y].isEmpty()) { for(Mark mark: this.marks[x][y]) { markSet[x][y].add((Mark) mark.clone()); } } } } Map<Pheromone, double[][]> pheromoneFieldCopy = new HashMap<>(); for( Map.Entry<Pheromone, double[][]> pheromone : this.pheromoneField.entrySet()) { pheromoneFieldCopy.put(pheromone.getKey(), (double[][]) pheromone.getValue().clone()); } return new LogoEnvPLS( width, height, xAxisTorus, yAxisTorus, turtleSet, markSet, pheromoneFieldCopy ); } }
LogoEnvPLS extends AbstractLocalStateOfEnvironment implements Cloneable { @Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); if (!this.marks[x][y].isEmpty()) { for(Mark mark: this.marks[x][y]) { markSet[x][y].add((Mark) mark.clone()); } } } } Map<Pheromone, double[][]> pheromoneFieldCopy = new HashMap<>(); for( Map.Entry<Pheromone, double[][]> pheromone : this.pheromoneField.entrySet()) { pheromoneFieldCopy.put(pheromone.getKey(), (double[][]) pheromone.getValue().clone()); } return new LogoEnvPLS( width, height, xAxisTorus, yAxisTorus, turtleSet, markSet, pheromoneFieldCopy ); } LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<TurtlePLSInLogo>[][] turtlesInPatches,
		Set<Mark>[][] marks,
		Map<Pheromone, double[][]> pheromoneField
	);  LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	);  LogoEnvPLS(
		LevelIdentifier levelIdentifier,
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	); }
LogoEnvPLS extends AbstractLocalStateOfEnvironment implements Cloneable { @Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); if (!this.marks[x][y].isEmpty()) { for(Mark mark: this.marks[x][y]) { markSet[x][y].add((Mark) mark.clone()); } } } } Map<Pheromone, double[][]> pheromoneFieldCopy = new HashMap<>(); for( Map.Entry<Pheromone, double[][]> pheromone : this.pheromoneField.entrySet()) { pheromoneFieldCopy.put(pheromone.getKey(), (double[][]) pheromone.getValue().clone()); } return new LogoEnvPLS( width, height, xAxisTorus, yAxisTorus, turtleSet, markSet, pheromoneFieldCopy ); } LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<TurtlePLSInLogo>[][] turtlesInPatches,
		Set<Mark>[][] marks,
		Map<Pheromone, double[][]> pheromoneField
	);  LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	);  LogoEnvPLS(
		LevelIdentifier levelIdentifier,
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	); Collection<Point> getNeighbors(int x, int y, int distance); double getDirection(SituatedEntity from, SituatedEntity to); double getDirection(Point2D from, Point2D to); double getDistance(SituatedEntity loc1, SituatedEntity loc2); double getDistance(Point2D loc1, Point2D loc2); Set<TurtlePLSInLogo> getTurtlesAt(int x, int y); Set<TurtlePLSInLogo> getTurtlesAt(Point2D position); Set<TurtlePLSInLogo> getTurtlesAt(double x, double y); Set<TurtlePLSInLogo> getTurtles(); Set<TurtlePLSInLogo> getTurtles(AgentCategory agentCategory); Set<Mark> getMarksAsSet(); Set<Mark> getMarksAt(Point2D position); Set<Mark> getMarksAt(int x, int y); Set<Mark> getMarksAt(double x, double y); double getPheromoneValueAt(Pheromone pheromone, int x, int y); double getPheromoneValueAt(Pheromone pheromone, double x, double y); double[][] getPheromoneValues(Pheromone pheromone); Map<Pheromone, double[][]> getPheromoneField(); void setPheromoneField(Map<Pheromone, double[][]> pheromoneField); int getWidth(); int getHeight(); boolean isxAxisTorus(); boolean isyAxisTorus(); Set<Mark>[][] getMarks(); Set<TurtlePLSInLogo>[][] getTurtlesInPatches(); @Override Object clone(); @Override int hashCode(); @Override boolean equals(Object o); }
LogoEnvPLS extends AbstractLocalStateOfEnvironment implements Cloneable { @Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); if (!this.marks[x][y].isEmpty()) { for(Mark mark: this.marks[x][y]) { markSet[x][y].add((Mark) mark.clone()); } } } } Map<Pheromone, double[][]> pheromoneFieldCopy = new HashMap<>(); for( Map.Entry<Pheromone, double[][]> pheromone : this.pheromoneField.entrySet()) { pheromoneFieldCopy.put(pheromone.getKey(), (double[][]) pheromone.getValue().clone()); } return new LogoEnvPLS( width, height, xAxisTorus, yAxisTorus, turtleSet, markSet, pheromoneFieldCopy ); } LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<TurtlePLSInLogo>[][] turtlesInPatches,
		Set<Mark>[][] marks,
		Map<Pheromone, double[][]> pheromoneField
	);  LogoEnvPLS(
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	);  LogoEnvPLS(
		LevelIdentifier levelIdentifier,
		int gridWidth,
		int gridHeight,
		boolean xAxisTorus,
		boolean yAxisTorus,
		Set<Pheromone> pheromones
	); Collection<Point> getNeighbors(int x, int y, int distance); double getDirection(SituatedEntity from, SituatedEntity to); double getDirection(Point2D from, Point2D to); double getDistance(SituatedEntity loc1, SituatedEntity loc2); double getDistance(Point2D loc1, Point2D loc2); Set<TurtlePLSInLogo> getTurtlesAt(int x, int y); Set<TurtlePLSInLogo> getTurtlesAt(Point2D position); Set<TurtlePLSInLogo> getTurtlesAt(double x, double y); Set<TurtlePLSInLogo> getTurtles(); Set<TurtlePLSInLogo> getTurtles(AgentCategory agentCategory); Set<Mark> getMarksAsSet(); Set<Mark> getMarksAt(Point2D position); Set<Mark> getMarksAt(int x, int y); Set<Mark> getMarksAt(double x, double y); double getPheromoneValueAt(Pheromone pheromone, int x, int y); double getPheromoneValueAt(Pheromone pheromone, double x, double y); double[][] getPheromoneValues(Pheromone pheromone); Map<Pheromone, double[][]> getPheromoneField(); void setPheromoneField(Map<Pheromone, double[][]> pheromoneField); int getWidth(); int getHeight(); boolean isxAxisTorus(); boolean isyAxisTorus(); Set<Mark>[][] getMarks(); Set<TurtlePLSInLogo>[][] getTurtlesInPatches(); @Override Object clone(); @Override int hashCode(); @Override boolean equals(Object o); static final double NORTH; static final double NORTH_EAST; static final double EAST; static final double SOUTH_EAST; static final double SOUTH; static final double SOUTH_WEST; static final double WEST; static final double NORTH_WEST; }