From 25629dd65e9f0138c4981b39bfc7968d210aa12b Mon Sep 17 00:00:00 2001 From: shoe Date: Fri, 21 Mar 2025 22:21:43 +0000 Subject: [PATCH] Rename var in a function (can you tell I do not want to add UI) --- walkers.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/walkers.js b/walkers.js index f9605c2..c3e6798 100644 --- a/walkers.js +++ b/walkers.js @@ -83,20 +83,21 @@ function update_walkers() { } } -function add_random_direction(pos) { +// give this function a walker and it will update the walkerition by one tile +function add_random_direction(walker) { let rand = Math.floor(Math.random() * 4); if (rand === 0) { - pos.row++; - pos.row = pos.row.mod(n_rows); + walker.row++; + walker.row = walker.row.mod(n_rows); } else if (rand === 1) { - pos.row--; - pos.row = pos.row.mod(n_rows); + walker.row--; + walker.row = walker.row.mod(n_rows); } else if (rand === 2) { - pos.col++; - pos.col = pos.col.mod(n_cols); + walker.col++; + walker.col = walker.col.mod(n_cols); } else { - pos.col--; - pos.col = pos.col.mod(n_cols); + walker.col--; + walker.col = walker.col.mod(n_cols); } }