Sunday April 15, 2001
Delphi For Fun Newsletter #15
Spring Gobbler season is here! The season opened Saturday. The score so far: Turkeys 1, Hunter 0. The lead hen saw me in my hidey hole about the same time I saw her. She flew up into a birch tree about 30 yards away and watched 20 minutes for me to move. Ever tried sitting without wiggling a finger for 20 minutes? Every bone in my body was aching when she finally flew down out of sight behind a tree. As soon as I straightened up I heard a "puck puck puck" from a second one off to my right and off they all went. I did catch a glimpse of the snowwhite head of a gobbler as the dozen or so ran up the hill through the woods. I just love being outsmarted by something with a brain the size of a pea. Tomorrow will be a different story. Here are the "What's New" excerpts since last time. April 15: 2001: Here's a program I call Fences and Traveling Salesmen. It illustrates "connectthedot" graphics algorithms for
Oh  a version of the Cannonballs program that always knows when it hits the target was also posted (See below for details of the problem). Also corrected the coordinate calculations to move the ball more accurately. The old version rounded each velocity increment to integers which affected the path significantly in some cases. April 12:2001: The math topic Intersecting Lines is ready. A good algebra refresher with a downloadable program that allows you to graphically define a couple of line segments and then tells you if they intersect or not. Not very impressive for 2 day's "work". Especially considering that a frog has to do this in real time every time he catches a fly  with the endpoint of one of the lines moving! Now that's impressive! I wonder how long it takes the frog to learn the trick. Does each frog have to write his own program? Or do their little tadpole brains come preprogrammed? So many questions, so little time. In any event, we're now prepared to fix the Cannonballs program. Oh  a version of the Cannonballs program that always knows when it hits the target was also posted (See below for details of the problem). Also corrected the coordinate calculations to move the ball more accurately. The old version rounded each velocity increment to integers which affected the path significantly in some cases. April 11: 2001: I posted a correction today for the first of the bugs uncovered by granddaughter Kristen: In PrimeFactors1, results will be invalid for numbers with prime factors exceeding 2^{31 } (around 2 billion). The problem was that the Factors array in the U_Primes unit was defined as type integer (32 bit integers) instead of int64 (64 bit integers). You can just change that line in your source code, or download again. A second bug is turning out to be more challenging. She found that at certain angles in the Cannonballs program, the ball would pass through the target without registering a hit. The problem was easy to diagnose  the cannonball is moving a distance greater than the width of the target in each time unit and so can pass "through" the target between iterations. Saving the previous position and checking when we get to the right of the target would catch that case but I've decided to rewrite the whole collision detection routine. Collision detection is a critical task in robot path planning, ray tracing (for simulated lighting effects in graphics) and in every action adventure game. It's also a topic usually covered in senior and graduate level computer science courses at universities, so there must be some interesting math in there somewhere.. April 8, 2001: Here's the Easter dates program just in time for this season. If you're a Christian, or live in a country that gives you a day off on Good Friday, you already know that Easter this year is next Sunday, April 15th. But how about next year, or in 2010, or the year you were born? It's a simple beginner's level program, even if a large amount of labor has been spent in deriving the algorithms (not by me). April 5, 2001: We're back! Home again after spending a couple of weeks with grandkids in Connecticut and Alabama on spring break. I can report that precocious 11year olds can pick up on Delphi fairly quickly. In a few hours, Kristen wrote "Hello World" and a version of the "Cats and Mice" puzzle. I was setting over her shoulder and providing vocabulary, but at the end she was diagnosing "missing semicolon" and other simple error messages and was using Object Inspector to modify properties on her own. We're planning a Computer camp at Grandpa's for this summer. 11year olds also make good beta testers  I'll be posting some corrections in the near future. (4year olds on the other hand, are much more interested in Hot Wheels Stunt Car Driver games) For now, here's a Word Ladder program that can change FLOUR to BREAD in 6 steps and STONE to MONEY in 11. Another graph searching program implemented with depthfirst and breadthfirst algorithms. (Word Ladders are those changeoneletteratatime puzzles so CAT to DOG becomes CATCOTCOGDOG, for example). March 15, 2001: It may be too late to make use of this Windchill program for this year (I hope). And the "International Windchill Conference" recently agreed to change the formula to make it more accurate for next year. But I wrote the program one cold, windy day a week or so ago and it's finished so I may as well publish it. The program is in the "Intermediate level" because it addresses a couple of subtle coding problems with the Delphi's trackbar component (TTrackbar). Not the kind of problems a beginner needs to worry about. Forgot to mention, I also posted a short article on Proof by Contradiction in the Math Topics section a few days ago. The idea is to assume that what you are trying to prove is not true and then see if this leads to some impossible conclusion. The example given shows how Euclid used this technique to prove that there is no largest prime number. March 14, 2001: Have you ever wondered how those "sort column" features work for a displayed grid? Probably not. But here's another Delphi Techniques program that shows how to do it anyway. Grid Sort displays a stringgrid of random data. Click on the header of any column to resort the rows in increasing sequence by that column. March 13, 2001: Here's a program which illustrates accessing drive and file information. If you need to locate the CDROM or Network connected drives in code or want to access all files matching a certain mask, you'll get some ideas of how to do it from this DriveDemo program in the Delphi Techniques section. March 11, 2001: The Big Factorials program is available. It calculates N! (1x2x3x4....xN) for values of N up to 999. 999! contains over 2500 digits, a very large number indeed. The distance from the Sun to our furthest planet, Pluto, is approximately 13! kilometers and it's only 23! kilometers across the known universe. Since these numbers are far larger than any computer can handle directly, we just wrote a program that works like a very fast human with a pencil and paper. We also added an article in Delphi Techniques section describing how to let the user stop execution of a long loop. 4061 visitors
To subscribe or unsubscribe from this newsletter, go to
http://www.delphiforfun.org/newsletter.htm
"Don't go
around saying the world owes you a living; the world owes you nothing;
it was here first."  Mark Twain

