//A* BootStraper - Scratch X0
//Venkatraman Palani
//CA 686: FX of AI
//Practicum 1;
var cols=5;
var rows=5;
var grid=new Array(cols);
//searchSpace
var oSet=[];
//openSet
var cSet=[];
//closedSet
var s;
var e;
//start & end
var w,h;
//canvas width & height
function node(i,j){
this.x=i;
this.y=j;
this.f=0;
this.g=0;
this.h=0;
this.show=function(){
//fill(255);
//stroke(0);
//rect((this.x*w)+1,(this.y*h)+1,w-1,h-1);
rect(this.x*w,this.y*h,w-5,h-5);
//rect(0,0,w,h)
}
//debug trace 0
}
//grid node & node objects
function setup(){
createCanvas(700,700);
console.log('A*');
//initialize canvas & log header
w=width/cols;
h=height/rows;
//node pixel density (w*h) across canvas per unit grid
for(var i=0; i<cols; i++){
grid[i]=new Array(rows);
}
//create 2D array
for(var i=0; i<cols; i++){
for(var j=0; j<rows; j++){
grid[i][j]=new node(i,j);
}
}
console.log(grid);
//initialize grid indexes with node objects; grid log.
s=grid[0][0];
e=grid[cols-1][rows-1];
//searchSpace** start at grid node = top left & end at grid node = bottom right; **Note: can be randomized.
oSet.push(s);
console.log(oSet);
//openSet loaded with start grid node; log track.
}
function draw(){
background(255,0,0);
//indefinite animate loop (equivalent/~= while 1) & static background
if(oSet.length>0){
//traverse further if openSet is not empty;
}else{
//end traversal
}
for(i=0; i<cols; i++){
for(j=0; j<rows; j++){
grid[i][j].show();
}
}
//debug trace 0
}