// get lowest possible position in the specific col public int getRowDepth(int col) { // XXX Memento? for (int row = 0; row < model.numOfRows(); ++row) { if (model.getCell(col, row) != CellState.EMPTY) { // FIXME warum -1? weil bei check horizontal muss ich wieder +1 return row - 1; } } // FIXME warum -1? weil bei check horizontal muss ich wieder +1 return model.numOfRows() - 1; // if whole col is empty, return the // lowest position }
private boolean isInsideBoard(int col, int row) { if (col >= 0 && row >= 0 && col < model.numOfColumns() && row < model.numOfRows()) { return true; } return false; }
private boolean checkVertical(CellState player, int col, int row) { // TODO das muesste doch auch funktionieren wenn man das aktuell // gesetzen feld nicht ueberprueft, weil da // ohnehin der aktuelle spieler drin steht... // dann koennte man auch mode.getwinlength()-1 verwenden, oder? // check downwards if (row + (model.getWinLength()) < model.numOfRows()) { if (model.getCell(col, row + 1) == player && model.getCell(col, row + 2) == player && model.getCell(col, row + 3) == player && model.getCell(col, row + 4) == player) { return true; } } return false; }
public boolean isEmpty(int col) { return isEmpty(col, model.numOfRows() - 1); // check the lowest position // of the column }