static bool countNeighbor(Point_int p, int branch_max) { int i; int count = 0; Point_int p2; for (i = 0; i < D2; i++) { p2.x = p.x + dx[i]; p2.y = p.y + dy[i]; if (inBound(p2) && !isEmpty(p2)) { count++; } } return(count < branch_max); }
static bool isEmpty(Point_int p) { return(map[p.x, p.y] == 0); }
static bool inBound(Point_int p) { return(p.x >= 0 && p.x < xmax && p.y >= 0 && p.y < ymax); }