1
\$\begingroup\$

I am developing an 2d open world mmorpg game for learning purposes, and have a issue with big maps.
A year ago i developed 2d open world single player / co-op game. It saved map in chunks, and AI for NPCs starts 'ticking' when specified map chunk is loaded.
In my mmorpg game, NPCs AI is handled by server, and its always 'ticking' in some specified interval. That is where my troubles begin. I want NPC to walk in random directions. For this to work, I have to check map collision for every step, so my NPC wouldn't end up in wall. Problem is when I have big map, for example 10000x10000, and every tile is represented with 6 bytes, that is about 572MB of map data my server must hold in memory all the time, and i cant load just few map chunks, like in my single player RPG because of lot NPCs AI needs to be updated all the time, even if player is not located near by.
My goal is to archive map size of 50000x50000 tiles. I know its possible because i seen 2d mmorpgs with huge open worlds, a lot bigger then 50000x50000, and I doubt that their server have 20GB of ram to waste just on maps.
If anyone have any ideas how I can lower memory usage, I woud like to hear you.

Thanks in advance, and sorry for my bad english

\$\endgroup\$
0

2 Answers 2

5
\$\begingroup\$

First, while MMOs usually have a lot of players online at any one time, these players usually concentrate on key-areas. There are usually large parts of the world where no players are present most of the time. That means you can still use chunks and not keep those in memory which have no players near them.

When you have some NPCs which need to perform some activity even when there is no player nearby, you could simulate these with a simplified model. For example: a blacksmith NPC who makes swords by automatically collecting resources and bringing them to his forge, the simplified model would not do the routefinding but just use an estimation how many swords he would have made during the time no player was nearby, remove the required resources from the surrounding and give him that number of swords.

Should this still require too many resources, you need to design your server infrastructure in a way which allows it to scale over multiple servers. Make it possible to have multiple servers where each server is responsible for only a part of the game world.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Next step after multiple servers with each server responsible for part of the world is that you abstract world zones from servers. A zone can be inactive (sitting in database) if there aren't any players in or near it, or it can be active. Active zone can have it's own server, or in case of multiple zones with low number of players, they can be handled by single server. \$\endgroup\$
    – grega g
    Mar 4, 2014 at 10:27
2
\$\begingroup\$

I suspect these other games aren't updating all npcs at all times. I know the alure of the idea that npcs go about their lives whether there is someone there to see it or not is strong, but then you run in to exactly this problem with large worlds.
The 2 options I can think of are to either only update chunks where a player is close and will see the updates, or to 'fake' the NPC activity at a sort of 'higher level' i.e. you don't need to know that an NPC walked the route Tile 1-2-3-4-5, you just need to know that he was in Tile 1 and in 4 updates he will be in Tile 5.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .