renamed to polycubeCounting
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
include("Shape.jl")
|
include("Shape.jl")
|
||||||
include("ImmutableOrientedShape.jl")
|
include("ImmutableOrientedShape.jl")
|
||||||
include("Powerset.jl")
|
|
||||||
include("TupleMisc.jl")
|
include("TupleMisc.jl")
|
||||||
include("plot.jl")
|
include("plot.jl")
|
||||||
using XXhash
|
using XXhash
|
||||||
using Serialization
|
using Serialization
|
||||||
using ArgParse
|
using ArgParse
|
||||||
|
using Combinatorics
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
s = ArgParseSettings()
|
s = ArgParseSettings()
|
||||||
@@ -45,6 +45,13 @@ function main()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function options()
|
||||||
|
println("scanForShapes(Int::n): scans for shapes of size <=n")
|
||||||
|
println("countShapes(): opens shape storage and displays the amount of shapes for the generated sizes")
|
||||||
|
println("listshapes(): lists all shapes from the shape storage")
|
||||||
|
println("plot(Vector{Int}::v): plots shapes of size v[1], or just v[2] from the list")
|
||||||
|
end
|
||||||
|
|
||||||
function scanForShapes(MaxSize::Int64)
|
function scanForShapes(MaxSize::Int64)
|
||||||
D = Dict{UInt, ImmutableOrientedShape}()
|
D = Dict{UInt, ImmutableOrientedShape}()
|
||||||
S = Vector{Shape}();
|
S = Vector{Shape}();
|
||||||
@@ -57,29 +64,53 @@ function scanForShapes(MaxSize::Int64)
|
|||||||
cube = pop!(S)
|
cube = pop!(S)
|
||||||
growableSpaces = collect(getPossibleNeighbors(cube))
|
growableSpaces = collect(getPossibleNeighbors(cube))
|
||||||
acceptable_growth = MaxSize - length(cube.cubes)
|
acceptable_growth = MaxSize - length(cube.cubes)
|
||||||
for i ∈ 1:acceptable_growth
|
possibleGrowth = powerset(growableSpaces, 1, acceptable_growth)
|
||||||
possibleGrowth = Powerset.getPowerSubSet(length(growableSpaces), i)
|
for cubesToAdd ∈ possibleGrowth
|
||||||
for j ∈ axes(possibleGrowth, 1)
|
newShape = deepcopy(cube)
|
||||||
cubesToAdd = growableSpaces[possibleGrowth[j, :]]
|
for c ∈ cubesToAdd
|
||||||
newShape = deepcopy(cube)
|
push!(newShape, c)
|
||||||
for c ∈ cubesToAdd
|
end
|
||||||
push!(newShape, c)
|
collision = checkForCollision(newShape, D)
|
||||||
end
|
if !collision
|
||||||
collision = checkForCollision(newShape, D)
|
push!(S, newShape)
|
||||||
if !collision
|
immutableNewShape = getImmutableOrientedShape(newShape)
|
||||||
push!(S, newShape)
|
D[immutableNewShape.hash] = immutableNewShape
|
||||||
immutableNewShape = getImmutableOrientedShape(newShape)
|
|
||||||
D[immutableNewShape.hash] = immutableNewShape
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sanitizedData = sanitize(D, MaxSize)
|
sanitizedData = sanitize(D, MaxSize)
|
||||||
serialize("results.bin", sanitizedData)
|
serialize("julia/results.bin", sanitizedData)
|
||||||
|
end
|
||||||
|
|
||||||
|
function scanForShapesRec(MaxSize::Int64)
|
||||||
|
D = Dict{UInt, ImmutableOrientedShape}()
|
||||||
|
singletonCube = getCube()
|
||||||
|
immutableCube = getImmutableOrientedShape(singletonCube)
|
||||||
|
D[immutableCube.hash] = immutableCube
|
||||||
|
evaluateShape(singletonCube, D, MaxSize)
|
||||||
|
end
|
||||||
|
|
||||||
|
function evaluateShape(shape::Shape, D::Dict{UInt, ImmutableOrientedShape}, MaxSize::Int64)
|
||||||
|
growableSpaces = collect(getPossibleNeighbors(shape))
|
||||||
|
acceptable_growth = MaxSize - length(shape.cubes)
|
||||||
|
|
||||||
|
possibleGrowth = powerset(growableSpaces, 1, acceptable_growth)
|
||||||
|
for cubesToAdd ∈ possibleGrowth
|
||||||
|
newShape = deepcopy(shape)
|
||||||
|
for c ∈ cubesToAdd
|
||||||
|
push!(newShape, c)
|
||||||
|
end
|
||||||
|
collision = checkForCollision(newShape, D)
|
||||||
|
if !collision
|
||||||
|
immutableNewShape = getImmutableOrientedShape(newShape)
|
||||||
|
D[immutableNewShape.hash] = immutableNewShape
|
||||||
|
evaluateShape(newShape, D, MaxSize)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function countShapes()
|
function countShapes()
|
||||||
T = deserialize("results.bin")
|
T = deserialize("julia/results.bin")
|
||||||
n = T[1]
|
n = T[1]
|
||||||
for i ∈ 1:n
|
for i ∈ 1:n
|
||||||
print("n = ")
|
print("n = ")
|
||||||
@@ -90,7 +121,7 @@ function countShapes()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function listShapes()
|
function listShapes()
|
||||||
T = deserialize("results.bin")
|
T = deserialize("julia/results.bin")
|
||||||
print("max size: ")
|
print("max size: ")
|
||||||
println(T[1])
|
println(T[1])
|
||||||
for V ∈ T[2]
|
for V ∈ T[2]
|
||||||
Reference in New Issue
Block a user