Home  |  Introduction  |  Newsletters  |  Programs  |  Feedback






Support DFF

 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.

If you shop at Amazon anyway,  consider using this link. 


We receive a few cents from each purchase.  Thanks



The index page for all Programs on the site?

The DFF Play CD?

Zipped file DFF Play CD.zip contains  executable version of about  75 of the 200+ programs from the site, mostly those I particularly liked or thought would be of widest interest for non-programmers.  The file is rather large, about 20mb..

Anything else?





Search WWW

Search DelphiForFun.org


Not a programmer (yet)?

 That's OK -  the executable version for any puzzle or  game you find here is available for download.  Just scroll down to the bottom of most any description page and you'll find a "Download executable" link. Downloaded programs are in "zipped" format to reduce size and may require an "unzipper" program unless you are running Win XP or later.  Here's a link to a free one. 

Check  out  the Most Popular  Downloads from DFF   (updated weekly)

First time visitor?

Take a look at the Introduction page to see what this site is about

Notes for Teachers


Wednesday, October 29, 2003


 Delphi For Fun Newsletter #34  

Fall is here so it must be time for our quarterly update for you faithful DFF subscribers; around 600 now.   Muzzleloader season is only a week away.  I have enough firewood to last the winter and only a few more Christmas woodworking projects to complete down in the shop.   So we should be ready to get down to some serious programming when the snow flies.   It seems like user feedback has led me to lots of “fix-ups” and enhancements this fall, although there have been a few new works implemented and removed from the “Future Projects” list.

·        The Castle Escape is the only totally new game/puzzle that comes to mind as having been published this quarter.

·        Elevator Simulation simulates multiple elevators running at the same time.   The elevator motion is animated and run under manual control.  The next version will run predefined scripts and allow users to control how requests are met.

·        Cut List is the most recent addition – it tries to find the best way to cut a list required material pieces from available stock.

·        Other new projects include Graphic Effects and Big Cursors in Delphi Techniques and Probability Distributions in Math Topics.

We did pass a couple of milestones recently  - September marked three years of operation for the Delphi For Fun website and we also passed 50,000 home page views.    Total pages viewed now averages about 50,000 per month mostly from search engine referrals.   

This will be the first newsletter sent under our host’s new “SmarterMail” mail/list server.  Let’s hope that it lives up to its name.

Here’s the complete list of "What's New" items since last time.

August 5, 2003:   A viewer from New Zealand pointed out that my Solar Position program had his sun rising in the evening and setting in the morning.  He reported that he was having trouble sleeping under those conditions so I fixed it today.   A slight southern hemisphere glitch was the cause.   As usual, I found another problem while there - the Analemma graph only worked after the "Sunrise Sunset"  button had been clicked.  Fixed that one too.  

August 6, 2003:  Today's Mensa© Puzzle Calendar problem:  Jim was arranging his identically sized stamps on page.  When he put 8 to a page, he had 1 left over; with 9 to a page, he had 4 left over; with 10 to a page, he had 1 left over; and with 12 to a page, he had 1 left over.  What is the smallest number that will allow him to fill each page with the same number of stamps?

I solved it by exhaustive search in about 10 minutes, then recalled that it sounded like a Chinese Remainder problem.  Sure enough, I had posted a program a couple of years ago that would have solved it.   So I went back and added this problem to the samples that are included with  Chinese Remainders 2.   Solve it either way - take your choice.  

August 12, 2003:  An elderly queen, her daughter, and little son, weighing 195, 105, and 90 pounds respectively, were kept prisoners at the top of a high tower.  There is a cord passing over a pulley with a basket at each end, and so arranged that when one basket rested on the ground, the other was opposite the window.   The Castle Escape program lets you, or the program, help them escape.  Adapted from Merlin's Puzzle Pastimes, Charles Barry, Dover Publications.

August 16, 2003:  Version 6 of the Roller Coaster Simulation program was posted today.  It adds a template feature suggested by  Dr. Jon Thomsen of the Technical University of Denmark.  The idea is to allow his Dynamics engineering students to better compare their theoretical predictions with simulation results.   Wow, my program is going to college!  



August 21, 2003:  The our first version of the Token flip puzzle was published in April, 2001.   You solve the puzzle by clicking on tokens, each click flips the color of that token and tokens which adjoin vertically and horizontally.  The objective is to get all tokens with their white side showing.  My original  version auto-solved  puzzles on its own by brute force searching.  But search times get impossibly long for board sizes larger than 5X5.  This April, viewer Bernd Hellema came through with a Pascal linear algebra solution  which solved puzzles in milliseconds and which I modified for Delphi and posted.   But it took 10 moves to solve a 4X4 all black board that I could solve in four moves.  

