Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cubedhuang committed Nov 19, 2024
1 parent c921dcc commit e453033
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"tabWidth": 4,
"useTabs": true,
"trailingComma": "none"
}
10 changes: 6 additions & 4 deletions js/boid.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class Boid extends V2D {
const ns = [];
const ds = [];

const candidate_count = cands.map(c => c.length).reduce((a, b) => a + b, 0);
let step = opt.accuracy === 0 ? 1 : Math.ceil(candidate_count / opt.accuracy);
const candidate_count = cands
.map(c => c.length)
.reduce((a, b) => a + b, 0);
let step =
opt.accuracy === 0 ? 1 : Math.ceil(candidate_count / opt.accuracy);
let i = Math.floor(random(step));

for (const c of cands) {
Expand Down Expand Up @@ -77,8 +80,7 @@ class Boid extends V2D {
if (ns.length > 0) {
aln.setMag(opt.maxSpeed).sub(this.vel).max(opt.maxForce);

csn
.div(ns.length)
csn.div(ns.length)
.sub(this)
.setMag(opt.maxSpeed)
.sub(this.vel)
Expand Down
13 changes: 9 additions & 4 deletions js/opt.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ const opt = (() => {

if (data.maxSpeed <= data.minSpeed) $min.value = data.maxSpeed;
} else if (model === "accuracyPower") {
data.accuracy = data.accuracyPower >= 10 ? 0 : 2 ** data.accuracyPower;
data.accuracy =
data.accuracyPower >= 10 ? 0 : 2 ** data.accuracyPower;

select(`[data-show=accuracy]`).textContent = Math.floor(data.accuracy);
select(`[data-show=accuracy]`).textContent = Math.floor(
data.accuracy
);
return;
} else if (model === "vision") g.shapeMode++;

Expand Down Expand Up @@ -166,7 +169,8 @@ const opt = (() => {

if (!k) continue;

if (typeof value === "boolean") array.push(`${k}=${value ? "1" : "0"}`);
if (typeof value === "boolean")
array.push(`${k}=${value ? "1" : "0"}`);
else array.push(`${k}=${value}`);
}

Expand Down Expand Up @@ -214,7 +218,8 @@ const opt = (() => {
}
}

data.accuracy = data.accuracyPower >= 10 ? 0 : 2 ** data.accuracyPower;
data.accuracy =
data.accuracyPower >= 10 ? 0 : 2 ** data.accuracyPower;
methods.leaveMenu();
updateAll();
},
Expand Down
3 changes: 2 additions & 1 deletion js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ const opt = new Vue({

const k = this.special.encode[key];

if (typeof value === "boolean") array.push(`${k}=${value ? "1" : "0"}`);
if (typeof value === "boolean")
array.push(`${k}=${value ? "1" : "0"}`);
else array.push(`${k}=${value}`);
}

Expand Down

0 comments on commit e453033

Please sign in to comment.