3 ms·
I'm currently writing an MMO. http://www.reddit.com/r/roguelikes/comments/1xa9rj/i_have_been_writing_a_pseudoroguelike_mmorpg_with/ http://www.reddit.com/r/rog
by stcredzero 13y ago
I'm currently writing an MMO.
http://www.reddit.com/r/roguelikes/comments/1xa9rj/i_have_been_writing_a_pseudoroguelike_mmorpg_with/ http://www.reddit.com/r/roguelikes/comments/1xa9rj/i_have_be...
http://www.reddit.com/r/Clojure/comments/1x4ycd/i_have_been_writing_a_pseudoroguelike_mmorpg_in/ http://www.reddit.com/r/Clojure/comments/1x4ycd/i_have_been_...
I am intrigued by actor models, but I can't get my head around what that would mean in terms of architecture. A game loop is easy to understand, especially for functional programming. You just make the world at tick n+1 a function of the world at tick n.
For one thing, this makes server load easy to evaluate. It's just a percentage of simulation tick duration spent in calculation. How would I evaluate that in the actor model?
- pron 13y agoWell, with (concurrent) actors there are no ticks – just like in the real world, and every actor has its own loop. This game also computes an FPS rate. Whenever an actor completes an update, it atomically increments a counter. Every N increments, with N being the number of actors, we say a frame is done. But this is unnecessary. The best way to estimate load is by looking at Quasar's internal execution queues. Also, every actor in this game has a loop of 30ms, i.e. it immediately responds to messages it receives, but if there are none, it updates every 30ms. If you miss that deadline, namely your current run is over 30ms from the previous one, you know the server is overloaded. Of course, the main advantage of working like that is that you get really good parallelism. In a previous blog post where I discussed the standalone simulation[1], I mentioned that you can run it still using actors and still in parallel, but in lockstep using a Phaser. After each cycle, every actor waits for all the others to complete. This gives you "classic" predictability, but you're not making the most out of your hardware as all cores basically become idle after each step, and then you have to start them up again. When the actors run asynchronously, all cores are busy all the time. [1]: http://blog.paralleluniverse.co/2013/10/16/spaceships2/ http://blog.paralleluniverse.co/2013/10/16/spaceships2/
- stcredzero 13y agoThe best way to estimate load is by looking at Quasar's internal execution queues. Yes, but then how do I break things down in specific terms? With the game loop, it's easy for me to just take milliseconds timestamps before and after each subroutine. For example, I can just time how long it takes for me to run (prepopulate-monsters). Also, every actor in this game has a loop of 30ms, i.e. it immediately responds to messages it receives, but if there are none, it updates every 30ms. If you miss that deadline, namely your current run is over 30ms from the previous one, you know the server is overloaded. So then, I have to aggregate the loop running-times for every entity, or take a census of entities overrunning? Of course, the main advantage of working like that is that you get really good parallelism. I've always understood this part. However, consistent game ticks are useful for various aspects of simulation and game AI. but you're not making the most out of your hardware as all cores basically become idle after each step A laudable goal, but what if one is prioritizing "never lag" over efficiency? My game is to have some of the same "a-life simulation with a game attached" quality that Dwarf Fortress has. To ensure that such calculation never interferes with player responsiveness, I was planning to put such background processing on an entirely different instance, then import the resulting evolved monster species into player instances. How would this be architected differently using actors?
- pron 13y ago> With the game loop, it's easy for me to just take milliseconds timestamps before and after each subroutine. For example, I can just time how long it takes for me to run (prepopulate-monsters). Well, you can do the same here, for each actor's loop. With a single loop you're letting your hardware go to waste and limit your scalability. > So then, I have to aggregate the loop running-times for every entity, or take a census of entities overrunning? You can do both. Whatever makes sense for you. > However, consistent game ticks are useful for various aspects of simulation and game AI. Well it's a tradeoff. I think that given the current state of hardware, you need to use all your cores. > A laudable goal, but what if one is prioritizing "never lag" over efficiency? I don't think the two are mutually exclusive. How will you achieve "never lag" if your single thread can't perform all the computation in time? > My game is to have some of the same "a-life simulation with a game attached" quality that Dwarf Fortress has. Sounds like a perfect fit for the actor approach. > To ensure that such calculation never interferes with player responsiveness, I was planning to put such background processing on an entirely different instance, then import the resulting evolved monster species into player instances. How would this be architected differently using actors? Well, you could always still use a single-threaded loop and offload computation to actors. But a better way would be to split each entity to two actors. One for sending feedback to the player, and one for slow computation. If you want to ensure little interference, you can run the different kinds of actors in different Quasar schedulers, each using a different thread-pool, and control the number of threads in each of the pools. Quasar also supports distributed actors, so you can place the slow, computation-heavy ones on different machines, just as you have planned.
- Kiro 13y agoHow can I follow the progress?
- stcredzero 13y agoI will post to HN when I get to the point of having a login and only slightly embarrassing game.