sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.46k stars 485 forks source link

Add Quantumino solver to sage/games #11379

Closed seblabbe closed 13 years ago

seblabbe commented 13 years ago

Some code to solve the Quantumino Puzzle (see also this video on youtube).

Apply:

  1. attachment: trac_11379_quantamino-sl.patch
  2. attachment: trac_11379_corrections-sl-v2.patch
  3. attachment: trac_11379_color_issue-sl.patch
  4. attachment: trac_11379-reviewer-docs.patch
  5. attachment: trac_11379_hole_bug-sl.patch
  6. attachment: trac_11379_2d_boundary-sl.patch

Component: misc

Keywords: sd31

Author: Sébastien Labbé

Reviewer: Rob Beezer

Merged: sage-4.7.2.alpha2

Issue created by migration from https://trac.sagemath.org/ticket/11379

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:1

I saw this demo'ed at Sage Days 30. It's really nice. I'll give the patch as look once it appears.

seblabbe commented 13 years ago
comment:2

Just added the patch.

The file takes 80 seconds to test... so I still need to add some "long" doctest warnings...

Sébastien

seblabbe commented 13 years ago

Attachment: trac_11379_quantamino-sl.patch.gz

seblabbe commented 13 years ago
comment:4

Takes now 17 seconds to test on my machine (35s with long test).

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Attachment: trac_11379-size-suggestion.patch.gz

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:5

Hi Sebastien,

Very nice - this is a lot of fun, and a great advertisement for the power of dancing links. Lots of little comments, I hope its not too much. Nothing very serious.

sage -t  "devel/sage-main/sage/games/quantumino.py"
**********************************************************************
File "/sage/sage-4.7/devel/sage-main/sage/games/quantumino.py", line 193:
    sage: hash(p)
Expected:
    2059134902
Got:
    6915256369230374838
**********************************************************************

Minor editing

As I said, lots of little stuff, which I hope does not look like too long a list. I've tried to keep it to suggestions so you have the latitude to approach it as you see fit. I'll be happy to stick with this review as you make revisions.

Rob

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:6

One more comment I forgot:

ss=quantumino_solver.get_solution(7, box=(3,3,9))

seems to totally hang on my system - not even a Ctrl-C gets it back. Do I need to use a box of exactly volume 80? Was it unreasonable to expect a different result?

seblabbe commented 13 years ago
comment:7

Hi Rob,

Thanks a lot for your good review. I almost done making the corrections. I also added a class Tiling Solver which replaces the puzzle solver function. This allows for more introspection (for instance looking at the rows passed to the DLX solver) and also comptute the number of solutions more efficiently. I have one question about your suggestion :

  • I thought an interact would be fun. Checkboxes for the excluded piece, plus the ability to "explode" the solution via a slider. I'm not suggesting you write an interact, but a size argument as input to show3d() (for the solution) would make this possible. Patch attempts to do this, but it is not totally correct, at size below 0.50 the pieces start to fall apart into cubes. And the aside piece breaks up even earlier in my test. The hole in block number 8 behaves slightly differently. So as a suggestion: consider adding a size argument to pass from the solution show3d() down to each piece. But my patch is just a suggestion - it is not ready to use.

I don't understand what is meant by ""explode" the solution". Is this a slider which would bring the size of the cube from 0 to 1 ? It doesn't not seem that nice to me. I would rather suggest a slider which would go from one solution to the other, where we would see the pieces that are removed and added, etc. Or maybe even an animation of it. I am almost done doing it: I have the iterator of partial solutions. I only need to know how to make a Jmol animation of 3D Graphics object or maybe an animation of Tachyon images.

Sébastien

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -3,3 +3,9 @@
 Will post a patch soon.

 [1] http://www.youtube.com/watch?v=jX_VKzakZi8
+
+For the patchbot:
+
+Apply : trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379-size-suggestion-updated.patch
+
+
seblabbe commented 13 years ago
comment:9

I don't understand what is meant by ""explode" the solution".

Ok, now I understand. I needed to try it ! It is true that it helps to change the size of the small cubes. Because of conflicts, I had to reload your patch (but could not erase yours) so I renamed it. Hence, your patch apply over my second patch.

I think I was able to answer all of your comments. Needs review!

Sébastien

seblabbe commented 13 years ago

Attachment: trac_11379-size-suggestion-updated.patch.gz

Applies over the correction patch.

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:10

I had a bit of time to look through the patch. Looks great! I still need to do a thorough test of the new features and all, so will try to get to that soon.

Would Franco let you bring the real physical puzzle to Seattle for SD 31?

Rob

seblabbe commented 13 years ago
comment:11

Would Franco let you bring the real physical puzzle to Seattle for SD 31?

Sure! I'll ask. And will try not to forget it!

Sébastien

seblabbe commented 13 years ago
comment:13

I have been working on it again yesterday. I will update the patches again quite soon. Do not review until then.

Sebastien

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Reviewer: Rob Beezer

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:14

Replying to @seblabbe:

I have been working on it again yesterday. I will update the patches again quite soon. Do not review until then.

Thanks - ready whenever you are (I think!).

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Description changed:

--- 
+++ 
@@ -6,6 +6,9 @@

 For the patchbot:

-Apply : trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379-size-suggestion-updated.patch
+**Apply:**
+1.  [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz) 
+2.  [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
+3.  [attachment: trac_11379-size-suggestion-updated.patch](https://github.com/sagemath/sage-prod/files/10652948/trac_11379-size-suggestion-updated.patch.gz)
1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Changed keywords from none to sd31

seblabbe commented 13 years ago
comment:15

Great. So I will upload the patches later tonight! I still have some cleaning to make.

seblabbe commented 13 years ago

Attachment: trac_11379_corrections-sl.patch.gz

Applies over my first patch

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -1,14 +1,8 @@
-Last week I wrote code to solve the Quantamino Puzzle [1].
-
-Will post a patch soon.
-
-[1] http://www.youtube.com/watch?v=jX_VKzakZi8
+Some code to solve the [Quantumino Puzzle](http://familygamesamerica.com/mainsite/consumers/productview.php?pro_id=274&search=quantumino) (see also [this video](http://www.youtube.com/watch?v=jX_VKzakZi8) on youtube).

 For the patchbot:

 **Apply:**
-1.  [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz) 
-2.  [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
-3.  [attachment: trac_11379-size-suggestion-updated.patch](https://github.com/sagemath/sage-prod/files/10652948/trac_11379-size-suggestion-updated.patch.gz)

-
+1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
+2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
seblabbe commented 13 years ago
comment:16

Ok, so I just re-uploaded the correction patch. The size suggestion patch as been folded into that correction patch. So only two patches are needed to be applied (the one that has already been reviewed and the correction patch).

So, compared to what has already been reviewed, I did a bunch of improvements: I created a new file sage/combinat/tiling.py and moved the polyomino class into it. Also, I created a new class called TilingSolver which solves the general problem of Tiling a box by polyomino. This class replaces the old function general_puzzle_solver which I might misspell. The TilingSolver class allows to do more introspection like getting the rows passed to the DLX solver and count them. One can also get the DLX Solver. I managed to write the Polyomino and TilingSolver abstract enough so that they can be defined in any dimension. Ploting works when the dimension is 2 or 3. I also added parameters to allow (or not) reflections and rotations and whether the pieces can be reused or not.

There is still one issue mentionned in the review that I did not fixed. The holes in the polyomino. Maybe tomorrow we can think about a efficient way to fix this?

Question: Should I use Pentomino like Donald Knuth does or Pentamino like the game Quantumino calls the pieces? Which is best?

Good night!

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -1,8 +1,12 @@
 Some code to solve the [Quantumino Puzzle](http://familygamesamerica.com/mainsite/consumers/productview.php?pro_id=274&search=quantumino) (see also [this video](http://www.youtube.com/watch?v=jX_VKzakZi8) on youtube).

-For the patchbot:
+For the human:

 **Apply:**

 1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
 2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
+
+For the patchbot:
+
+Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch
seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -6,7 +6,8 @@

 1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
 2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
+3. [attachment: trac_11379_color_issue-sl.patch](https://github.com/sagemath/sage-prod/files/10652950/trac_11379_color_issue-sl.patch.gz)

 For the patchbot:

-Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch
+Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch
seblabbe commented 13 years ago
comment:18

In a new patch I just uploaded which applies on top of two others, I fixed a color issue for when pieces are reusable. Sorry, I had the idea for the fix when I woke up. Now, I stop working on it!

seblabbe commented 13 years ago

Applies over the correction patch.

seblabbe commented 13 years ago
comment:19

Attachment: trac_11379_color_issue-sl.patch.gz

Ok, so I can't stop working on it apparently. I added the possibility of making an animation. I also fixed the problem that showed up during my quick demo.

Needs review!

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:20

Attachment: trac_11379-reviewer-docs.patch.gz

Sebastien,

Sorry to be so tardy on this one. Really just one "issue" that I think needs attention.

Made a reviewer patch: Changed some module and class links in documentation to be active, fixed a couple minor English language things. Do not list me as an author for these.

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.

Related Questions:

  1. Pentamino 8 (a yellow one) still has a hole in it. Not a big deal, but perhaps a symptom of something that should be done more carefully?
  2. I feel bad to bring this up, since I suggested it. The "size" parameter works fine for 0.5 < size < 1.0. Proably size > 1.0 should raise an error. Below size=0.5 the puzzle pieces seem to break into lots of individual cubes. Also the hole in piece 8 seems to change according to size. So I wonder if these first two items are related.
  3. In the 3D puzzle in the tiling module documentation, there are again holes in the pieces.
  4. Maybe each cube of a piece needs to be shrunk and translated, relative to some anchor point (the "corner" closest to the origin?). I have not looked carefully enough to know if this what needs to be done.

Rob

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Description changed:

--- 
+++ 
@@ -7,7 +7,7 @@
 1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
 2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
 3. [attachment: trac_11379_color_issue-sl.patch](https://github.com/sagemath/sage-prod/files/10652950/trac_11379_color_issue-sl.patch.gz)
-
+4. [attachment: trac_11379-reviewer-docs.patch](https://github.com/sagemath/sage-prod/files/10652951/trac_11379-reviewer-docs.patch.gz)
 For the patchbot:

-Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch
+Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch trac_11379-reviewer-docs.patch
seblabbe commented 13 years ago
comment:21

Hi Rob,

Sorry to be so tardy on this one. Really just one "issue" that I think needs attention.

No problem!

Made a reviewer patch: Changed some module and class links in documentation to be active, fixed a couple minor English language things. Do not list me as an author for these.

Good, thanks for those fixes! Is there a problem with one of the fixes ? Because there is a symbol tilde ~ that appears in front of one of the class path.

:class:`~sage.combinat.tiling.TilingSolver`

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.

The delay between frames and the number of iterations are arguments of the method show (see animate??). I would keep the animation function as is, but add an exemple in the doctest of how to change those parameters and add blank frames at the end. What do you think?

  1. Pentamino 8 (a yellow one) still has a hole in it. Not a big deal, but perhaps a symptom of something that should be done more carefully?

Ok. I will think about it. Let me find a solution which will be better than the "cube in the middle" I am using up to now. Maybe using Simplicial Complexes of cubes, I could get the exact boundary of the piece? I take a look at it and comes back with a fix soon.

Sébastien

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:22

Replying to @seblabbe:

No problem!

Good. We just need to finish this before you become a father. ;-)

:class:`~sage.combinat.tiling.TilingSolver`

The tilde should suppress the sage.combinat.tiling prefix in the output. Don't remember just why I did it that way there (I'm sure I had a reason at the time!) - but you should feel free to adjust it if you would rather have the fully-qualified name.

The delay between frames and the number of iterations are arguments of the method show (see animate??). I would keep the animation function as is, but add an exemple in the doctest of how to change those parameters and add blank frames at the end. What do you think?

Perfect.

Ok. I will think about it. Let me find a solution which will be better than the "cube in the middle" I am using up to now. Maybe using Simplicial Complexes of cubes, I could get the exact boundary of the piece? I take a look at it and comes back with a fix soon.

Maybe if each piece had a center, or maybe a center of a bounding box, or something like that. Then you could shrink into the center. Seems like you work off a corner right now, but again, I have not studied it very carefully. If the size parameter becomes too much trouble, feel free to drop it, but I think fixing this will fix a variety of other things, like the hole in piece 8.

seblabbe commented 13 years ago

Attachment: trac_11379_hole_bug-sl.patch.gz

Applies over the precedent patches.

seblabbe commented 13 years ago
comment:23

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 :

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 :

sage: from sage.games.quantumino import show_pentaminos
sage: show_pentaminos()                                

Also, using size<0.5 does not create disconnected cubes :

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:

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

seblabbe commented 13 years ago

Author: Sébastien Labbé

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -7,7 +7,8 @@
 1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
 2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
 3. [attachment: trac_11379_color_issue-sl.patch](https://github.com/sagemath/sage-prod/files/10652950/trac_11379_color_issue-sl.patch.gz)
-4. [attachment: trac_11379-reviewer-docs.patch](https://github.com/sagemath/sage-prod/files/10652951/trac_11379-reviewer-docs.patch.gz)
+4. [attachment: trac_11379-reviewer-docs.patch](https://github.com/sagemath/sage-prod/files/10652951/trac_11379-reviewer-docs.patch.gz) 
+5. [attachment: trac_11379_hole_bug-sl.patch](https://github.com/sagemath/sage-prod/files/10652952/trac_11379_hole_bug-sl.patch.gz)
 For the patchbot:

-Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch trac_11379-reviewer-docs.patch
+Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch trac_11379-reviewer-docs.patch trac_11379_hole_bug-sl.patch
seblabbe commented 13 years ago
comment:25

I don't know how to speak to the buildbot. Maybe the commas between patches name are needed? I am trying.

More info is here : http://wiki.sagemath.org/buildbot

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -11,4 +11,4 @@
 5. [attachment: trac_11379_hole_bug-sl.patch](https://github.com/sagemath/sage-prod/files/10652952/trac_11379_hole_bug-sl.patch.gz)
 For the patchbot:

-Apply trac_11379_quantamino-sl.patch trac_11379_corrections-sl.patch trac_11379_color_issue-sl.patch trac_11379-reviewer-docs.patch trac_11379_hole_bug-sl.patch
+Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch
seblabbe commented 13 years ago
comment:26

Or maybe the information must be put in a comment instead of above in the description :

For the patchbot:

Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch

seblabbe commented 13 years ago

Attachment: trac_11379_2d_boundary-sl.patch.gz

Applies over the precedent patches.

seblabbe commented 13 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,4 @@
 Some code to solve the [Quantumino Puzzle](http://familygamesamerica.com/mainsite/consumers/productview.php?pro_id=274&search=quantumino) (see also [this video](http://www.youtube.com/watch?v=jX_VKzakZi8) on youtube).
-
-For the human:

 **Apply:**

@@ -9,6 +7,5 @@
 3. [attachment: trac_11379_color_issue-sl.patch](https://github.com/sagemath/sage-prod/files/10652950/trac_11379_color_issue-sl.patch.gz)
 4. [attachment: trac_11379-reviewer-docs.patch](https://github.com/sagemath/sage-prod/files/10652951/trac_11379-reviewer-docs.patch.gz) 
 5. [attachment: trac_11379_hole_bug-sl.patch](https://github.com/sagemath/sage-prod/files/10652952/trac_11379_hole_bug-sl.patch.gz)
-For the patchbot:
+6. [attachment: trac_11379_2d_boundary-sl.patch](https://github.com/sagemath/sage-prod/files/10652953/trac_11379_2d_boundary-sl.patch.gz)

-Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch
seblabbe commented 13 years ago
comment:27

For the patchbot:

Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch, trac_11379_2d_boundary-sl.patch

seblabbe commented 13 years ago
comment:28

Replying to @seblabbe:

Although, I can not say that the proposed solution is perfect and always better than the precedent one.

I change the way to show 2d polyomino. First, I reverted its drawing as it was before. Second, I added a boundary line. Thirdly, I made the edge between adjacent points smaller than before. This way, holes are more esthetic and natural : we accept them more easily.

You can see the result with this example :

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)], 'yellow')) 
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)], "black"))        
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)], "gray"))         
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,3)],"cyan"))                
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1)],"red"))                 
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,2)],"blue"))                
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,3)],"green"))               
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)],"magenta"))             
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)],"orange"))              
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)],"pink"))                
sage: T = TilingSolver(L, (8,8), reflection=True)                          
sage: solution = T.solve().next()                                          
sage: G = sum([piece.show2d() for piece in solution], Graphics()) 
sage: G.show(aspect_ratio=1, axes=False)                                               

Or this animation :

sage: a = T.animate()      #45 seconds     
sage: a                   
Animation with 328 frames 
sage: a.show()      # take some time like 2 minutes

Now, I am happy with the patch. Needs review!

Sébastien

seblabbe commented 13 years ago
comment:29

The above 328 frames animation is here  :

http://thales.math.uqam.ca/~labbes/Experimentations/florent.gif

done with the following parameters

sage: a.show(delay=50, iterations=1)
1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Standalone, comprehensive patch

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:30

Attachment: trac_11379_quantamino-total-sl.patch.gz

I like all the changes (no holes!). And the 2-D pieces look real nice. I think this is ready to go - builds, passes long tests, nice documentation on 4.7.1.alpha4. So positive review.

One patch needed a commit message, and since it was easy, I just rolled everything into one big "total" patch. Still has Sebastian's name on it.

Nice work on a big project - this will be a great way to demonstrate backtracking (and dancing links).

Rob

jdemeyer commented 13 years ago
comment:32

The commit message of attachment: trac_11379_corrections-sl.patch should be changed since it contains a reference to a mercurial queue.

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Attachment: trac_11379_corrections-sl-v2.patch.gz

New version with edited commit string

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago
comment:33

I consolidated the commit strings ont eh one patch, and had to use a new name for the file, since I do not have the privileges to replace it.

Rob

1d7ec08f-60ae-4512-91a6-8324c06eab9f commented 13 years ago

Description changed:

--- 
+++ 
@@ -3,7 +3,7 @@
 **Apply:**

 1. [attachment: trac_11379_quantamino-sl.patch](https://github.com/sagemath/sage-prod/files/10652946/trac_11379_quantamino-sl.patch.gz)
-2. [attachment: trac_11379_corrections-sl.patch](https://github.com/sagemath/sage-prod/files/10652949/trac_11379_corrections-sl.patch.gz)
+2. [attachment: trac_11379_corrections-sl-v2.patch](https://github.com/sagemath/sage-prod/files/10652955/trac_11379_corrections-sl-v2.patch.gz)
 3. [attachment: trac_11379_color_issue-sl.patch](https://github.com/sagemath/sage-prod/files/10652950/trac_11379_color_issue-sl.patch.gz)
 4. [attachment: trac_11379-reviewer-docs.patch](https://github.com/sagemath/sage-prod/files/10652951/trac_11379-reviewer-docs.patch.gz) 
 5. [attachment: trac_11379_hole_bug-sl.patch](https://github.com/sagemath/sage-prod/files/10652952/trac_11379_hole_bug-sl.patch.gz)
jdemeyer commented 13 years ago

Merged: sage-4.7.2.alpha2