I’m developing an AI-driven fantasy world generator(Meaning that the resident NPCs will take care of doing everything after the initial “normal” generation.) with the aim of making it generate the most engaging worlds possible. Basically my own Dwarf Fortress to lord over, gameplay- and complexity- wise. I’m starting out small, though, so for now, it’s a 100x100 plate of rock and few NPCs on it. I want to see if they will properly seek out water and food if I make them go thirsty and hungry.
But first, I wanted to ask something about my implementation of the Block class, intended to represent every single block in the game world:
public class Block {
int posX, posY, posZ;
Material material;
BlockShape shape;
ArrayList<Object> objects;
public Block(int posX, int posY, int posZ) {
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
}
The idea is for the blocks to have obviously their coordinates, then the material they’re made of(dirst, iron ore, adamantium,…), then their shape(solid, ramp, column, hewn wall,…), and then a list of diverse other objects that may be in the block(NPCs, furniture, projectile, effect of a spell, item, remains, some flora, fluid…). Coordinates stay the same, the other stuff is initialized(and deleted) as needed during world generation/gameplay. So, folks with a more extensive knowledge and experience with running times and data structure(I know, technically, there’s no data structure yet, but bear with me) optimization: Do you see any obvious red lights in there; could this cause a huge slowdown or save bloat? There’s gonna be a lot of these in the game, and they’re going to go through a huge number of AI checks, so I figured out I’d ask beforehand, rather than having to weed out such an elementary feature out of everything later and rework it.