summaryrefslogtreecommitdiff
path: root/maize-maze/js/helpers.js
diff options
context:
space:
mode:
authorLizzy Hunt <lizzy.hunt@usu.edu>2024-01-12 19:13:13 -0700
committerLizzy Hunt <lizzy.hunt@usu.edu>2024-01-12 19:13:13 -0700
commit07670ef8afb5a273267ea7149d5f7eef02fdf66b (patch)
tree2d0c8e64936c7fa2588786f4af199abf1bb48a60 /maize-maze/js/helpers.js
parent3ac982dfa653f0eb7fbceeb1678a3cae93b512f4 (diff)
downloadsimponic.xyz-07670ef8afb5a273267ea7149d5f7eef02fdf66b.tar.gz
simponic.xyz-07670ef8afb5a273267ea7149d5f7eef02fdf66b.zip
add subprojects
Diffstat (limited to 'maize-maze/js/helpers.js')
-rw-r--r--maize-maze/js/helpers.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/maize-maze/js/helpers.js b/maize-maze/js/helpers.js
new file mode 100644
index 0000000..1bc6579
--- /dev/null
+++ b/maize-maze/js/helpers.js
@@ -0,0 +1,18 @@
+function random_in_range(a,z) {
+ return Math.floor(Math.random() * (z - a) + a);
+}
+
+function shuffle_array(a) {
+ for (let i = 0; i < a.length; i++) {
+ let j = random_in_range(0, i+1);
+ temp = a[i]; a[i] = a[j]; a[j] = temp;
+ }
+}
+
+function sub(p1, p2) {
+ return [p1[0] - p2[0], p1[1] - p2[1]];
+}
+
+function any(l) {
+ return l.filter((x) => x).length > 0;
+} \ No newline at end of file