As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
link to let me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider
using this link.
We receive a few cents from each
Support DFF - Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
For over 15 years
Mensa Page-A-Day calendars have provided several puzzles a year
for my programming pleasure. Coding "solvers" is most fun,
but many programs also allow user solving, convenient for "fill
in the blanks" type. Below are Amazon links to the
two most recent years.
365 Puzzlers Calendar 2017
365 Puzzlers Calendar 2018
(Hint: If you can
wait, current year calendars are usually on sale in January.)
e-mail with your comments about this program (or anything else).
a program to create random tilings of a rectangular area from a defined set of
And here's a design for a 30" X 60" tile top
computer desk produced by this program.
Background & Techniques
This program was written in 1992 to layout table
tops for one of my woodworking projects. The slate tiles come in
boxes of 20 or so in sizes ranging from 3X6 to 12X12 inches.
Purchased from Lowe's as I recall.
For this posting, I cleaned up some of the code based
on things I've learned in the past 10 years, but it's not a complete
The program allows users to define a set of available
tiles and a target table size. Table tiling patterns are randomly
generated. Desirable patterns can be held in a separate list for
later review and printing. Tile sets can be saved and restored
in text files with a ".til" extension.
Here are the highlights:
|My TIntEdit integer edit component is required
to compile TileFit. It's available from the NumEdit
page in the Delphi Techniques section along with some words
about installing it. I don't like to require extra components in
project, but there are lots of
numeric edit fields here that use TIntEdit to ensure valid numbers (tile
sizes, counts, table size, print page column and row layouts,
|A few local routines were copied from my personal
utilities library to the U_Tilefit unit. These might
come in handy in other projects one day.
|Getword to parse words from the saved tile set data as it's
|GCD2 and GCD to compute the greatest
common divisor (gcd) for a set of tile sizes. GCD compute the
gcd for an array of integers. It calls GCD2 which uses Euclid's
algorithm to compute gcd for two integers. |
|HexStrToInt to convert hex color strings
back to integers. Delphi has an IntToHex function to create
hexadecimal strings but they seem to have forgotten the function to convert
|GetNextBtnClick is the central routine which creates tile
patterns. I'm sure that this routine would look quite
different if I were writing it today. This version create arrays of
available tile sizes; then in a loop it creates an array of the tile
sizes that would fit in any empty space on the table. Of the tiles that
fit, one is selected randomly, the indicator of next space to be filled
is updated and continue the loop. If we get stuck, i.e. no tiles
left that fit the available space, we just reset everything and start
over. I'm surprised that it works as well as it
does. There are provisions for stopping the loop and
for setting a maximum search time - probably reflecting processing speeds 9
years ago compared to today.|
|There are options to hold any pattern that catches your eye as looking
good, and to review, delete members and print the held table list.
There's also a print preview option. All that seems to be working, so I
left it alone.|
|I did add Id and Color fields to the tile data and buttons to
display tile Ids and/or colors in the displayed table tops. Also added a
"tick mark" option just to check where tile boundaries could fall.|
Addendum July 14, 2005: Viewer Andrew from France wrote asking
how he could create patterns with multiple colors for the same tile
size. So I tackled the first update in the four years since the
program was originally posted. I sure wish I had done a better job
of documenting the algorithms when I wrote the original code! After 3
days, I managed to get the change implemented, but I'm still not sure how the
thing works. (But I'm pretty sure I could figure it out again if I had
to.) In addition to handling multiple colors of the same
tile size, the form can now be resized and the NumEdit prerequisite
for compiling the program has been removed.
Running/Exploring the Program
Suggestions for Further Explorations
July 14, 2005:
adding the "color" property to tiles, it would reasonable to have
multiple tile entries with the same size but different colors.
Currently the selection process after having randomly selected a particular
sized tile will choose the first one of that size that it finds.
Probably the "available sizes" array entries should
contain pointers to all tiles of that size so that a second random selection
could be made among those.
new tile ID field introduces another complication - the edit dialog should
check that Ids entered are unique. It doesn't.
arrays in the program are static (fixed size) arrays. Converting
these to dynamic arrays would eliminate size constraints on tiles
|Created: November 11, 2001
Modified: July 29, 2017