fixed it!!!!
This commit is contained in:
@@ -74,8 +74,6 @@ struct Solver {
|
||||
SomaSolutionList *solutions;
|
||||
};
|
||||
|
||||
uint64 STD_SOMA[] = { 23ul, 30ul, 15ul, 1043ul, 24594ul, 12306ul, 11ul };
|
||||
|
||||
/*
|
||||
void backtrack_solve_iter(std::vector<uint64> *polycube_input, std::vector<int> *offsets) {
|
||||
size_t num_inputs = offsets->size() - 1;
|
||||
@@ -161,7 +159,7 @@ SomaSolutionList getSolutionRotations(Arena *arena, SomaSolution *solution, int
|
||||
result.data[i] = PushList(arena, SomaSolution, solution->length);
|
||||
}
|
||||
for (int piece_i = 0; piece_i < solution->length; piece_i++) {
|
||||
Space space = {
|
||||
VoxelSpace space = {
|
||||
solution->data[piece_i],
|
||||
dims[0],
|
||||
dims[1],
|
||||
@@ -222,15 +220,15 @@ uint64 factorial(int n) {
|
||||
return result;
|
||||
}
|
||||
|
||||
SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
SomaSolutionList solve(VoxelSpaceReprList reprsInput, int dims[3]) {
|
||||
Arena *arena = arenaAlloc(Megabytes(64));
|
||||
Arena *permsArena = arenaAlloc(Megabytes(128));
|
||||
|
||||
OffsetList offsets = PushList(arena, OffsetList, reprs_in_count + 1);
|
||||
OffsetList offsets = PushList(arena, OffsetList, reprsInput.length + 1);
|
||||
|
||||
VoxelSpaceReprList polycubes = PushList(arena, VoxelSpaceReprList, 0);
|
||||
|
||||
Space empty_voxel_space = {
|
||||
VoxelSpace emptyVoxelSpace = {
|
||||
0,
|
||||
dims[0],
|
||||
dims[1],
|
||||
@@ -242,10 +240,10 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
uint64 possibleCombos = 0;
|
||||
|
||||
{
|
||||
Space space = empty_voxel_space;
|
||||
space.space = reprs_in[0];
|
||||
cullEmptySpace(&space);
|
||||
VoxelSpaceReprList positions = getAllPositionsInPrism(permsArena, &space, dims);
|
||||
VoxelSpace voxelSpace = emptyVoxelSpace;
|
||||
voxelSpace.space = reprsInput.data[0];
|
||||
cullEmptySpace(&voxelSpace);
|
||||
VoxelSpaceReprList positions = getAllPositionsInPrism(permsArena, &voxelSpace, dims);
|
||||
possibleCombos += positions.length;
|
||||
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, positions.capacity);
|
||||
polycubes.capacity += positions.capacity;
|
||||
@@ -253,10 +251,10 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
memcpy(insertion, positions.data, positions.capacity * ListElementSize(VoxelSpaceReprList));
|
||||
};
|
||||
|
||||
for (size_t i = 1; i < reprs_in_count; i++) {
|
||||
for (size_t i = 1; i < reprsInput.length; i++) {
|
||||
AppendList(&offsets, polycubes.capacity);
|
||||
Space space = empty_voxel_space;
|
||||
space.space = reprs_in[i];
|
||||
VoxelSpace space = emptyVoxelSpace;
|
||||
space.space = reprsInput.data[i];
|
||||
cullEmptySpace(&space);
|
||||
VoxelSpaceReprList perms = getAllPermutationsInPrism(permsArena, &space, dims);
|
||||
possibleCombos *= perms.length;
|
||||
@@ -269,7 +267,7 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
AppendList(&offsets, polycubes.length);
|
||||
|
||||
SomaSolutionList solutions = PushList(permsArena, SomaSolutionList, (size_t)floor(sqrt(possibleCombos)));
|
||||
AppendList(&solutions, PushFullList(permsArena, SomaSolution, reprs_in_count));
|
||||
AppendList(&solutions, PushFullList(permsArena, SomaSolution, reprsInput.length));
|
||||
|
||||
Solver solver = {
|
||||
&polycubes,
|
||||
@@ -282,12 +280,11 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
return filterUnique(permsArena, solver.solutions, dims);
|
||||
}
|
||||
|
||||
|
||||
void interactiveCmdLineSolveSoma() {
|
||||
//get_dims_input(dims);
|
||||
//std::cout << '\n';
|
||||
//std::vector<uint64> reprs = get_reprs_input(dims[0]*dims[1]*dims[2]);
|
||||
print("Great. Calculating solutions...\n");
|
||||
SomaSolutionList solutions = solve(STD_SOMA, ArrayCount(STD_SOMA), (int[]){ 3, 3, 3 });
|
||||
SomaSolutionList solutions = solve(AsList(VoxelSpaceReprList, STD_SOMA), (int[]){ 3, 3, 3 });
|
||||
print("%zu solutions found.\n", solutions.length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user