I am working on a little puzzle game ( Gem Puzzle).
I have a puzzle Piece object for each piece on the board that has the following attributes:
Position Pcorrect_;
Position Pactuel_;
bool estvide_;
(the 3rd attribute is irrelevant for this question)
The Position is simple structure consisting of:
unsigned ligne;
unsigned colonne;
Each Piece is stored in a vector of a vector.
std::vector<std::vector<Piece>> board_;
The Pieces eventually get mixed around so the correct attribute (location) does not match the actual attribute (location).
I am stuck on a method that should sort the board.The actual position has to match the current position for each piece of the board.
Is there an elegant way of doing this with a sort function ?My current approach is using 4 loops and lots of conditions which is probably the wrong way of doing it.