This commit is contained in:
ThomasBallantine 2025-08-12 22:16:04 +01:00
parent aff6562cfe
commit 4fa2c17e4a

View File

@ -96,6 +96,7 @@ void movenorth(Housearray* f, char direction){
int grid_x = f->x·coord - f->x_coord_origin; int grid_x = f->x·coord - f->x_coord_origin;
int grid_y = f->y·coord - f->y_coord_origin; int grid_y = f->y·coord - f->y_coord_origin;
f->houses[grid_y][grid_x]++; f->houses[grid_y][grid_x]++;
//comment
} }
void movesouth(Housearray* f, char direction){ void movesouth(Housearray* f, char direction){
@ -106,7 +107,7 @@ void movesouth(Housearray* f, char direction){
//update y coordinate //update y coordinate
f->y·coord++; f->y·coord++;
//check if expansion needed //check if expansion needed
if (f->y·coord > f->rows·in·array){ if (f->y·coord - f->y_coord_origin >= f->rows·in·array){
//Expand south //Expand south
int new_rows = old_rows +1; int new_rows = old_rows +1;
int new_cols = old_cols; int new_cols = old_cols;
@ -115,12 +116,12 @@ void movesouth(Housearray* f, char direction){
for (int i = 0; i< old_rows; ++i){ for (int i = 0; i< old_rows; ++i){
new_grid[i] = f->houses[i]; new_grid[i] = f->houses[i];
} }
new_grid[0] = (int*)calloc(new_cols, sizeof(int));//Initialising the new row to empty new_grid[new_rows - 1] = (int*)calloc(new_cols, sizeof(int));//Initialising the new row to empty
free(f->houses); free(f->houses);
f->houses = new_grid; f->houses = new_grid;
f->rows·in·array = new_rows; f->rows·in·array = new_rows;
f->columns·in·array = new_cols; f->columns·in·array = new_cols;
f->y_coord_origin++;
} }
//updating the visit count //updating the visit count
int grid_x = f->x·coord - f->x_coord_origin; int grid_x = f->x·coord - f->x_coord_origin;