TITLE: A Fresh Encounter with Hexapawn
AUTHOR: Eugene Wallingford
DATE: January 06, 2022 2:47 PM
DESC:
-----
BODY:
When I was in high school, the sponsor of our our Math Club, Mr. Harpring,
liked to give books as prizes and honors for various achievements. One
time, he gave me Women in Mathematics, by Lynn Osen. It
introduced me to Émilie du Châtelet, Sophie Germain, Emmy
Noether, and a number of other accomplished women in the field. I also
learned about some cool math ideas.
Another time, I received The Unexpected Hanging and Other Mathematical
Diversions, a collection of Martin Gardner's columns from
Scientific American. One of the chapters was about Hexapawn, a
simple game played with chess pawns on a 3x3 board. The chapter described
an analog computer that learned how to play a perfect game of Hexapawn. I
was amazed.
I played a lot of chess in high school and was already interested in
computer chess programs. Now I began to wonder what it would be like to
write a program that could learn to play chess... I suspect that Gardner's
chapter planted one of the seeds that grew into my study of computer
science in college. (It took a couple of years, though. From the time I
was eight years old, I had wanted to be an architect, and that's where my
mind was focused.)
As I wrote those words, it occurred to me that I may have written about
the Gardner book before. Indeed I have, in
a 2013 post on building the Hexapawn machine.
Some experiences stay with you.
They also intersect with the rest of the world. This week, I read Jeff
Atwood's recent post about
his project
to bring the 1973 book BASIC Computer Games into the 21st century.
This book contains the source code of BASIC programs for 101 simple games.
The earliest editions of this book used a version of BASIC before it
included the GOSUB command, so there are no subroutines in any of
the programs! Atwood started the project as a way to bring the programs
in this book to a new audience, using modern languages and idioms.
You may wonder why he and other programmers would feel so fondly about
BASIC Computer Games to reimplement its programs in Java or Ruby.
They feel about these books the way I felt about The Unexpected
Hanging. Books were the Github of the day, only in analog form.
Many people in the 1970s and 1980s got their start in computing by typing
these programs, character for character, into their computers.
I was not one of those people. My only access to a computer was in the
high school, where I took a BASIC programming class my junior year. I
had never seen a book like BASIC Computer Games, so I wrote all
my programs from scratch. As mentioned in
an old OOPSLA post from 2005,
the first program I wrote out of passion was a program to implement a
ratings system for our chess club. Elo ratings were great application
for a math student and beginning programmer.
Anyway, I went to
the project's Github site
to check out what was available and maybe play a game or two. And there
it was:
Hexapawn!
Someone has already completed the port to Python, so I grabbed it and
played a few games. The text interface is right out of 1973, as promised.
But the program learns, also as promised, and eventually plays a perfect
game. Playing it brings back memories of playing my matchbox computer
from high school. I wonder now if I should write my own program that
learns Hexapawn faster, hook it up with the program from the book, and
let them duke it out.
Atwood's post brought to mind pleasant memories at a time when pleasant
memories are especially welcome. So many experiences create who we are
today, yet some seem to have made an outsized contribution. Learning
BASIC and reading Martin Gardner's articles are two of those for me.
Reading that blog post and thinking about Hexapawn also reminded me of
Mr. Harpring and the effect he had on me as a student of math and as a
person. The effects of a teacher in high school or grade school can be
subtle and easy to lose track of over time. But they can also be real
and deep, and easy not to appreciate fully when we are living them. I
wish I could thank Mr. Harpring again for the books he gave me, and for
the gift of seeing a teacher love math.
-----