C
Carbiner
Guest
Hello!
I'm having some trouble condensing a two-dimensional Ds_grid into a one-dimensional Ds_grid. The problem is that the 2D grid is of varying size, and the 1D grid is of fixed length.
I know I can't just read the 2D grid, so I want to take the mean of a region of the 2D grid and set my 'next' 1D cell equal to that mean. I do know that the 2D grid will always be square, and its size should always fit nicely into the 1D grid. I just can't seem to make that work, though.
Here's what I've come up with so far:
Here's a picture for how it's supposed to work in my mind, as an example:
Edited for clarity
I'm having some trouble condensing a two-dimensional Ds_grid into a one-dimensional Ds_grid. The problem is that the 2D grid is of varying size, and the 1D grid is of fixed length.
I know I can't just read the 2D grid, so I want to take the mean of a region of the 2D grid and set my 'next' 1D cell equal to that mean. I do know that the 2D grid will always be square, and its size should always fit nicely into the 1D grid. I just can't seem to make that work, though.
Here's what I've come up with so far:
Code:
var region_size = xcells mod (input_grid_size div cell_size);
// Input Grid Size (32) is the Number of Xcells and Ycells. So there are a total of 1024 input grid cells.
// Xcells is the number of horizontal cells in the heat map. There are an equal number of ycells because the rooms are square.
// Cell Size is the number of pixels that each cell of the heat map represents in it's horizontal or verticle direction. So right now, each heat map cell represents 64 pixels
var i,ii,avg_heat;
var counter = 0;
for(i=0;i<xcells;i+=1+region_size)
{
for(ii=0;ii<ycells;ii+=1+region_size)
{
avg_heat = ds_grid_get_mean(heat_map,i,ii,i+region_size,ii+region_size);
input_grid[# 0, counter] = avg_heat;
counter++;
}
}
show_debug_message("Input Nodes: " + string(sqr(input_grid_size))-1); // -1 because it starts at 0 and counter starts at 0
show_debug_message("Inputed Nodes: " + string(counter)); // These should be equal
Edited for clarity
Last edited by a moderator: