#11379: Add Quantumino solver to sage/games
---------------------------+------------------------------------------------
Reporter: slabbe | Owner: slabbe
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7.1
Component: misc | Keywords: sd31
Work_issues: | Upstream: N/A
Reviewer: Rob Beezer | Author: Sébastien Labbé
Merged: | Dependencies:
---------------------------+------------------------------------------------
Changes (by newvalueoldvalue):
* status: needs_work => needs_review
* author: => Sébastien Labbé
Comment:
I just uploaded a new patch which applies over the precedent ones.
> The animations are great. Can you do something to mark the end (like a
few blank frames, for maybe a half-second)? It goes so fast, it is hard
to tell where the start is and where the end is.
I added a paragraph saying (copied from the animate doc string) :
{{{
The ``show`` function takes arguments to specify the delay between
frames (measured in hundredths of a second, default value 20) and
the number of iterations (default value 0, which means to iterate
forever). To iterate 4 times with half a second between each frame::
sage: a.show(delay=50, iterations=4) # optional
}}}
I also fixed the methods {{{dlx_common_prefix_solutions}}} and
{{{dlx_incremental_solutions}}} which were broken. That was maybe the
reason why the animations were going so fast... So now, the following
animation looks better and not too fast even with default parameters of
the method show :
{{{
#!python
sage: from sage.combinat.tiling import Polyomino, TilingSolver
sage: y = Polyomino([(0,0),(1,0),(2,0),(3,0),(2,1)], color='cyan')
sage: T = TilingSolver([y], box=(5,10), reusable=True, reflection=True)
sage: a = T.animate('incremental')
sage: a
Animation with 123 frames
sage: a.show()
}}}
> 1. Maybe each cube of a piece needs to be shrunk and translated,
relative to some anchor point (the "corner" closest to the origin?).
Ok. So I implemented this solution (translation to origin, shrinked,
translated back) and changed show2d and show3d methods accordingly. For
the Quantumino, it looks great. The yellow pentamino number 8 do not have
a hole anymore :
{{{
#!python
sage: from sage.games.quantumino import show_pentaminos
sage: show_pentaminos()
}}}
Also, using size<0.5 does not create disconnected cubes :
{{{
#!python
sage: from sage.games.quantumino import QuantuminoSolver
sage: s = QuantuminoSolver(0).solve().next()
sage: s.show3d(size=0.3)
}}}
Although, I can not say that the proposed solution is perfect and always
better than the precedent one. In the example below, there are no holes
anymore which is good. But, the space between each piece is not uniform
and it is even hard to find a size which will avoid the pieces to touch
each other without being to far from each other:
{{{
#!python
sage: from sage.combinat.tiling import Polyomino, TilingSolver
sage: L = []
sage:
L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(1,3)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,3)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,2)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,3)]))
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)]))
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]))
sage: T = TilingSolver(L, (8,8), reflection=True)
sage: solution = T.solve().next()
sage: G = sum([piece.show2d(size=0.85) for piece in solution], Graphics())
sage: G.show(aspect_ratio=1)
}}}
What do you think?
Sébastien
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11379#comment:23>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.