Skip to content

Commit 7d7f986

Browse files
clean: lint code
1 parent 574db52 commit 7d7f986

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

3d/cca_3d.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ export class CCA3D {
202202
this.state[z][y] = []
203203
this.bufferState[z][y] = []
204204
for (let x = 0; x < this.cubeDimension; x++) {
205-
const randomColor = this.colors[Math.floor(Math.random() * this.colors.length)]
205+
const randomColor =
206+
this.colors[Math.floor(Math.random() * this.colors.length)]
206207
const cell = this.createCell(randomColor, x, y, z, false)
207208
this.state[z][y][x] = cell
208209
// Initialize buffer with same properties but without mesh
@@ -283,16 +284,16 @@ export class CCA3D {
283284
const currentCell = this.state[z][y][x]
284285
const nextColorId = nextCellColorId(currentCell, this.colors)
285286
const successorNeighboursCount = this.getNeighbours(x, y, z).filter(
286-
(neighbour) => neighbour.id === nextColorId
287+
(neighbour) => neighbour.id === nextColorId,
287288
).length
288289

289290
if (successorNeighboursCount >= this.threshold) {
290291
const newColor = this.colorMap.get(nextColorId) ?? currentCell
291-
292+
292293
// Update the buffer state
293294
this.bufferState[z][y][x] = {
294295
...newColor,
295-
mesh: currentCell.mesh
296+
mesh: currentCell.mesh,
296297
}
297298

298299
// Update the visual if color changed
@@ -309,7 +310,7 @@ export class CCA3D {
309310
}
310311

311312
// Swap buffers
312-
[this.state, this.bufferState] = [this.bufferState, this.state]
313+
;[this.state, this.bufferState] = [this.bufferState, this.state]
313314
}
314315

315316
private getNeighbours(x: number, y: number, z: number): Cell[] {

main.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ let automaton: AutomatonBase
2929

3030
window.onload = () => {
3131
const getInitialAlgo = () => {
32-
const path = window.location.pathname.slice(1); // Remove leading slash
32+
const path = window.location.pathname.slice(1) // Remove leading slash
3333
const validAlgos = [
34-
"cca-1D", "cca-2D", "cca-3D", "conway",
35-
"immigration", "quadlife", "langton", "entropy"
36-
];
37-
return validAlgos.includes(path) ? path : "cca-2D";
38-
};
34+
"cca-1D",
35+
"cca-2D",
36+
"cca-3D",
37+
"conway",
38+
"immigration",
39+
"quadlife",
40+
"langton",
41+
"entropy",
42+
]
43+
return validAlgos.includes(path) ? path : "cca-2D"
44+
}
3945

4046
pane = new Pane({
4147
title: "Parameters",
@@ -235,9 +241,9 @@ window.onload = () => {
235241

236242
algoSelector.on("change", (event) => {
237243
// Update URL when algorithm changes
238-
const newUrl = `/${event.value}`;
239-
window.history.pushState({}, '', newUrl);
240-
244+
const newUrl = `/${event.value}`
245+
window.history.pushState({}, "", newUrl)
246+
241247
switch (event.value) {
242248
case "cca-1D":
243249
setCca1dBlades()
@@ -268,12 +274,12 @@ window.onload = () => {
268274
})
269275

270276
// Handle browser back/forward navigation
271-
window.addEventListener('popstate', () => {
272-
const newAlgo = getInitialAlgo();
277+
window.addEventListener("popstate", () => {
278+
const newAlgo = getInitialAlgo()
273279
if (newAlgo !== settings.algo) {
274-
algoSelector.value = newAlgo;
280+
algoSelector.value = newAlgo
275281
}
276-
});
282+
})
277283

278284
addBlinkerBtn.on("click", () => {
279285
automaton.placePatternRandomly(blinkerPattern())

0 commit comments

Comments
 (0)