This document contains the results of performing a similar code analysis of projectscellsociety_team06 at 9/29/16 2:17 PM.
11..18 lines in WaTorStepper (x2)
WaTorStepper /cellsociety_team06/src/global_stepper/WaTorStepper.java |
WaTorStepper /cellsociety_team06/src/global_stepper/WaTorStepper.java |
private void updateFish() { // fish update ArrayList<Cell> fishCells = getCellsOfType(board, WaTorRule.FISH_TYPE); for(Cell thisC : fishCells) { WaTorCell thisCell = (WaTorCell) thisC; thisCell.step(); ArrayList<Cell> emptyNeighborCells = this.getCellsOfType(thisCell.getNeighbors(), WaTorRule.EMPTY_TYPE); if(emptyNeighborCells.isEmpty()) // no empty cell continue; WaTorCell targetCell = (WaTorCell) randomAccess(emptyNeighborCells);
|
private void updateShark() { // shark update ArrayList<Cell> sharkCells = getCellsOfType(board, WaTorRule.SHARK_TYPE); for(Cell thisC : sharkCells) { WaTorCell thisCell = (WaTorCell) thisC; thisCell.step(); if(thisCell.getValue().getVal()==WaTorRule.EMPTY_TYPE) { continue; } ArrayList<Cell> neighborCells = this.getCellsOfType(thisCell.getNeighbors(), WaTorRule.EMPTY_TYPE); neighborCells.addAll(this.getCellsOfType(thisCell.getNeighbors(), WaTorRule.FISH_TYPE)); if(neighborCells.isEmpty()) { continue; } WaTorCell targetCell = (WaTorCell)randomAccess(neighborCells);
|
9..11 lines in BaseStepper, SegregationStepper
BaseStepper /cellsociety_team06/src/global_stepper/BaseStepper.java |
SegregationStepper /cellsociety_team06/src/global_stepper/SegregationStepper.java |
protected ArrayList<Cell> getCellsOfType(ArrayList<Cell> cellList, int type) { ArrayList<Cell> cells = new ArrayList<Cell>(); for(Cell c : cellList) { if(c.getValue().getVal()==type) { cells.add(c); } } return cells; }
|
private ArrayList<Cell> getUnhappyIdxs(int thisType, int otherType) { ArrayList<Cell> thisTypeCells = this.getCellsOfType(board, thisType); ArrayList<Cell> unhappyCells = new ArrayList<Cell>(); for(Cell c : thisTypeCells) { int numDiff = this.getCellsOfType(c.getNeighbors(), otherType).size(); if(numDiff/(float)NUM_NEIGHBORS < this.satisfactionThreshold) { unhappyCells.add(c); } } return unhappyCells; }
|
3..4 lines in RandomBoardInitializer, BoardBuilder
BoardBuilder /cellsociety_team06/src/io/BoardBuilder.java |
RandomBoardInitializer /cellsociety_team06/src/io/RandomBoardInitializer.java |
Cell[][] boardArr = new Cell[height][width]; // add cell and append rule for(int h=0; h<height; h++) { for(int w=0; w<width; w++) {
|
Cell[][] board = new Cell[height][width]; for(int i=0; i<height; i++) { for(int j=0; j<width; j++) {
|
4 lines in SpecificationFileParser (x2)
SpecificationFileParser /cellsociety_team06/src/io/SpecificationFileParser.java |
SpecificationFileParser /cellsociety_team06/src/io/SpecificationFileParser.java |
private void parseFireRule(Document d) { double probCatch = Double.parseDouble(this.getUniqueKey(d, "ProbCatch")); rule = new FireRule(probCatch); }
|
private void parseSegregationRule(Document d) { double threshold = Double.parseDouble(this.getUniqueKey(d, "SatisfactionThreshold")); rule = new SegregationRule(threshold); }
|
2 lines in WaTorCell (x2)
WaTorCell /cellsociety_team06/src/cell/WaTorCell.java |
WaTorCell /cellsociety_team06/src/cell/WaTorCell.java |
this.value.setVal(type); currentHealth = ((WaTorRule)this.rule).getInitialHealth();
|
this.value.setVal(type); currentHealth = ((WaTorRule)this.rule).getInitialHealth();
|