I mentioned that to Bernd and  a few days later he had enhanced his code to return the optimal (lowest move count) solution for all boards.  This truly final version of TokenFlip Final was finally posted today.  

August 24, 2003:  Viewer and unofficial chief beta tester,  Don Rowland, reported some bugs in the Circle Covering Points program the other day.  He suggested fixes for some, and I fixed the rest.   No bugs left in this program!



 August 27, 2003:  Graphic Effects is based on a program written by a  young Delphi programmer from Czechoslovakia  posted  today over in Delphi Techniques.   It is a clever demonstration of 15 different   text and graphics effects.   I added some user inputs to replace hard coded values,  generalized the "Contrast"  page to handle multiple values, and  added a "Brightness" effect.  Most of the rest is as "Ivanoslav"  wrote it.  


id=_x0000_s1035 style="MARGIN-TOP: -97.5pt; Z-INDEX: 5; MARGIN-LEFT: 0px; WIDTH: 135pt; POSITION: absolute; HEIGHT: 105.75pt; mso-wrap-distance-left: 7.5pt; mso-wrap-distance-top: 0; mso-wrap-distance-right: 7.5pt; mso-wrap-distance-bottom: 0; mso-position-horizontal: left; mso-position-horizontal-relative: text; mso-position-vertical-relative: line; mso-position-vertical: absolute" type = "#_x0000_t75" coordsize = "21600,21600" alt = "" o:allowoverlap = "f"> August 31, 2003:  A viewer asked the other day about using cursors larger than the standard 32 X 32 pixels.     To the best of my knowledge, there is no Windows or hardware method.  Here is my Big Cursors solution using common sprite techniques and posted over in the Delphi Techniques section. 

September 2, 2003:  Two years ago I published Shared Birthdays in the Math Topics section of DFF.  It discusses the probability that N randomly selected people will share a common birthday.  Like nearly all of the discussions of this problem, it ignores the existence of   Feb 29 birthdays during a leap year.  Someone pointed out some code a few months ago that addresses the leap year issue.   The statistics change very little but the difficulty of understanding the methodology increases a bunch  when leap years are introduced.  I finally spent a day working through the algorithm and posted my description and revised program in a separate Shared Birthdays Leap Year page. 


 September 3, 2003:  Viewer Mark wrote today about a problem with another old math demo program, Circle >From 3 Points.  He was confused because the Y coordinate increased toward the bottom of the screen.   So normal for us programmers that I forgot that it was not so for everyone else.  I fixed it today.  


September 4, 2003:  Max Burgos has been converting my Tangram 2  program to Visual Basic.    He pointed out two errors in the Delphi version, one of which is now fixed.   In the diagram at left, the first figure in the "Easy" figure set, the large red triangle could have been rotated and dropped over the small green triangle without the overlap being detected.  There were all sorts of tests for shared borders and intersecting sides but the "completely enclosed" case slipped through.   If you want to gain an appreciation for the human visual system, study the algorithms to determine whether polygons touch or overlap.     

The second error is not so easily fixed.   The fourth figure in the "Veryhard" figure set can be incorrectly solved leaving a empty space  (Place the parallelogram across the "arrow shaft" - it should not fit, but it does).   The problem is that figures get distorted as they are rotated because the coordinates used to define pieces and figures are not accurate enough.    No luck so far in making the definitions more accurate and still keeping existing figure definitions usable.    


September 5, 2003:  Thanks to sharp-eyed (and sharp) viewers, this seems to be program fix-up month.  To go along with the theme I posted a new version of FileFixup today;   The original program corrected a particular problem I had with a malformed file that included an extra carriage return at the end of each line.   Steve Moller from the land down-under recently made a worthwhile addition to the program by incorporating Delphi's AdjustLineBreaks function.   This function corrects other common line break errors by inserting missing Cr or Lf characters to make valid line endings.   It also reverses Lf-Cr sequences to  Cr-Lf.    While at it, I added a display form to show hexadecimal and character views of the input and output files.  Just for testing I've added file  PasDoc2.txt  with missing carriage returns in the downloads.    


