April 3, 2010
Delphi For Fun Newsletter #56
Welcome to warm weather. At least here in Virginia, even up on our mountain, temperatures reached into the 70's yesterday and the snow banks seem to have disappeared at last. The common feeling in these parts is that we'll pay the price later for the warm weather now, as in a frost to kill off the blooms that will be tempted out this week..
Programming this quarter was about normal for this time of year averaging one posting per week, split evenly between 6 updates and 6 new programs. Of these, the one most satisfying to me was last week's posting of my investigation of Archimedes derivation of the value of Pi.
Here is the complete list:
January 4, 2010:
While playing the "Wii Play" version of the Four-In-A-Row game
with a grandson over
the holidays, I used my Delphi version of the game to advise me on moves
to make. I was embarrassed to find that the program's random
moves "enhancement" frequently allowed Chris to win by placing 4 adjacent token in his first
4 moves - the initial random moves feature assumed that there would be no winner that soon.
Four In A Row Version 2.2 posted today
fixes the problem by limiting initial random moves to 2 or 3 turns.
A university student recently took on a Java version of the
MasterMind game as a school project. He wrote asking about my "Smarter
than you" intelligence level which can be applied when the program is doing the
guessing about the secret pattern. The program has a Verbose mode which
was supposed to help debugging and explaining the search steps, but the messages
were being cleared after each computer guess.
Version 2.1 corrects this and hopefully will help him and others understand
the mini-max guessing procedure used at the smartest level.
January 9, 2010:
"Instant Insanity" is a variation of an older cube arrangement puzzle and one of a large family of similar puzzles. In this one, we have four cubes with one of four colors on each face of each cube. The objective is to stack the cubes so each column of faces has all four colors.
A viewer recently asked for help in developing a Delphi solver
Most of the online literature describes a graph search algorithm which can be
applied to find solutions
with pencil and paper. With a faster but dumber computer, it's easiest
just to check all 41,472 possible arrangements looking for
solutions. Instant Insanity
Version 1.0 posted today does just that with a few sample or user defined
February 1, 2010: A couple of times each year I get a request for help from a student requesting help in some project using my "Reaction Times" programs. This year it was a graduate student in at a Medical School in Ecuador whose thesis topic is to test the effect of sleep deprivation on interns as result of the long hours they put in. Her problem turned out to be decimal separator confusion because the PC she was using happened to have the Window's Locale set for a European country. Changing back to Ecuador set it from comma back to dot and allowed her to analyze her data. While investigating, I discovered and fixed a problem with the ResponseStats statistical analysis program that kept a newly loaded response statistics file from being made available. Reaction Times programs including ResponseStats Version 3.1 was uploaded today to fix the problem.
February 4, 2010:
Word squares are square letter arrays with rows containing words
which match words formed by the corresponding columns. Here is a
Word Square Search program which
searches a 62,000 word dictionary to create word squares based on an initial
word provided by the user. At left is one of 149 solutions found for
the word "WORD".
February 23, 2010: I recently needed to send the log file from a newsletter mailing to help diagnose a minor problem. However the log file contained the email addresses of each recipient and sending them in unsecured plain text did not seem like a good idea. This program, Obfuscate Text, added to our Utility section, confuses email address one of two ways; replacing the name portion with a random word or replacing the entire email address with an "address removed" phrase. In both cases, email addresses are identified by the embedded @ symbol. As an exercise that might be useful some day, I added an option to obfuscate the word following a given word. For example, changing the word following the word "Password:".
February 17, 2010:
Waterjugs Version 3 now solves problems
with up to 7 jugs (or jars). This required a major rewrite of the previous
version where run time exploded for problems larger than 4 jars. The
problems require pouring water from one jug to another to obtain a target
configuration of water amounts in each jug. At the start of the problem,
we are given the capacity and the amount of liquid in each jug. There are no
graduation marks, so each pouring from jug A to jug B transfers the smaller of
the liquid in A or the unused capacity of B. The included 7
jug problem was submitted by Melanie whose program ran for days without finding
a solution. My first attempt with the old version would bomb (stack
overflow error), my
second attempt found the answer in 25 minutes and this version accomplishes the
goal in 2 1/2 minutes. You are welcome to pour 'til your
heart's content on the 7 jug problem included, but be forewarned, the shortest
solution requires 48 moves!
February 10. 2010:
Triangle program provides mathematical and visual views of a problem every
pilot, or at least every amateur pilot must wrestle with; how to get where you
want to go when the wind wants to take you off course. The answer is
to head the airplane into the wind just enough to offset the distance that the
wind moves you. Version 2 lets users change colors from my default
choices in order to address a problem recently reported by a pilot who happens
to be "color handicapped".
March 4, 2010: A Text Spinner program suggested by a viewer was added to our Delphi Techniques section. today. A "text spinner" randomly changes the content of a text based on some criteria, in this case a supplied set of alternative phrases embedded within the input text. Not very practical, but an interesting intermediate level programming exercise anyway.
March 11, 2010: A small bug was reported and fixed in the Computational Geometry test program, Geometry4 today. The "Draw line from point perpendicular to line" demo page (PerpSheet) did not allow the initial line to be drawn due to a rookie coding error. In the "mouse move" procedure, the statement: if (activepage=PerpSheet) or (activepage=AngleSheet) and (dragval=1) then begin needed an extra set of parentheses (colored red here) to look like this: if ((activepage=PerpSheet) or (activepage=AngleSheet)) and (dragval=1) then begin. This is the coding equivalent of writing the algebra expression A + B * C when you meant (A + B) * C. Results in both cases were wrong!
March 18, 2010: I use our "Monitor Off" program each evening to blank the monitor on my old laptop dedicated to capturing and reporting outputs from our weather station. Monitor Off Version 2 fixes a problem a user had with the alternative code for blanking the monitor, The "Power-Off" option, should now work when the "Standby" option does not. I have tested it under Windows 7 on my Dell Studio 17, my first laptop to require its use. The program uses the Pause key to blank the monitor, regardless of the active window.
In the process of testing, I also found that the Studio 17 uses the Fn + F12 keys to emulate the missing Pause key. I have no experience with other company's laptops, but I suspect that they all use a similar technique to replace the seldom used Pause key with a virtual alternative. Dell doesn't seem to document the "feature", but my Key Codes program will help find the hidden key in short order.
March 28, 2009:
I spent most of this past week in discussions with Mr.
Archimedes about his approximation of the value of Pi. It was largely a
one-way conversation with me asking "How do you know that?" and his only reply
being the sparse text he wrote 22
centuries ago. Fortunately we have an English translation of his "The Measurement of the Circle" which largely presumes that you have
recently completed your high school Algebra and Geometry classes. There
are many "proof is left to the user" results presented on the
path to his
novel, and most accurate at that time, conclusion that the ratio of the
circumference to the diameter of a circle is greater than 310/71
and less than 31/7. Did I
mention that he did not have access to decimal notation or the trigonometric
functions which depend on knowing the value of Pi or calculators or computers?
I have new appreciation for an amazing mind. My
Archimedes' Estimation of Pi
program is an attempt to follow and fill in some of the blanks in his proof.
quality of a person's life is in direct proportion to their commitment to
excellence, regardless of their chosen field of endeavor. - Vince
Lombardi (Football Coach)
Talent is cheaper than table salt. What separates the talented individual from the successful one is a lot of hard work. - Stephen King (Author)
To subscribe or unsubscribe from this newsletter, visit http://delphiforfun.org/newsletter.htm
298,000 home page visitors since Sept 2000. 217,000 program downloads in the past 12 months!