Closed gr_set_random_grid function