Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix randomize walls for large grids #149

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/*
dist/js/bundle.js
dist/js/bundle.js
devuser/
.vscode/
work_recordings/
15 changes: 10 additions & 5 deletions src/Controllers/EnvironmentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ class EnvironmentController extends CanvasController{
let resolution = 20;
Perlin.seed();

for (let r = 0; r < this.env.num_rows; r++) {
for (let c = 0; c < this.env.num_cols; c++) {
let xval = c/this.env.num_cols*(resolution/this.env.renderer.cell_size*(this.env.num_cols/this.env.num_rows));
let yval = r/this.env.num_rows*(resolution/this.env.renderer.cell_size*(this.env.num_rows/this.env.num_cols));
let num_rows = this.env.grid_map.rows
let num_cols = this.env.grid_map.cols
// let num_rows = this.env.num_rows
// let num_cols = this.env.num_cols

for (let r = 0; r < num_rows; r++) {
for (let c = 0; c < num_cols; c++) {
let xval = c/num_cols*(resolution/this.env.renderer.cell_size*(num_cols/num_rows));
let yval = r/num_rows*(resolution/this.env.renderer.cell_size*(num_rows/num_cols));
let noise = Perlin.get(xval, yval);
avg_noise += noise/(this.env.num_rows*this.env.num_cols);
avg_noise += noise/(num_rows*num_cols);
if (noise > noise_threshold && noise < noise_threshold + thickness/resolution) {
let cell = this.env.grid_map.cellAt(c, r);
if (cell != null) {
Expand Down