September 8, 2003:  Dürer's Magic Square appeared in an engraving by Albrecht  Dürer in 1514.  This program,  posted some time ago, challenges the viewer to see how many of the 86 number combinations adding to the square's magic number  they can find.    Viewer Don Rowland recently noticed a minor problem while finding solutions -  the program allowed selecting the same number more than once!   Together we came with the fix  posted today.   



September 14, 2003:  Don Rowlett reported a minor problem with a Graph Traverse program posted some time ago.  The program is mainly a demonstration of depth first search techniques as it checks all paths through a grid of numbers looking for the path with largest and smallest sums.   The grids are randomly generated and the display for the largest size had been truncated.  Fixed today.    

Also posted today one more attempt at improving the piece moving method in Tangram2.   Max Burgos found another bug allowing pieces to be dropped on top of  other pieces under some conditions.    I replaced the PointInPoly procedure with one that works only for convex polygons (polygons without indentations).   If we move around such a polygon (i.e. tangram piece) and check each side against a point being tested, any interior point will always be on the same side of each edge.   Any exterior point will always  fall on both sides of the lines through the edges


September 21, 2003:  Today's program over in the Delphi Techniques section explores threaded processing.  Threads are separate processes that run independently within a single program's space.   I have been working for several days on an Elevator Simulation program.  Controlling these things is a tougher problem than appears at first glance, partially because the order of handling requests depends on the state of the system as well as the order received.  To make a long story short, after several false starts, I decided to define the elevators as thread objects where they can operate independently.     Threads test 1 - Elevators looks like a promising start.  And I learned enough about  threads coding in the process to make a separate posting seem worthwhile.   

  September 28, 2003:  Building on last week's threads test, I completed and posted Elevator Simulator 1 today.  The "elevators" from last week's program now have internal destination buttons that you can access by clicking on an elevator.  There are also up/down call buttons on each floor and a simple scheduler to dispatch an elevator in response to call button clicks.   We're up to about 1000 lines of code so far and are perhaps half done.    Version 2 to follow will allow user control of scheduling strategies, add automated passenger scripts and performance reporting, but probably not next week.  

 I need a break to pay play with my new log splitter!   . 


October 6, 2003:  A viewer wrote the other day asking if I could validate American Express card numbers.     I don't have a Amex card, so can't be sure, but I posted a version of the Check Digits program today that  tries.  It validates my Discover card OK, as well as Visa, MasterCard,  "mod 11" ISBN (book) numbers and traditional "mod 10" check digits.    Perhaps an Amex card holder will send me feedback if the program happens to work for their card.

October 17, 2003: 

Exponential Poisson


It has been a while since I posted a program partly because we're trying to get ready for winter here on the mountain.   Also today's posting, Probability Distributions, was one of those simple little ideas that turned out to be not so simple to implement.   It started while thinking about  the "people generator" for version 2 of my elevator simulation program.  Simulating the time between random arrivals often assumes an Exponential distribution, which is related to another distribution, the Poisson, describing arrivals per unit of time.    I decided to post a Math Topics program describing this relationship and showing how the statistics of sample data relate to theoretical statistics.  What the heck, might as well throw in the Normal And Uniform distributions and maybe an illustration of the remarkable Central Limit Theorem.  Two weeks later, here it is. 

October 18, 2003: Thanks to viewer Brandon Hunt, the confusion over Amex and Discover cards has been cleared up. They do use prefix digits in creating check digits.   All major cards use the same algorithm as described in the ANSI standard that governs credit cards: ANSI X4.13, "American National Standard for Financial Services - Financial Transaction Cards".   Hans Peter Luhn, one of the early pioneers developing techniques for making computers useful, developed the algorithm.  He was granted the check digit patent in 1960, at age 64.   Who says that us old codgers lose our mental faculties?      I reposted the Check Digits  program today with the new information and deleting all that foolishness testing whether card number prefixes are required - they are. .       

October 21, 2003: Viewer Joe wrote a few weeks ago asking if I could make a version of our Four In A Row game that would allow three humans to play each other.  He also wanted to be able to set a larger board size.   Four In A Row, Version 2B  does it.  Have fun Joe!

October 27, 2003: 


A Cut List is a list, or better yet a diagram, showing how to cut material pieces required for a project from a set of available stock pieces.  Here's CutList,  an update of a program I wrote 10 years ago to solve a particular problem



Gary Darby


"Somewhere, something incredible is waiting to be known."  Carl Edward Sagan

To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm

 55,000 home page visitors since Sept 2000.     179,000 programs downloaded in the past 12 months!