## Chutes and Ladders Infinite Loop

I play Chutes and Ladders with my kids sometimes. It isn’t a game of skill. Many months ago I was involved in a game that went on and on and on. As soon as someone would get close to the end he or she would land on a chute and be shunted nearly back to start.

I was left wondering just how long a game would last. So this week my son and I implemented a simulator in Python to calculate how long any one person’s game would last. Each person’s play is independent in Chutes and Ladders, the characters do not interact. Therefore, simulating an entire game is almost as easy as simulating a single player’s experience.

First, the board is 100 cells long and the spinner gives you a value between 1 and 6, just like rolling a die. A fair die will have an average roll of 3.5, so on average it would take about 100/3.5 = 28.6 turns to finish a game if there were no chutes or ladders. The histogram of game length without chutes and ladders is below. The longest plausible game is about 35 turns in this scenario and the average is 28.6 turns, estimated from 10,000 random trials.

The addition of chutes and ladders stretches the histogram radically. Instead of the longest single-person game being about 35 turns, it is now over 200 turns. Fortunately, a 200-turn game is not very likely. Surprisingly the average is not a hundred million years. At 30.8 turns the average game with chutes and ladders is only a little longer than the average game without.

Pretty cool.


import random
import pylab as plt
import numpy as np
d = {}
for i in range(1, 101):
d[i] = i

cl = {1: 38,
4: 14,
9: 31,
16: 6,
21: 42,
28: 84,
36: 44,
48: 26,
49: 11,
51: 67,
56: 53,
62: 19,
64: 60,
71: 91,
80: 100,
87: 24,
93: 73,
95: 75,
98: 78}
d.update(cl)
numturnsa = []
for t in range(10000):
numturns = 0
pos = 0

while True:
numturns += 1
pos += random.randint(1,7)
if pos &amp;gt; 100:
break
# To &quot;play&quot; without chutes and ladders, comment out the next line.
pos = d[pos]
numturnsa.append(numturns)

plt.figure(figsize=(5,3))
plt.hist(numturnsa, 60)
plt.xlabel(&quot;Number of turns&quot;)
plt.ylabel(&quot;Count&quot;)
plt.savefig(&quot;chuteshist_nochutes.png&quot;, dpi=200)
numturnsa = np.array(numturnsa, dtype=&quot;f&quot;)
print &quot;The average number of turns is&quot;,np.mean(numturnsa)


## Typefaces

Updated February 5, 2014 to correctly display the LaTeX screenshot, minor prose edits, and added discussion of font styles.

I do not know if you have a favorite font. I do. I really like Microsoft’s Calibri font because it is very readable on screen and paper and it looks professional. With that in mind, it has several huge shortcomings for much work. Let me list

• You don’t have a right to use the font unless you have purchased it (for \$120) or acquired with a legal license of a Microsoft product that includes it.
• Calibri does not have small caps family member
• Calibri does not have a corresponding math font

Many people, including me, got to know Calibri because it is the default font in Microsoft Word. I am trying to find a way to leave Word because it has poor support for equation numbering, mediocre bibliography support. It is also difficult to automate updated graphics using non-Microsoft work flow. For example, I often generate graphics in Python with Matplotlib and write them to a file. I would like my document workflow to pick up the picture automatically when it changes but have not found a reliable way to do this in Word.

Microsoft Word is fundamentally poor at rendering documents compared to a display tool like Adobe Reader. Consider the following screenshot comparing a default Word document snippet in Calibri with Word’s rendering of text in the TeX Gyre Bonum OpenType font. Next screenshot is from a Word display at 100% zoom.

The shading in the Bonum section is appalling. Look at the dot over the letter i in pi. Word renders the compatible TeX Gyre Bonum Math and TeX Gyre Bonum fonts differently depending on whether it is in equation mode or body text. The shading in the top paragraph is good; however, the overall construction is horrible. In Word a number in equation mode is displayed in the default math font Cambria. Calibri does not match Cambria and the two numbers can’t look the same. Furthermore, the fraction in the middle of the paragraph causes the line spacing to expand just on that line, making it look almost like there are more paragraph breaks than there should be. Distracting and unattractive.

The next picture is screenshot from Adobe Reader X at 100% zoom viewing a LuaLaTeX generated LaTeX document.

