Maze generation

Hi guys. I’ve hit a wall here.

I’m trying to build a generative keith herring’s maze, or something like those grafitti fillings maze, like the image below. I’ve done a few thing, but now I hit a wall and I’m stuck.

I begin using a maze generation algorith. I’ve created three objects: Vertex, Grid and Walker.
The vertex object stores the grid vertices and has a boolean flag to mark if this vertex is used or not.
The grid object stores the vertices in a grid and serves as point references to the walker object
The walker object is the guy that does the work. When spawned it receives a grid start point and marks that point as used.
What I got until now:
a self sentient grid that knows if each vertex is busy or not

What I know that I should do, intend to do and quite don’t know how to do:
search for available neighbors, pick one, add that Vertex to an arraylist that’s inside the Walker object, draw a Path.
Get to know of that after the first picked neighbor, if the next neighbor is the first point in the array list, close the path and build a new walker.

I’m stuck in this part, in the control methods stored inside the walker object. I’ve checked some maze building tutorials and also autonomous behavior tutorials, but right now i’m very confused. So any guidance will be welcome.

This is what i got until now:

main

Grid board;
ArrayList<Walker> harring;
ArrayList<Vertex> stack;

int cols, rows;
int dim=40;
int counter=0;
int num;

void setup() {
  size(800, 800);

  cols=width/dim;
  rows=height/dim;

  board=new Grid();

  harring=new ArrayList<Walker>();
  stack=new ArrayList<Vertex>();

  buildGrid();
  //buildWalker();
}

void draw() {
  background(32);

  board.display();

  for (int i=harring.size()-1; i>=0; i--) {
    Walker w=harring.get(i);
    w.display();
  }
}

void buildGrid() {
  for (int i=0; i<cols+1; i++) {
    for (int j=0; j<rows+1; j++) {
      int num=i+j*(cols+1);
      board.addVertex(i, j, dim, num);
    }
  }
}

void buildWalker() {
  int ind=int(random(board.grid.size()-1));
  println(ind);
  Vertex v1=board.grid.get(ind);
  stack.add(v1);
  Vertex v2=board.grid.get(stack.size()-1); 
  int vi=v1.i;
  int vj=v1.j;
  int vdim=v1.dim;
  int vn=v1.n;
  v1.active=true;
  //harring.add(new Walker(v));
  harring.add(new Walker(vi, vj, vdim, vn));
}

void removeWalker() {
  int ind=harring.size()-1;
  if (ind>=0) {

    Walker w=harring.get(ind);
    Vertex v=stack.get(ind);
    v.active=false;
    harring.remove(ind);
    stack.remove(ind);

  }
}

void keyPressed() {
  if (keyCode==RIGHT) {
    buildWalker();
  }
  if (keyCode==LEFT) {
    removeWalker();
  }
}

int index(int i, int j) {
  if (i<0 || j<0 || i>cols+1 || j>rows+1) {
    return 0;
  } else { 
    return i+j*cols;
  }
}

Vertex class

class Vertex {
  int i, j;
  int x, y;
  int n;
  int dim;
  boolean active=false;

  Vertex(int _i, int _j, int _dim, int _n) {
    i=_i;
    j=_j;
    dim=_dim;
    n=_n;
    x=i*dim;
    y=j*dim;
  }

  void display() {
    if (active) {
      stroke(0, 255, 255);
      strokeWeight(2);
    } else {
      stroke(255, 255, 0);
      strokeWeight(1);
    }
    
    
    pushMatrix();
    translate(x, y);
    line(-2, 0, 2, 0);
    line(0, -2, 0, 2);
    textSize(8);
    //text(n,1,1);
    popMatrix();
  }
}

Grid class

class Grid {
  ArrayList<Vertex> grid=new ArrayList<Vertex>();

  Grid() {
  }

  void addVertex(int i, int j,int dim, int n) {
    grid.add(new Vertex(i,j,dim,n));
  }

  void display() {
    for (Vertex v : grid) {
      v.display();
    }
  }
}

Walker class

class Walker {
  ArrayList<Vertex> vertices=new ArrayList<Vertex>();
  Vertex v;
  int i, j;
  int x, y;
  int dim;
  int n;

  Walker(Vertex _v) {
    v=_v;
    i=v.i;
    j=v.j;
    x=v.x;
    y=v.y;
    n=v.n;
  }

  Walker(int _i, int _j, int _dim, int _n) {
    i=_i;
    j=_j;
    dim=_dim;
    x=i*dim;
    y=j*dim;
    n=_n;
  }

  Vertex checkNeighbors() {
    ArrayList<Vertex> neighbors=new ArrayList<Vertex>();
    Vertex top= board.grid.get(index(i, j-1));
    Vertex right=board.grid.get(index(i+1, j));
    Vertex bottom=board.grid.get(index(i, j+1));
    Vertex left=board.grid.get(index(i-1, j));

    if (neighbors.size()>0) {
      int r=floor(random(0, neighbors.size()));
      return neighbors.get(r);
    } else {
      return null;
    }
  }

  void update() {
    // Vertex next=v.checkNeighbors();
  }

  void display() {
    strokeWeight(2);
    noFill();
    stroke(255, 0, 0);
    pushMatrix();
    translate(x, y);
    ellipse(0, 0, 12, 12);
    text(n, 0, 10);
    popMatrix();
  }
}