Im very new to C++ and I'm having a hard time creating a 3D playing board. Size of the board can increase throughout the course of the game.
My first idea was to use nested vectors.
vector<vector<vector<int>>> board
Idea was, that it would be easily accesible (board[z][y][x]) and I wouldnt have problems with dynamic allocation. However I heard that it's not a good idea to nest vectors, because it breaks "cache friendliness". Instead, I should use 1d vector and "fake" dimension using math.
I think this means to create vector of size (x * y * z). In that case, when I want to "go" to nested_vector_board[0][1][0] I use board[x]. In case I want to go to nested_vector_board[1][1][0], I use board[x * y + x].
Is my understanding correct? What should I do in case of resizing of the board? For example, if I want to make the board wider, it seems I need to manually shift all the data. Even more importantly, is there a better, simpler way to do it?
I will welcome any advice and thank you very much in advance!