publicstaticbooleanemptySpaceExists(Board b) { intsize= b.size(); for (inti=0; i < size; i++) { for (intj=0; j < size; j++) { //return true if any of the tiles are null. if (b.tile(i, j) == null) { returntrue; } } } returnfalse; }
publicstaticbooleanatLeastOneMoveExists(Board b) { // TODO: Fill in this function. if (emptySpaceExists(b)) { returntrue; } intsize= b.size(); for (inti=0; i < size; i++) { for (intj=0; j < size; j++) { //whether there is the same value above. if (j < size - 1 && b.tile(i, j).value() == b.tile(i, j + 1).value()) { returntrue; } //whether there is the same value right. if (i < size - 1 && b.tile(i, j).value() == b.tile(i + 1, j).value()) { returntrue; } } } returnfalse; }