ff windaube veut toujours pas
All checks were successful
Linux arm64 / Build (push) Successful in 2m45s
All checks were successful
Linux arm64 / Build (push) Successful in 2m45s
This commit is contained in:
@@ -92,7 +92,7 @@ If for some reasons you wanna run the command line version (not updated):
|
|||||||
### One-sided n-polyominoes
|
### One-sided n-polyominoes
|
||||||
|
|
||||||
| n | Number | Generation | File storing | File retrieving | File size |
|
| n | Number | Generation | File storing | File retrieving | File size |
|
||||||
| - | - | - | - | - | - |
|
| -: | -: | :-: | :-: | :-: | -: |
|
||||||
| 1 | 1 | 0s 0.005622ms | 0s 0.750955ms | 0s 0.014016ms | 2 bytes |
|
| 1 | 1 | 0s 0.005622ms | 0s 0.750955ms | 0s 0.014016ms | 2 bytes |
|
||||||
| 2 | 1 | 0s 0.005758ms | 0s 0.181323ms | 0s 0.012256ms | 3 bytes |
|
| 2 | 1 | 0s 0.005758ms | 0s 0.181323ms | 0s 0.012256ms | 3 bytes |
|
||||||
| 3 | 2 | 0s 0.017525ms | 0s 0.054497ms | 0s 0.006431ms | 8 bytes |
|
| 3 | 2 | 0s 0.017525ms | 0s 0.054497ms | 0s 0.006431ms | 8 bytes |
|
||||||
@@ -109,12 +109,13 @@ If for some reasons you wanna run the command line version (not updated):
|
|||||||
| 14 | 1802312 | 45s 606.597ms | 32s 28.7977ms | 2s 919.653ms | 27034680 bytes |
|
| 14 | 1802312 | 45s 606.597ms | 32s 28.7977ms | 2s 919.653ms | 27034680 bytes |
|
||||||
| 15 | ~6M | ~5mn | ~5mn | ~10s | ~100 MB |
|
| 15 | ~6M | ~5mn | ~5mn | ~10s | ~100 MB |
|
||||||
|
|
||||||
_File storing includes normalizing and sorting all polyominoes before writing them to the file._
|
_File storing includes type checking and sorting all polyominoes before writing them to the file._
|
||||||
If you want to know more details about the generation and storage of polyominoes, [check the documentation](/doc/)!
|
If you want to know more details about the generation and storage of polyominoes, [check the documentation](/doc/)!
|
||||||
|
|
||||||
Run it yourself by typing:
|
Run it yourself by typing:
|
||||||
``xmake build benchmark``
|
``xmake f -m release``
|
||||||
``xmake run benchmark``
|
``xmake build bmark``
|
||||||
|
``xmake run bmark``
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ int main() {
|
|||||||
PiecesFiles pf;
|
PiecesFiles pf;
|
||||||
for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) {
|
for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) {
|
||||||
if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) {
|
if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) {
|
||||||
#ifdef NDEBUG
|
#ifndef DEBUG
|
||||||
std::cout << "IMPORTANT: You are currently in release mode, if you do not wish to generate big pieces (can take several minutes), type 'xmake f -m debug'." << std::endl;
|
std::cout << "IMPORTANT: You are currently in release mode, if you do not wish to generate big pieces (can take several minutes), type 'xmake f -m debug'." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ int main() {
|
|||||||
pf.savePieces(i);
|
pf.savePieces(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "IMPORTANT: You are currently in debug mode, if you wish to use bigger pieces, type 'xmake f -m release'." << std::endl;
|
std::cout << "IMPORTANT: You are currently in debug mode, if you wish to use bigger pieces, type 'xmake f -m release'." << std::endl;
|
||||||
|
|
||||||
bool everythingGenerated = true;
|
bool everythingGenerated = true;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void Generator::generate(int polyominoSize, int lastAddedPositionNumber, int nex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate the list of candidate positions
|
// generate the list of candidate positions
|
||||||
for (Position position : this->currentTestedShape) {
|
for (const Position position : this->currentTestedShape) {
|
||||||
this->tryToAddCandidatePosition(Position{position.x, position.y + 1}, nextAvaibleNumber, candidatePositions);
|
this->tryToAddCandidatePosition(Position{position.x, position.y + 1}, nextAvaibleNumber, candidatePositions);
|
||||||
this->tryToAddCandidatePosition(Position{position.x + 1, position.y}, nextAvaibleNumber, candidatePositions);
|
this->tryToAddCandidatePosition(Position{position.x + 1, position.y}, nextAvaibleNumber, candidatePositions);
|
||||||
this->tryToAddCandidatePosition(Position{position.x, position.y - 1}, nextAvaibleNumber, candidatePositions);
|
this->tryToAddCandidatePosition(Position{position.x, position.y - 1}, nextAvaibleNumber, candidatePositions);
|
||||||
@@ -58,7 +58,7 @@ void Generator::generate(int polyominoSize, int lastAddedPositionNumber, int nex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try adding a square only to positions with a higher number than the last one
|
// try adding a square only to positions with a higher number than the last one
|
||||||
for (auto [key, val] : candidatePositions) {
|
for (const auto [key, val] : candidatePositions) {
|
||||||
if (val > lastAddedPositionNumber) {
|
if (val > lastAddedPositionNumber) {
|
||||||
this->currentTestedShape.insert(key);
|
this->currentTestedShape.insert(key);
|
||||||
this->generate(polyominoSize, val, nextAvaibleNumber, (polyominoSize == this->currentTestedShape.size()) ? std::map<Position, int>() : candidatePositions);
|
this->generate(polyominoSize, val, nextAvaibleNumber, (polyominoSize == this->currentTestedShape.size()) ? std::map<Position, int>() : candidatePositions);
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ bool PiecesFiles::savePieces(int polyominoSize, std::vector<Polyomino>& polyomin
|
|||||||
|
|
||||||
for (const Polyomino& polyomino : polyominoes) {
|
for (const Polyomino& polyomino : polyominoes) {
|
||||||
// write the characteristics of the piece
|
// write the characteristics of the piece
|
||||||
char infoByte = (polyomino.isConvex() << 7) + (polyomino.hasHole() << 6) + polyomino.getLength();
|
bool isConvex = polyomino.isConvex();
|
||||||
|
bool hasHole = (isConvex) ? false : polyomino.hasHole();
|
||||||
|
char infoByte = (isConvex << 7) + (hasHole << 6) + polyomino.getLength();
|
||||||
piecesFile.write(&infoByte, 1);
|
piecesFile.write(&infoByte, 1);
|
||||||
|
|
||||||
// write the positions of the piece
|
// write the positions of the piece
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Polyomino::Polyomino(const std::set<Position>& positions) {
|
|||||||
int maxX = INT_MIN;
|
int maxX = INT_MIN;
|
||||||
int minY = INT_MAX;
|
int minY = INT_MAX;
|
||||||
int maxY = INT_MIN;
|
int maxY = INT_MIN;
|
||||||
for (Position position : positions) {
|
for (const Position position : positions) {
|
||||||
if (position.x < minX) minX = position.x;
|
if (position.x < minX) minX = position.x;
|
||||||
if (position.x > maxX) maxX = position.x;
|
if (position.x > maxX) maxX = position.x;
|
||||||
if (position.y < minY) minY = position.y;
|
if (position.y < minY) minY = position.y;
|
||||||
@@ -40,13 +40,13 @@ Polyomino::Polyomino(const std::set<Position>& positions, int length) :
|
|||||||
void Polyomino::normalize() {
|
void Polyomino::normalize() {
|
||||||
int minX = INT_MAX;
|
int minX = INT_MAX;
|
||||||
int minY = INT_MAX;
|
int minY = INT_MAX;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
if (position.x < minX) minX = position.x;
|
if (position.x < minX) minX = position.x;
|
||||||
if (position.y < minY) minY = position.y;
|
if (position.y < minY) minY = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Position> newPositions;
|
std::set<Position> newPositions;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
newPositions.insert(Position{position.x - minX, position.y - minY});
|
newPositions.insert(Position{position.x - minX, position.y - minY});
|
||||||
}
|
}
|
||||||
this->positions = std::move(newPositions);
|
this->positions = std::move(newPositions);
|
||||||
@@ -54,7 +54,7 @@ void Polyomino::normalize() {
|
|||||||
|
|
||||||
void Polyomino::rotateCW() {
|
void Polyomino::rotateCW() {
|
||||||
std::set<Position> newPositions;
|
std::set<Position> newPositions;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
newPositions.insert(Position{position.y, (length - 1) - (position.x)});
|
newPositions.insert(Position{position.y, (length - 1) - (position.x)});
|
||||||
}
|
}
|
||||||
this->positions = std::move(newPositions);
|
this->positions = std::move(newPositions);
|
||||||
@@ -62,7 +62,7 @@ void Polyomino::rotateCW() {
|
|||||||
|
|
||||||
void Polyomino::rotate180() {
|
void Polyomino::rotate180() {
|
||||||
std::set<Position> newPositions;
|
std::set<Position> newPositions;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
newPositions.insert(Position{(length - 1) - (position.x), (length - 1) - (position.y)});
|
newPositions.insert(Position{(length - 1) - (position.x), (length - 1) - (position.y)});
|
||||||
}
|
}
|
||||||
this->positions = std::move(newPositions);
|
this->positions = std::move(newPositions);
|
||||||
@@ -70,7 +70,7 @@ void Polyomino::rotate180() {
|
|||||||
|
|
||||||
void Polyomino::rotateCCW() {
|
void Polyomino::rotateCCW() {
|
||||||
std::set<Position> newPositions;
|
std::set<Position> newPositions;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
newPositions.insert(Position{(length - 1) - (position.y), position.x});
|
newPositions.insert(Position{(length - 1) - (position.y), position.x});
|
||||||
}
|
}
|
||||||
this->positions = std::move(newPositions);
|
this->positions = std::move(newPositions);
|
||||||
@@ -89,7 +89,7 @@ void Polyomino::goToSpawnPosition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculates amount of squares per rows and columns
|
// calculates amount of squares per rows and columns
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
linesCompleteness.at(0).at(position.y) += 1; // 0 = bottom to top = no rotation
|
linesCompleteness.at(0).at(position.y) += 1; // 0 = bottom to top = no rotation
|
||||||
linesCompleteness.at(1).at((length - 1) - position.x) += 1; // 1 = right to left = CW
|
linesCompleteness.at(1).at((length - 1) - position.x) += 1; // 1 = right to left = CW
|
||||||
linesCompleteness.at(2).at((length - 1) - position.y) += 1; // 2 = top to bottom = 180
|
linesCompleteness.at(2).at((length - 1) - position.y) += 1; // 2 = top to bottom = 180
|
||||||
@@ -158,14 +158,14 @@ void Polyomino::goToSpawnPosition() {
|
|||||||
|
|
||||||
int minX = INT_MAX;
|
int minX = INT_MAX;
|
||||||
int minY = INT_MAX;
|
int minY = INT_MAX;
|
||||||
for (Position position : this->positions) {
|
for (const Position position : this->positions) {
|
||||||
if (position.x < minX) minX = position.x;
|
if (position.x < minX) minX = position.x;
|
||||||
if (position.y < minY) minY = position.y;
|
if (position.y < minY) minY = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// center the piece with an up bias
|
// center the piece with an up bias
|
||||||
std::set<Position> newPositions;
|
std::set<Position> newPositions;
|
||||||
for (Position position : positions) {
|
for (const Position position : positions) {
|
||||||
newPositions.insert(Position{(position.x - minX) + (verticalEmptyLines / 2), (position.y - minY) + ((horizontalEmptyLines + 1) / 2)});
|
newPositions.insert(Position{(position.x - minX) + (verticalEmptyLines / 2), (position.y - minY) + ((horizontalEmptyLines + 1) / 2)});
|
||||||
}
|
}
|
||||||
this->positions = std::move(newPositions);
|
this->positions = std::move(newPositions);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ int main(int argc, char** argv) {
|
|||||||
std::srand(std::time(NULL));
|
std::srand(std::time(NULL));
|
||||||
|
|
||||||
#ifdef BENCHMARK
|
#ifdef BENCHMARK
|
||||||
#ifndef NDEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "IMPORTANT: You are currently in debug mode, debug mode has lowest optimization settings and thus yields worse benchmarking results, to switch to release mode, type 'xmake f -m debug'." << std::endl;
|
std::cout << "IMPORTANT: You are currently in debug mode, debug mode has lowest optimization settings and thus yields worse benchmarking results, to switch to release mode, type 'xmake f -m debug'." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ void benchmarking(int min_size, int max_size) {
|
|||||||
using std::chrono::milliseconds;
|
using std::chrono::milliseconds;
|
||||||
|
|
||||||
std::cout << "| n | Number | Generation | File storing | File retrieving | File size |" << std::endl;
|
std::cout << "| n | Number | Generation | File storing | File retrieving | File size |" << std::endl;
|
||||||
std::cout << "| - | - | - | - | - | - |" << std::endl;
|
std::cout << "| -: | -: | :-: | :-: | :-: | -: |" << std::endl;
|
||||||
|
|
||||||
Generator gen;
|
Generator gen;
|
||||||
PiecesFiles pf;
|
PiecesFiles pf;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ target("text")
|
|||||||
add_files("./src/TextUI/*.cpp")
|
add_files("./src/TextUI/*.cpp")
|
||||||
add_deps("core")
|
add_deps("core")
|
||||||
|
|
||||||
target("benchmark")
|
target("bmark")
|
||||||
set_default(false)
|
set_default(false)
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
add_files("./src/TextUI/*.cpp")
|
add_files("./src/TextUI/*.cpp")
|
||||||
@@ -39,8 +39,8 @@ target("graph")
|
|||||||
add_deps("core")
|
add_deps("core")
|
||||||
add_packages("sfml")
|
add_packages("sfml")
|
||||||
|
|
||||||
if is_mode("release") then
|
if is_mode("debug") then
|
||||||
add_defines("NDEBUG")
|
add_defines("DEBUG")
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_plat("mingw") then
|
if is_plat("mingw") then
|
||||||
|
|||||||
Reference in New Issue
Block a user