Quilt
Block Random Layout Program
*
Pattern
Creator *
By Frank Cox
(September
27, 2010)
Updated September 27, 2010 – Chris Hulbert compiled a Windows executable of the quilt program which is available for download from this webpage. Windows users can simply download the program and run it directly.
Updated June 20, 2010 – The original quilt layout program posted on March 13, 2010 doesn't work with unequal or variable numbers of block patterns. This bug has been fixed in the version of the quilt program that is now posted here. Thanks to Dan Wheeler for reporting this issue.
To make sure that you are running the bug-fixed version of the quilt program look for the date June 20/2010 in the title and heading lines that appear when you start the program. If that date is present, you have the latest version of the quilt program.
This program creates a random quilt layout using a specified number of quilt blocks. The blocks are arranged so no two blocks with the same pattern are touching vertically, horizontally or diagonally.
In the above diagram, quilt block Q will not be the same pattern as any of the blocks numbered 1 through 8.
Example:
QUILT BLOCK RANDOM LAYOUT PROGRAM --------------------------------- June 20/2010 Copyright (c) 2010, Frank Cox <theatre@melvilletheatre.com> Enter dimensions of the finished quilt Height: 10 Width: 10 Enter number of quilt block patterns: 10 Enter number of pieces for pattern 1 :10 Enter number of pieces for pattern 2 :10 Enter number of pieces for pattern 3 :10 Enter number of pieces for pattern 4 :10 Enter number of pieces for pattern 5 :10 Enter number of pieces for pattern 6 :10 Enter number of pieces for pattern 7 :10 Enter number of pieces for pattern 8 :10 Enter number of pieces for pattern 9 :10 Enter number of pieces for pattern 10 :10 Starting Quilt Calculation -------------------------- Depending on quilt size and your computer's speed, this may take a while . . . HERE IS YOUR QUILT PATTERN -------------------------- 10 07 10 08 01 07 08 05 07 02 08 05 06 09 10 04 02 01 09 01 01 09 07 02 06 01 03 06 03 08 03 02 05 08 05 02 08 07 10 01 06 04 06 09 10 04 03 04 09 07 10 08 07 08 02 07 08 02 08 01 02 05 02 01 05 06 09 01 05 10 06 03 08 07 10 03 04 02 06 09 02 04 05 01 02 08 10 07 03 04 10 06 10 03 05 04 03 08 02 01
The number of calculations required to create a quilt pattern increases exponentially with the total number of blocks in the pattern, so while a smaller pattern may take only seconds to create, a larger pattern may require several hours of calculation time. There is an astounding number of possible layouts using any number of quilt blocks.
This Quilt Program does very little error checking. If you give it a quilt layout to process that can't be “solved” (such as a 5x5 quilt with 24 red blocks and 1 blue one), the program will quite happily run forever trying to find a solution that doesn't exist.
This Quilt Program is Free Software; it is provided absolutely free of charge without warranty in the hope that it will be useful to you.
The zip file that can be downloaded from this web page contains the Quilt Program in several forms:
A MS-DOS executable program that will (probably) run on most versions of Microsoft Windows.
Precompiled binaries created for Centos 5, both 32-bit and 64-bit versions.
C source code. The Quilt Program is written in generic ANSI C so it should compile with minimal or most likely no modification required on any computer platform. All you need is a C compiler.
Click here to download the Quilt Program zip file.
Thanks to Chris Hulbert (http://splinter.com.au/blog ), the Quilt Program is now available for Microsoft Windows!
Click here to download the Quilt Program for Microsoft Windows.
Happy Quilting!
/* quilt.c Quilt Block Layout Program Copyright (c) 2010, Frank Cox <theatre@melvilletheatre.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY FRANK COX ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FRANK COX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <stdlib.h> #include <time.h> int rnd(float max); int main(void) { int counter,size,width,*blocks,*quilt,patterns,temp; printf("QUILT BLOCK RANDOM LAYOUT PROGRAM\n---------------------------------\nJune 20/2010 "); printf("Copyright (c) 2010, Frank Cox <theatre@melvilletheatre.com>\n"); printf("Enter dimensions of the finished quilt\n\nHeight: "); scanf("%d",&size); printf("Width: "); scanf("%d",&width); size=size*width; quilt=malloc(size*sizeof(int)); printf("\nEnter number of quilt block patterns: "); scanf("%d",&patterns); printf("\n"); blocks=malloc(patterns*sizeof(int)); temp=0; for (counter=0; counter < patterns; counter++) { printf("Enter number of pieces for pattern %d :",counter+1); scanf("%d",&blocks[counter]); temp=temp+blocks[counter]; } if (temp != size) { free(blocks); free(quilt); printf("\nERROR: The quilt size is %d, but you specified a total number of %d pieces.",size,temp); exit(1); } temp=0; for (counter=0; counter < patterns; counter++) { int counter2; for (counter2=0; counter2 < blocks[counter]; counter2++) { quilt[temp]=counter; temp++; } } free(blocks); srand(time(NULL)); printf("\nStarting Quilt Calculation\n--------------------------\n"); printf("Depending on quilt size and your computer's speed, this may take a while . . .\n\n"); do { for (counter=0; counter < size; counter++) { if (counter % width) if (quilt[counter]==quilt[counter-1]) break; if (counter % width != width-1) if (quilt[counter]==quilt[counter+1]) break; if (counter >= width && counter % width) if (quilt[counter]== quilt[counter-width-1]) break; if (counter >= width) if (quilt[counter]== quilt[counter-width]) break; if (counter >= width && counter % width != width-1) if (quilt[counter]== quilt[counter-width+1]) break; if (counter % width && counter < size-width) if (quilt[counter]== quilt[counter+width-1]) break; if (counter < size-width) if (quilt[counter]==quilt[counter+width]) break; if (counter % width != width-1 && counter < size-width) if (quilt[counter]==quilt[counter+width+1]) break; } if (counter < size) { temp=quilt[counter]; patterns=rnd(size)-1; quilt[counter]=quilt[patterns]; quilt[patterns]=temp; } } while (counter < size); printf("HERE IS YOUR QUILT PATTERN\n--------------------------\n"); for (counter=0; counter < size; counter++) { printf("%02d ",quilt[counter]+1); if ((counter % width)==width-1) printf("\n"); } free(quilt); return 0; } int rnd(float max) { return 1+ (int) (max * (rand() / (RAND_MAX + 1.0))); }
Other articles written by Frank Cox can be found here.
Frank Cox owns and operates the Melville Theatre in Melville, Saskatchewan, Canada, and has been playing with computers for over 30 years.
This work is licensed under a Creative
Commons Attribution-Share Alike 2.5 Canada License.