Delphi For Fun Newsletter #41
Muzzle loader deer season opened yesterday, and the holiday season is nearly here, so I had better get this year's final email sent . The weather has been unusually warm here on the mountain, as it has been over much of the country. Our firewood is stacked and ready to get us through the cold winter weather when it arrives. In the meantime, with the temperature 60 degrees today, the little spike-horn I shot yesterday couldn't hang long, so we processed him for the freezer this morning. One down, one to go.
The 5th anniversary of DelphiForFun passed almost without notice in September. I did remember my 47th anniversary with my wonderful wife in October so priorities are still straight.
Quite a few bug fixes and interesting new projects have been posted since our last newsletter in August. I hope you have as much fun playing with them and learn as much as I did writing them. Here's "What's New" since last time.
August 5, 2005: Here's a program which solves sets of linear equations using a technique called Gaussian Elimination with Partial Pivoting. Even the title sounds scary. Fortunately, this demo program is usable to those of us who are more results oriented and don't worry about the messy details. As usual, complete source code and other references are available for those who do want to dig in.
August 21, 2005: No, I haven't been on vacation again as some surmised from the lack of new postings this month. I took a week or 10 days catching up on Project Euler problems in order to stay on the 1st page of rankings. Also tackled a couple of other projects.
Newsletter #40 was published a week ago, so if you think you are subscribed but didn't get one, your mailbox may be full, an invalid address was submitted, an overzealous spam filter caught it, or some other problem prevented delivery. There were only 30 or so of these this time and my File Update program made short work of deleting the invalid addresses from the mailing list.
I spent a few days in the shop building a physical catapult model to see if my Catapult program results agrees with Mother Nature's laws. If not, I don't suppose she will admit to having made a mistake. I did fire the first projectile today! Tomorrow I'll replace the clamps holding it together with screws and get some measured results. I did post a small revision to the program this afternoon to fix a problem causing the projectile animation display taking a vertical jump between the firing and flight phases. I expect to be making some more tweaks tomorrow when I get real world results.
I also spent several days working on a generalized hull finding routine to fix a problem with the Tangram program which allowed invalid piece placement in some cases - program accepted pieces when vertices were inside the solution space, even though an edge passed outside (see image at left). My idea was to identify the outside edges of the solution space and then check to see of the edges of the piece being placed intersected any outside edge of the solution.
The hull finding program works but turned out not to be applicable to the Tangram problem. I found tangram figures with holes and with disconnected parts that forced me to take another approach. A fix based on checking for piece edges with the background color on both sides was posted today.
I may get around to posting the hull finder one of these days.
August 25, 2005:
I occasionally consult my Wordstuff
program for a little help in solving Mensa
"Puzzle-A-Day" calendar problems. This morning, I realized the
version incorporating "Scrambled Pie" had never been posted. So
Wordstuff now contains links to five word puzzle solvers.
Still working on the Catapult program. The "update" posted on the 21st, actually broke more things than it fixed. A previously corrected problem converting parameters between measurement systems was reintroduced. It's fixed today, but I'm still having problems reconciling program results with real world results from my model catapult. Like my "bullets" should be flying 5 times further than what I'm getting. Either I'm measuring some parameters incorrectly or there's a problem with calculating the acceleration of the projectile when firing. More later.
August 26, 2005:
I posted the "final" version of the Catapult Simulator
today. Results from testing against my new model catapult show reasonable
agreement. The differences between program results and real world
results might be due to program bugs or real world model construction and
measurement errors. Only time will tell.
Minor problems in the Big Integers module occurred when invalid parameters were passed to Invmod or GCD functions. Those are now handled. Visit Big Integer Test for more details and to download the corrected DFF Library module.
Viewer Mariano Lizarraga at firstname.lastname@example.org wrote to say that he has made a Spanish translation of the Astronomy Demo program and would be willing to share it with any one who requests it. Just send him an email request - mention whether you want source code or executable.
September 7, 2005: After several iterations, we are finally posting an update to the Big integers TInteger class which does large integer arithmetic. Viewer Charles Doumar has implemented a number of enhancements including a faster multiply and a new Nth root function. In addition several minor bugs and improvement in check input variable for validity were added.
Motivated by the need to test the changes in TInteger processing functions, I wrote a TRegress class which provides a framework for developing regression testing programs. Regression testing tries to catch is functions that are accidentally broken as other things are fixed or enhanced. In this instance TRegress helps build "Case files" with solved problems and runtimes from the old code and compares them with the same problems run against new code. It has proven itself quite helpful in testing the TInteger changes described above.
September 8, 2005: Mike Conlon was
writing a Basic program pendulum simulation recently and caught a small math
error buried deep in the double pendulum calculations in our Pendulum
program. It doesn't make much
difference in the apparent action of the pendulum - just delayed the appearance
of the chaos part of the Chaos demo (two double pendulums, identical except for
a 0.01% difference in the lower bob weights , will start out synchronized but
soon behave entirely differently). Correction was posted today.
September 14: 2005: A few years ago, I posted a Set Partitions program that addressed the ways that a set of distinct objects could be divided into separate piles. This week I finally had the need to explore the other kind of mathematical partition, Integer Partitions which considers the number of ways that a positive integer can be written as the sum of smaller integers. 5 can be written a the sum of positive integers in 7 ways, for 60 the are about a million ways to do it! You can confirm for yourself such interesting properties as "the number of partitions of N into K parts is the same as the number of partitions whose largest part is K".
September 19, 2005: From the "Computers as Tools" department, I wrote a little utility program today to Remove blank lines that saved several hours of error-prone manual editing. I added a new school to our Booksearch web but trying to update the index page hung MS FrontPage, my web editor. Investigation showed that 35,000 extra lines containing 10 blank characters each were scattered throughout the 136 valid HTML code lines! The normal 12Kb file now contained 360KB. What a mess! We may never know what hiccup caused this but the fix required about 25 lines of code and 15 minutes of "work" to create the tool and fix the file. I decided to post it to the Utilities section of DFF so I'll know where to find it in case the problem ever recurs.
September 21, 2005: Note to AOL users. I am not able to respond to feedback requests from AOL email addresses. My replies get rejected with error "554 transaction failed". It seems to be a problem with AOL having excessively tight filters on senders and not being able or willing to correct the resulting problems. I spent several hours earlier this year, and my host site has also spent much time trying to correct the problem with AOL, but today's rejection indicates the problem still exists. (A Google search on "AOL 554 transaction failed" returns 19,000 hits, so it seems to be a common problem. ) I'm sure it is frustrating to those who send inquiries and not receive replies, and I know it is frustrating for me to spend time researching problems or questions and then having my response rejected. Fortunately, there doesn't seem to be many AOL types left.
To today's victim, AOL user Mike: Inverted text printing seems to work fine here. If you are using program TestMirroredText2.exe, let me know exactly what happens when you try to print. (Use a non-AOL email address please!)
September 29, 2005: I fixed a bug in
Brute Force today
which surfaced while solving this division problem. The solution requires
letters be assigned digit values 0 through 9 to make a true numeric
expression. Brute Force tries to solve sets of equations with
integer values by trial and error. A surprising range of puzzle types may
be solved this way, however, before today, equations with successive minus signs
were evaluated incorrectly. This puzzle and the equations to solve
it, were added to the included samples as
Allwords is a simple program that finds all subsets (words) of a set of letters and optionally filters out those that are not in a dictionary. The program is simple because it uses a couple of our pre-built Delphi classes; one to generate permutations of the letters and another to check generated "words" against a dictionary. Source code for this program available from the Beginner's page in the Delphi Techniques section of our site. The Beginner's page contains descriptions and download links for several simple programs that I've written in response to user's requests.
PhraseFinder is a more sophisticated word search program. It finds sets of valid dictionary words that can be formed from a given set of letters. It is much faster and more flexible than the "Unscramble" program included in Word Stuff 2. Unfortunately, it tends to find too many solutions. I wrote it because I could not manually unscramble 'abcdeefhiklllloooorrtyww' into the phrase "Follow the yellow brick road" so I wanted to see if I could do it with a program. Using PhraseFinder to look for five-word phrases containing words between 3 and 6 letters long produces over 29,000 "solutions" before we get to the alphabetized version "Brick follow road the yellow"!
October 8, 2005: At a viewer's request, I updated the one of our earliest programs today. Roman Numerals was originally posted 5 years ago to convert Arabic numbers (our number system) to Roman. It will now also convert the other way, Roman to Arabic. I suspect that the young person that requested it has the problem as a homework assignment. But she requested the program in "C" so if she does copy this Delphi version, she'll learn a lot in the process of converting it. There are two characteristics of Roman numbers that complicate the conversion to Arabic: Unlike Arabic digits, most combinations of the Roman letter digits do not form valid Roman numerals, so lots of validity checking of the input number is required. Also, there is no zero among the Roman letter digits, so we must detect its non-existence and insert zeros where required in the output.
October 9, 2005: Here's a Metronome program I wrote because I needed one and all of the free ware versions seemed to be more complex than necessary. It generates clicks (3 versions) at rates between 40 and 240 beats per minute. Not much more to say about that.
A change was also made to our Sound Generator program which now generates sounds for a preset number of seconds or milliseconds. The previous version played a one seconds loop of the generated sound until the Stop button was clicked. A new "Save as wave file" button saves the generated sounds. If you haven't guessed, the purpose of these changes was to generate the click files used by Metronome. Five to seven milliseconds of a mid-range triangle or sine wave shape seems to sound quite "clickish".
October 17, 2005: I posted a small change to the pattern guessing game, Mastermind, today. When the program is the "guesser", it makes an initial random guess for the secret pattern. It " forgot" to check to see if that first guess solved the problem before entering a more systematic search loop. I'm pretty sure it will remember from now on.
October 27, 2005: Here's a new version of our common DFF Library file today (DFFLibV04) with a couple of additions. A new UGeometry unit contains several computational geometry routines formerly located in Computational Geometry demo program, (LinesIntersect tests for line intersection, PointInPoly determines if a given point is inside or outside of a given polygon, etc.). GraphSearch uses unit UTGraphSearch unit and illustrates use of a TGraphList class to solve several graph search problems. TGraphList has several changes and additions to support interactive applications. There are no significant changes to GraphSearch, just a repackaging to make TGraphList available for other programs coming down the pike.
program finds Minimal Spanning Trees
using Kruskal's algorithm. A minimal spanning tree is a
set of edges which connects all of the nodes of a graph with the smallest
possible sum of the weights assigned to the edges. (Very handy if you ever
need to design a pipeline to reach a number of cities :>) The
program lets you interactively define graphs and find solutions like the example
November 1, 2005: I just updated the utility program, Remove Blank Lines, to fix a minor problem. Minor to fix, potentially major in consequences. Among other tasks, the Delphi procedure CloseFile writes the last buffer to a file being created. But only if you remember to include the statement. Without it, the final record or records from the input file may never get written to the output file. Thanks to viewer/user Tim D for reporting the bug.
November 11, 2005: I spent a week trying to get a Delphi program that would talk to the ActiveHome CM15A USB X10 Computer Interface. This is a device which can send and receive signals over household power lines to monitor or control other devices (lights, alarms, motion detectors, etc.). The sample code that comes with the ActiveHome SDK (System Development Kit) does not include any Delphi samples and the formats of the messages received just did not seem to match up with what I thought was expected. I returned the device and went back to using an older "Two-way" serial port interface (TW-523) which has worked fine for years. Just thought it might be nice to update the code for a more modern USB interface and to post it here on DFF. Maybe next year. If anyone has had any success, let me know.
project has just been posted, an initial version of the Japanese game of
Go. Black and white stones played on a grid. Surrounded groups of
stones are captured and score points. Like Chess, Go has
become a lifelong study and challenge for thousands of players. I'm
not one of them but did get sucked into the challenge of implementing simple
human to human play. Well, as it turned to be not so simple,
but here's my first version of the game
of Go, bugs and all. Feedback
November 13, 2005: I recently received an email from a fellow who plays the solitaire card game known as Roll-Call or "Hit or Miss". It's a simple game but he's played it for many years without winning a game. He wrote wondering about the chances that he would ever win. So here's a simulation program, Roll-Call Solitaire Statistics. that displays the results for several versions of the game. (It's less than 2% chance of winning for his version.) The program also lets you replay winning games, so he can finally have the thrill of winning, even if he has to set up the deck first!
Darby To subscribe or
unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm 132,000
visitors since Sept
2000. 398,000 program downloads in the past 12 months!
To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
132,000 home page visitors since Sept 2000. 398,000 program downloads in the past 12 months!