3 ms·
I've come up with a way, using Clojure, to have a discrete game loop, but still have multicore concurrency and parallelism. This gives one the simplicity of a c
by stcredzero 13y ago
I've come up with a way, using Clojure, to have a discrete game loop, but still have multicore concurrency and parallelism. This gives one the simplicity of a cooperative multitasking model, without having to do explicit yields. It comes at the price of not being able to achieve full use of all of a machine's cores in a single instance, but I don't think this is necessarily a problem. There's this thing called an OS, which would let me achieve nearly full utilization with only a few instances. And by a few, I really do mean single digit numbers. For me, this is preferable, since it eliminates a single point of failure. (To be fair, Erlang also eliminates this if one uses its distribution capabilities intelligently.)
- minikomi 13y agoCare to discuss this in more detail? I'm intrigued.
- stcredzero 13y agoThe world is divided into sub-grids, which are all processed in parallel, minus movements that cross sub-grid boundaries. At the end of the parallel processing, all of the sub-grids are reassembled into a world-grid. (Which takes O(n*Log32(n))) The world-grid acts as a "global" processor and processes all remaining movements. Basically, everything is parallel, except that which has to be processed globally, which is just a tiny minority of everything. Then there is a non-parallelized step that knits together and coordinates the global grid. If you plotted parallelism over time, it would probably look like a saw tooth or a square wave. Right now, there are only two tiers, but this could be generalized into a structure like an R-tree, which would probably make the algorithm cache oblivious. It's the "knitting" step that keeps it from utilizing 100% of the cores in parallel with just one instance. I still hope to be able to support 1000's of entities with just one instance, however.
- minikomi 13y agoVery interesting, thank you.