changed Shape to Polycube

This commit is contained in:
Maxime Vorwerk
2023-09-25 03:58:25 +02:00
parent 08599a2d79
commit 638d02ddf6
4 changed files with 55 additions and 55 deletions

64
julia/Polycube.jl Normal file
View File

@@ -0,0 +1,64 @@
include("Rotations.jl")
struct Polycube
cubes::Set{Tuple{Int64, Int64, Int64}}
recentCubes::Set{Tuple{Int64, Int64, Int64}}
orderedLists::Vector{Vector{Tuple{Int64, Int64, Int64}}}
end
function Base.:push!(S::Polycube, t::Tuple{Int64, Int64, Int64})
push!(S.cubes, t)
for i 1:24
t_rot = Rotations[i](t)
index = searchsortedfirst(S.orderedLists[i], t_rot)
insert!(S.orderedLists[i], index, t_rot)
end
end
function getPossibleNeighbors(S::Polycube)
possibleSpots = Set{Tuple{Int64, Int64, Int64}}()
for p S.cubes
push!(possibleSpots,
p + (1, 0, 0),
p + (0, 1, 0),
p + (0, 0, 1),
p - (1, 0, 0),
p - (0, 1, 0),
p - (0, 0, 1)
)
end
spots = setdiff(possibleSpots, S.cubes)
return spots
end
function getCube()
return Polycube(
Set([(0, 0, 0)]),
Set([(0, 0, 0)]),
[
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
[(0, 0, 0)],
])
end