diff --git a/build b/build index b6ce346..63daf03 100755 --- a/build +++ b/build @@ -1,6 +1,6 @@ #!/bin/bash LIB_INCLUDE="-lglfw -lGL -lm" -g++ -g -g2 -DOS_LINUX=1 -DDJSTDLIB_DEBUG=1 -xc -std=c99 ./src/main.c -o ./target/somaesque $LIB_INCLUDE +gcc -g -g2 -DOS_LINUX=1 -DDJSTDLIB_DEBUG=1 -xc -std=c99 ./src/main.c -o ./target/somaesque $LIB_INCLUDE ./target/somaesque diff --git a/src/SomaSolve.c b/src/SomaSolve.c index b0ccafd..8006f24 100644 --- a/src/SomaSolve.c +++ b/src/SomaSolve.c @@ -132,7 +132,7 @@ void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution, size_ SomaSolutionList *solutions = solver->solutions; size_t start = offsets->data[curr_piece]; size_t end = offsets->data[curr_piece + 1]; - size_t num_pieces = offsets->length; + size_t num_pieces = offsets->length - 1; for (size_t i = start; i < end; i++) { bool successful_fuse = !collides(working_solution, input->data[i]); if (successful_fuse) { @@ -168,7 +168,7 @@ SomaSolutionList getSolutionRotations(Arena *arena, SomaSolution *solution, int dims[2], }; VoxelSpaceList pieceRotations = getAllRotations(arena, &space); - for (int rot_i = 0; rot_i < pieceRotations.length; rot_i++) { + for (EachIn(pieceRotations, rot_i)) { AppendList(&result.data[rot_i], pieceRotations.data[rot_i].space); } } @@ -228,7 +228,7 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) { OffsetList offsets = PushList(arena, OffsetList, reprs_in_count + 1); - VoxelSpaceReprList polycubes = EmptyList(); + VoxelSpaceReprList polycubes = PushList(arena, VoxelSpaceReprList, 0); Space empty_voxel_space = { 0, @@ -248,7 +248,6 @@ SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) { VoxelSpaceReprList positions = getAllPositionsInPrism(permsArena, &space, dims); possibleCombos += positions.length; VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, positions.capacity); - polycubes.data = insertion; polycubes.capacity += positions.capacity; polycubes.length += positions.length; memcpy(insertion, positions.data, positions.capacity * ListElementSize(VoxelSpaceReprList)); @@ -270,8 +269,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))); - SomaSolution initialSoln = PushFullList(permsArena, SomaSolution, reprs_in_count); - AppendList(&solutions, initialSoln); + AppendList(&solutions, PushFullList(permsArena, SomaSolution, reprs_in_count)); Solver solver = { &polycubes, diff --git a/src/lib/djstdlib b/src/lib/djstdlib index 27e7d74..0c81973 160000 --- a/src/lib/djstdlib +++ b/src/lib/djstdlib @@ -1 +1 @@ -Subproject commit 27e7d748952143d4a1df23b37ce082219156db7f +Subproject commit 0c81973aa2ad7e599314d1515e2eb0fb991850a6