5..6 lines in SegregationRules, SpreadingOfFireRules
SpreadingOfFireRules /cellsociety_team11/src/cellsociety_team11/spreading_of_fire/SpreadingOfFireRules.java |
SegregationRules /cellsociety_team11/src/cellsociety_team11/segregation/SegregationRules.java |
@Override public Integer calculateNewValue(Cell<Integer> cell, Integer value, Grid<Integer> grid, Coordinates coordinates) { Random r = new Random(); if(value == BURNING) return EMPTY; for(SpreadingOfFireCell land : ((SpreadingOfFireCell)cell).getNeighbors()) {
|
@Override public Integer calculateNewValue(Cell<Integer> cell, Integer value, Grid<Integer> grid, Coordinates coordinates) { if(value == EMPTY) return EMPTY; double valueProportion = 0; double neighborSize = ((SegregationCell)cell).getNeighbors().size(); for(SegregationCell agent : ((SegregationCell)cell).getNeighbors()) {
|
4..6 lines in PredatorPreyRules (x2)
PredatorPreyRules /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyRules.java |
PredatorPreyRules /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyRules.java |
private Integer movePredator(PredatorPreyCell cell, Grid<Integer> grid, Coordinates coordinates) { cell.tickDeathTimer(); cell.tickBreedingTimer(); if(cell.getDeathTimer() <= 0) return EMPTY; HashSet<PredatorPreyCell> neighbors = ((PredatorPreyCell)cell).getNeighbors(); for(PredatorPreyCell neighbor : neighbors) {
|
private Integer movePrey(PredatorPreyCell cell, Grid<Integer> grid, Coordinates coordinates) { cell.tickBreedingTimer(); HashSet<PredatorPreyCell> neighbors = ((PredatorPreyCell)cell).getNeighbors(); for(PredatorPreyCell neighbor : neighbors) {
|
6..9 lines in PredatorPreyRules (x2)
PredatorPreyRules /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyRules.java |
PredatorPreyRules /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyRules.java |
if(n.getValue() == EMPTY && (n.getNewValue() == null || n.getNewValue() == EMPTY)) { return swap(cell, n); } } if(!getEmptyCells(grid).isEmpty()) { fillRandomEmptyCell(PREDATOR, cell, grid); return EMPTY; }
|
if(neighbor.getValue() == EMPTY && (neighbor.getNewValue() == null || neighbor.getNewValue() == EMPTY)) { return swap(cell, neighbor); } } return PREY;
|
9 lines in SpreadingOfFireCell, PredatorPreyCell
PredatorPreyCell /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyCell.java |
SpreadingOfFireCell /cellsociety_team11/src/cellsociety_team11/spreading_of_fire/SpreadingOfFireCell.java |
public HashSet<PredatorPreyCell> getNeighbors() { int i = coordinates.getI(); int j = coordinates.getJ(); HashSet<PredatorPreyCell> neighbors = new HashSet<PredatorPreyCell>(); for(int y = -1; y <= 1; y++) { for(int x = -1; x <= 1; x++) { if(Math.abs(y) == Math.abs(x)) { continue; }
|
public HashSet<SpreadingOfFireCell> getNeighbors() { int i = coordinates.getI(); int j = coordinates.getJ(); HashSet<SpreadingOfFireCell> neighbors = new HashSet<SpreadingOfFireCell>(); for(int y = -1; y <= 1; y++) { for(int x = -1; x <= 1; x++) { if(y == x) { continue; }
|
9 lines in SegregationCell, GameOfLifeCell
SegregationCell /cellsociety_team11/src/cellsociety_team11/segregation/SegregationCell.java |
GameOfLifeCell /cellsociety_team11/src/cellsociety_team11/game_of_life/GameOfLifeCell.java |
public HashSet<SegregationCell> getNeighbors() { int i = coordinates.getI(); int j = coordinates.getJ(); HashSet<SegregationCell> neighbors = new HashSet<SegregationCell>(); for(int y = -1; y <= 1; y++) { for(int x = -1; x <= 1; x++) { if(y == 0 && x == 0) { continue; }
|
public HashSet<GameOfLifeCell> getNeighbors() { int i = coordinates.getI(); int j = coordinates.getJ(); HashSet<GameOfLifeCell> neighbors = new HashSet<GameOfLifeCell>(); for(int y = -1; y <= 1; y++) { for(int x = -1; x <= 1; x++) { if(y == 0 && x == 0) { continue; }
|
12 lines in SegregationDisplayCell, PredatorPreyDisplayCell, SpreadingOfFireDisplayCell
SpreadingOfFireDisplayCell /cellsociety_team11/src/cellsociety_team11/gui/display_cell_types/SpreadingOfFireDisplayCell.java |
SegregationDisplayCell /cellsociety_team11/src/cellsociety_team11/gui/display_cell_types/SegregationDisplayCell.java |
PredatorPreyDisplayCell /cellsociety_team11/src/cellsociety_team11/gui/display_cell_types/PredatorPreyDisplayCell.java |
@Override protected Color getColor() { if (currentValue.equals(2)){ return Color.RED; } else if(currentValue.equals(1)){ return Color.GREEN; } else{ return Color.GRAY; } }
|
@Override protected Color getColor() { if (currentValue.equals(2)){ return Color.BLACK; } else if(currentValue.equals(1)){ return Color.WHITE; } else{ return Color.GRAY; } }
|
@Override protected Color getColor() { if (currentValue.equals(2)){ return Color.YELLOW; } else if(currentValue.equals(1)){ return Color.RED; } else{ return Color.GRAY; } }
|
5..19 lines in CellSocietyController, Main
Main /cellsociety_team11/src/xml/main/Main.java |
CellSocietyController /cellsociety_team11/src/cellsociety_team11/CellSocietyController.java |
XMLParser parser = new XMLParser(); SimulationXMLFactory factory = new SimulationXMLFactory("Simulation"); /* for (File f : folder.listFiles()) { if (f.isFile() && f.getName().endsWith(XML_SUFFIX)) { try { SimulationXMLModel p = factory.getSimulation(parser.getRootElement(f.getAbsolutePath())); System.out.println(p); } catch (XMLFactoryException e) { System.err.println("Reading file " + f.getPath()); e.printStackTrace(); } } } */ File f = new File(XML_FILE_LOCATION); if (f.isFile() && f.getName().endsWith(XML_SUFFIX)) { try {
|
XMLParser parser = new XMLParser(); SimulationXMLFactory factory = new SimulationXMLFactory("Simulation"); File f = new File(xmlFileLocation); if (f.isFile() && f.getName().endsWith(XML_SUFFIX)) { try {
|
4 lines in SegregationRules, PredatorPreyRules
SegregationRules /cellsociety_team11/src/cellsociety_team11/segregation/SegregationRules.java |
PredatorPreyRules /cellsociety_team11/src/cellsociety_team11/predator_prey/PredatorPreyRules.java |
for(int i = 0; i < grid.getHeight(); i++) { for(int j = 0; j < grid.getWidth(); j++) { if(grid.getGridMatrix()[i][j].getValue() == EMPTY && (grid.getGridMatrix()[i][j].getNewValue() == null || grid.getGridMatrix()[i][j].getNewValue() == EMPTY)) {
|
for(int i = 0; i < grid.getHeight(); i++) { for(int j = 0; j < grid.getWidth(); j++) { if(grid.getGridMatrix()[i][j].getValue() == EMPTY && (grid.getGridMatrix()[i][j].getNewValue() == null || grid.getGridMatrix()[i][j].getNewValue() == EMPTY)) {
|
4 lines in CellSocietyController, Main
CellSocietyController /cellsociety_team11/src/cellsociety_team11/CellSocietyController.java |
Main /cellsociety_team11/src/xml/main/Main.java |
catch (XMLFactoryException e) { System.err.println("Reading file " + f.getPath()); e.printStackTrace(); }
|
catch (XMLFactoryException e) { System.err.println("Reading file " + f.getPath()); e.printStackTrace(); }
|
1 line in DisplayGrid (x2)
DisplayGrid /cellsociety_team11/src/cellsociety_team11/gui/DisplayGrid.java |
DisplayGrid /cellsociety_team11/src/cellsociety_team11/gui/DisplayGrid.java |
for (int i = 0; i < grid.getHeight(); i++){
|
for (int i = 0; i<grid.getHeight(); i++){
|