Optimizing a Game Loop
<p>I'm new to game programming, and I'm currently just conceptualizing the game's engine. I was thinking about a block-based 2d-with-z-axis world, like a 3d Conway's Game of Life, or maybe Dwarf Fortress.</p>

<p>This got me thinking: I need to iterate over every entity in the 3d grid, every game loop. Let's say, 100x100x100 3d cube, plus another 100 if I allow overlaps. That's 1,000,000 to 100,000,000 objects per game loop. Not everything is moving (and of course not everything is rendered), but I need to check everything for physics (which would mean the entity would check the entities above (9), below (9) and besides (8) itself). </p>

<p>How can I optimize my game loop enough to maintain a reasonably fast game loop? </p>

<p>I'm currently using Android's built-in sqlite db to store each block's individual properties like HP and the like, but the gameMap is stored in memory as an array[100][100][100][100][entityId:entityType].</p>

<p>Or am I just overthinking this?</p>
