mikepound / opencubes

A community improved version of the polycubes project!
MIT License
44 stars 23 forks source link

Playing with cube rotations #4

Open GomideLeo opened 1 year ago

GomideLeo commented 1 year ago

Created a signature for each polycube in a rotation set so that it is possible to consistently choose the same rotation(s) if different polycube orientations of the same polycube are given. Two orientations might have the same signature, and will both be considered in this case.

Also, when a cube is symetric in one or more axes, the all_rotations function would return all of those rotations, added a way to prevent those

bertie2 commented 1 year ago

this is cool and does seem to reduce the number of comparisons needed, unfortunately comparisons are fast, and the math you are doing to work out which to remove is slow, so this actually results in a dramatic slow down of the code, example:

you are very right that rotating symmetric objects, and trying all the rotations is a waste of time, but we need to find a a way to remove these wastes which doesn't have too high a linear time cost.

Benchmark Examples (absolute values are hardware dependent and irrelevant, but the ratio is important):

pullrequests\opencubes> python .\cubes.py --no-cache 8 Generating polycubes n=3: 100%
Generating polycubes n=4: 100% Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Found 6922 unique polycubes Elapsed time: 18.167s

pullrequests\openCubesThing> python .\cubes.py --no-cache 8 Generating polycubes n=3: 100%
Generating polycubes n=4: 100%
Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Found 6922 unique polycubes Elapsed time: 125.612s