First, the TeX Gyre Bonum snippet is readable and reasonably good looking. The math font and text font are indistinguishable, as they should be. LaTeX handles even Microsoft’s pet font Calibri better than Microsoft. The fraction renders clearly and readably. It does so without creating a large horizontal gap.

The ideal faces, from my point of view, should:

• Be embeddable in your electronic documents
• Not cost much to install on every system you want to use (eleven computers at least)
• Work on Windows, Linux, and MacOS
• Include regular, bold, italic, bold italic, small caps, and math families
• Be functional with Word or other non-LaTeX tools.

The license problem is unquestionably the most limiting factor since OpenType now seems to allow fonts to work across platforms. The GUST project has created a series of libre fonts called the TeX Gyre fonts. Among these fonts, only three have the math family, and all three of these satisfy the other requirements.

 TeX Gyre Bonum Based on URW Bookman L TeX Gyre Pagella Palatino-like TeX Gyre Termes Times-like

There are several other Gyre fonts that are quite attractive and potentially useful but lack the math fonts. TeX Gyre Schola seems to be planning a math font which is not yet ready. If you don’t need to have a math font, or don’t need a matching math font then there are many other fonts to consider. Fontsquirrel has a lovely list of libre fonts. There are other fonts available for LaTeX that can produce good results but do not seem to have a functional method to work with other tools.

Wikipedia describes Calibri as a “humanist sans-serif typeface”. The closest TeX font with math support, to my eyes, is KP Sans-Serif. The strokes are not as modulated so the KP looks less refined than Calibri. I do not see how to use that typeface outside of LaTeX. If you are interested in other LaTeX fonts, consider looking at the LaTeX font project fonts with math support.

## Glue on Paper

Last summer I assigned my son, then six years old, to do an “inquiry.” Inquiries are guided studies of something, and empirical inquiries are like mini science fair projects. At the time I asked him to pick a topic he selected “how does glue work?” Exploring this at the chemistry level seemed like too big a reach for a 6 year old, so we morphed the question into “how well do different kinds of glue work?”

It turned out to be a really fun experiment. We gathered all the not-too-toxic glues from around the house. The oxiclean container has methyl cellulose inside.

He glued several trials of each paper together as crosses. Then, he brought the ends of the paper together and clamped, one piece of paper to a board hanging over the edge of the desk, and the other piece to bucket. In the picture below you can see the test setup. The paper is like two U-shapes that are glued where the come together. They don’t loop inside one another, they are held together only with glue. The glue joint area was approximately 1 inch square.

He added weight to the bucket until the paper failed, and then weighed the bucket.

The glues and results are in the table below. The “r” indicates that the paper ripped, otherwise the glue joint failed across the surface. The best and worst are boldface.

 # Glue Name Average Weight Held (lbs.) Trial 1 Trial 2 Trial 3 1 Elmer’s Glue Stick 1.52 1.096 1.234 1.222 2 PVA:Methyl Cellulose 1:1 vol. 2.37 3.064 2.888 2.062 3 Elmer’s Glue-All 3.39 3.270 3.944 (r) 2.928 4 Gorilla Glue 2.27 5.438 3.180 0.746 5 Methyl Cellulose 4.20 4.468 4.392 3.752 7 PVA 3.65 3.966 2.768 3.824 8 Titebond III 4.25 3.824 5.180 3.576 9 DAP Strongstick 1.54 1.460 1.562 1.576 10 Cyanoacrylate (Super Glue) 4.15 5.180 3.966 (r) 3.284 (r)

Most of these results fit my expectations. There were a few surprises though.

• Gorilla glue (polyurethane) was typically quite strong, but once was very poor.
• Methyl cellulose is usually considered a weak glue, but it performed almost as well as the best of them. Maybe it is strong in our dry climate and weaker in more humid climates?
• Glues that soak in well (super glue and methyl cellulose) seem to have an advantage.

The test was essentially performing a sort of peel-off strength test. In many ways I think the setup was quite good. The stresses on the glue joint are fairly typical for what materials are stressed with.

## Back Yard Oriole

We were visited by a female Bullock’s Oriole Icterus bullockii this evening, and the last.  She came to the feeder for the grape jelly.  I guess her kids eat like mine.  What a treat to see her.