Sparse (Pseudo) Infinite Grid Data Structure for Web Game

Posted by Ming on Stack Overflow See other posts from Stack Overflow or by Ming
Published on 2011-11-13T04:48:44Z Indexed on 2011/11/13 17:50 UTC
Read the original article Hit count: 269

I'm considering trying to make a game that takes place on an essentially infinite grid.

  • The grid is very sparse. Certain small regions of relatively high density. Relatively few isolated nonempty cells.
  • The amount of the grid in use is too large to implement naively but probably smallish by "big data" standards (I'm not trying to map the Internet or anything like that)
  • This needs to be easy to persist.

Here are the operations I may want to perform (reasonably efficiently) on this grid:

  • Ask for some small rectangular region of cells and all their contents (a player's current neighborhood)
  • Set individual cells or blit small regions (the player is making a move)
  • Ask for the rough shape or outline/silhouette of some larger rectangular regions (a world map or region preview)
  • Find some regions with approximately a given density (player spawning location)
  • Approximate shortest path through gaps of at most some small constant empty spaces per hop (it's OK to be a bad approximation often, but not OK to keep heading the wrong direction searching)
  • Approximate convex hull for a region

Here's the catch: I want to do this in a web app. That is, I would prefer to use existing data storage (perhaps in the form of a relational database) and relatively little external dependency (preferably avoiding the need for a persistent process).

Guys, what advice can you give me on actually implementing this? How would you do this if the web-app restrictions weren't in place? How would you modify that if they were?

Thanks a lot, everyone!

© Stack Overflow or respective owner

Related posts about web-development

Related posts about algorithm