Skip to content

Commit cf5ab31

Browse files
committed
initial random weights
1 parent acbfdc1 commit cf5ab31

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/pages/particle-life/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export default function ParticleLifePage() {
4141
const [fps, setFps] = useState(0)
4242
const [workers] = useState(() => Math.max(1, navigator.hardwareConcurrency - 1))
4343
const [formatter] = useState(() => new Intl.NumberFormat(undefined, { maximumFractionDigits: 0, minimumIntegerDigits: 3 }))
44+
const [initialWeights] = useState(() => {
45+
const weights = new Array(COLORS.length * COLORS.length)
46+
for (let i = 0; i < weights.length; i++) {
47+
weights[i] = (Math.random() * 2 - 1).toFixed(2)
48+
}
49+
return weights
50+
})
4451

4552
useEffect(() => {
4653
const form = formRef.current!
@@ -243,9 +250,14 @@ export default function ParticleLifePage() {
243250
</th>
244251
{Array.from({ length: colors }).map((_, j) => (
245252
<td key={j}>
246-
<input type="number" name={`attraction_${i}_${j}`} defaultValue={i === j ? "1" : "0"} step="0.1" min="-1" max="1" />
253+
<input type="number" name={`attraction_${i}_${j}`} defaultValue={initialWeights[i * COLORS.length + j]} step="0.1" min="-1" max="1" />
247254
</td>
248255
))}
256+
{/* {Array.from({ length: colors }).map((_, j) => (
257+
<td key={j}>
258+
<input type="number" name={`attraction_${i}_${j}`} defaultValue={i === j ? "1" : "0"} step="0.1" min="-1" max="1" />
259+
</td>
260+
))} */}
249261
</tr>
250262
))}
251263
</tbody>

src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export const ROUTES = {
235235
tags: ['simulation', 'canvas', 'particles'],
236236
},
237237
git: {
238-
lastModified: 1762271198000,
238+
lastModified: 1762282622000,
239239
firstAdded: 1760880322000
240240
},
241241
},

0 commit comments

Comments
 (0)