MoveDisplay


// Maze

int Cols;  // number across
int Rows;  // number down
float BWidth;  // width of a block
float BHeight; // height of a block

int StartRow;
int StartCol;

// Block Types
int WALL = 0;
int AVAIL = 1;
int PATH = 2;
int VISITED = 3;
int END = 4;

int[][] Dirs = {{0,1}, {-1,0}, {0,-1}, {1,0}};

color BLACK = color(0);
color WHITE = color(255);
color GREY = color(170);
color BLUE = color(100,100,255);
color RED = color(255,0,0);
color GREEN = color(0,255,0);

color[] Colors = {BLACK,WHITE,BLUE,GREY,RED};

Block[][] blocks;

int idraw = 0;
String Filename = "hard-dw.txt";

void setup() {
  size(600,600);
  background(0);
  
  ReadMaze(Filename);
  solve(StartRow,StartCol);
  frameRate(20);
}

void draw() {
}


void ReadMaze(String filename) {
  String[] lines = loadStrings(filename);
  Cols = lines[0].length();
  Rows = lines.length;
  //println(Cols,Rows);
  BWidth = width / (Cols+2.);
  BHeight = height / (Rows+2.);
  
  // Create blocks
  blocks = new Block[Rows][Cols];
  for (int row = 0; row < Rows; ++row)
    for (int col = 0; col < Cols; ++col) {
      float x = col*BWidth;
      float y = row*BHeight;
      char ch = lines[row].charAt(col);
      if (ch == '#') 
        blocks[row][col] = new Block(x,y,BWidth,BHeight,WALL,BLACK);
      else if (ch == ' ') 
        blocks[row][col] = new Block(x,y,BWidth,BHeight,AVAIL,WHITE);
      else if (ch == '?') {
        blocks[row][col] = new Block(x,y,BWidth,BHeight,AVAIL,GREEN);
        StartRow = row;
        StartCol = col;
      }
      else if (ch == '$')
        blocks[row][col] = new Block(x,y,BWidth,BHeight,END,RED);
        
      blocks[row][col].display();
    }
}

boolean solve(int row, int col) {
  // your code here...
  return true;
}