D
Dennis Ross Tudor Jr
Guest
I am supplying a script and the output it produced. The issue I am having is that the output shows that it's adding a value to the grid, but when the script sums of the region of the grid it found no values. Is there something wrong with the ds_grid_get_sum() function or am I not seeing something here? I've been up for more than a few hours now
The grid is actually twice the size of the board(16x8), hence the topRow variable (which == 8 by the way)
NUM_OF_ROWS=16
NUM_OF_COLS=8
When the Explode grid is viewed or printed out there are 1's where exploded cells should be so the region should add up to more than zero.
the last line of the output should have produced
AssignExplodeGrid script --> value of sums: 6+ (at least 6 but at most 9 -> depending how the 3 triplets were lined up.
Code:
show_debug_message("AssignExplodeGrid script --> assigning horizontal explodes");
var row,col;
// assign horizonal values to explode board
for(row=topRow;row<NUM_OF_ROWS;row++){
for(col=0;col<NUM_OF_COLS-2;col++){
var b1,b2,b3;
b1=ds_grid_get(Board,row,col);
b2=ds_grid_get(Board,row,col+1);
b3=ds_grid_get(Board,row,col+2);
if(b1.stoneType==b2.stoneType && b1.stoneType==b3.stoneType){
show_debug_message("AssignExplodeGrid script --> match horizontal");
b1.explode=true;
b2.explode=true; // TODO: remove redundancy
b3.explode=true; // by advancing 'col'
ds_grid_set(ExplodeBoard,row,col,1);
ds_grid_set(ExplodeBoard,row,col+1,1);
ds_grid_set(ExplodeBoard,row,col+2,1);
}
}
}
show_debug_message("AssignExplodeGrid script --> assigning vertical explodes");
// assign vertical values to explode board
for(row=topRow;row<NUM_OF_ROWS-2;row++){
for(col=0;col<NUM_OF_COLS;col++){
b1=ds_grid_get(Board,row,col);
b2=ds_grid_get(Board,row+1,col);
b3=ds_grid_get(Board,row+2,col);
if(b1.stoneType==b2.stoneType && b1.stoneType==b3.stoneType){
show_debug_message("AssignExplodeGrid script --> match vertical");
b1.explode=true;
b2.explode=true;
b3.explode=true;
ds_grid_set(ExplodeBoard,row,col,1);
ds_grid_set(ExplodeBoard,row+1,col,1);
ds_grid_set(ExplodeBoard,row+2,col,1);
}
}
}
var value;
value=ds_grid_get_sum(ExplodeBoard,0,topRow,NUM_OF_COLS,NUM_OF_ROWS);
show_debug_message("AssignExplodeGrid script --> value of sums: "+string(value));
Code:
AssignExplodeGrid script --> assigning horizontal explodes
AssignExplodeGrid script --> match horizontal
AssignExplodeGrid script --> match horizontal
AssignExplodeGrid script --> assigning vertical explodes
AssignExplodeGrid script --> match vertical
AssignExplodeGrid script --> value of sums: 0
NUM_OF_ROWS=16
NUM_OF_COLS=8
When the Explode grid is viewed or printed out there are 1's where exploded cells should be so the region should add up to more than zero.
the last line of the output should have produced
AssignExplodeGrid script --> value of sums: 6+ (at least 6 but at most 9 -> depending how the 3 triplets were lined up.