Files
jminos/src/Pieces/Generator.h
2025-03-01 20:27:36 +01:00

41 lines
1.2 KiB
C++

#pragma once
#include "Polyomino.h"
#include <vector>
#include <set>
#include <map>
/**
* A generator of one-sided polyominos of any size
*/
class Generator {
private:
std::vector<Polyomino> validPolyominos; // the list of already generated polyominos
std::set<Position> currentTestedShape; // the polyomino being created
public:
/**
* Default constructor
*/
Generator();
/**
* Generates the list of all one-sided polyominos of the specified size
* @return The list of polyominos
*/
std::vector<Polyomino> generatePolyominos(int polyominoSize);
private:
/**
* Generates all one-sided polyominos of the specified size using the current tested shape
*/
void generate(int polyominoSize, int lastAddedPositionNumber, int nextAvaibleNumber, std::map<Position, int> candidatePositions);
/**
* Checks wheter a candidate position can be added to the current tested shape
*/
void tryToAddCandidatePosition(const Position& candidate, int& nextAvaibleNumber, std::map<Position, int>& candidatePositions);
};