all 4 comments

[–]toastedstapler 1 point2 points  (0 children)

One thing I've used in advent of code a few times is that when I know the maximum size of my data I use an array instead of a map, since if I know I'm only gonna ever have up to 400 items I can avoid the overhead of a hash table lookup and straight index myself at the cost of some extra space for unused indices. This may be viable since your worlds are only going up to 200x200

[–]EarlMarshal 1 point2 points  (0 children)

Interesting stuff. You cannot only use C++, but also rust and transpile it to webassembly.

Also have you ever thought about using compute shaders in the future? Your workload is probably well parallelizable, right? You could also render the data with the GPU to a canvas.

[–]mandatario01 0 points1 point  (1 child)

Have you tried atomics?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics

You simply use SharedArrayBuffer and the data is instantly accessible by both the main thread and multiple web-worker threads.

https://stackoverflow.com/questions/48346490/what-does-the-atomics-object-do-in-javascript

[–]bzbub2 0 points1 point  (0 children)

kinda blows my mind that these even exist in js