## You're reading: Posts Tagged: nim

### Bouton numbers: a new integer sequence

In the 1901 paper that named the game Nim and provided its mathematical analysis, Charles Bouton defined “safe combinations”, positions that if you leave the game in this state, your opponent cannot win. In combinatorial game theory, these are $$\mathcal{P}$$ positions (the previous player has already won), as opposed to $$\mathcal{N}$$ positions (the next player can win).

Bouton gives a list of “the 35 safe combinations all of whose piles are less than 16”, working in three-heap Nim. Naturally it seemed sensible to check these, so I wrote a bit of Python code to do this. Bouton’s list is good. I realised I could easily adapt my code to find out how many $$\mathcal{P}$$ positions there are for three-heap Nim games with other maximum heap sizes: 1, 2, 3, and so on.

And, having generated a sequence of integers, I naturally looked to see if it was in the OEIS. This is sometimes a good way to discover that your sequence of numbers is also found in some unexpected places. It wasn’t there! So I submitted it, and I just got the exciting email “N. J. A. Sloane published your changes”. So I present A363166: “Bouton numbers: a(n) is the number of P positions in games of Nim with three nonzero heaps each containing at most n sticks”.

This is my first OEIS submission, so it’s all very pleasing, even if I’m submitting a ‘new’ sequence inspired by a 1901 paper!

### nimsticks: LaTeX package for drawing Nim sticks and games

A while ago on this blog I shared a LaTeX macro I had written for drawing games of Nim. I have now taken the plunge and written this into a LaTeX package called nimsticks. (Why? What do you do to relax on a lazy Sunday morning?)

Here is the description of the nimsticks package:

This LaTeX package provides commands \drawnimstick to draw a single nim stick and \nimgame which represents games of multi-pile Nim. Nim sticks are drawn with a little random wobble so they look ‘thrown together’ and not too regular.

What this does it allows commands such as \nimgame{5,3,4} which renders like this:

### Mathematical Objects: Pile of matchsticks

A conversation about mathematics inspired by a pile of matchsticks. Presented by Katie Steckles and Peter Rowlett.

### LaTeX for typesetting a multi-pile Nim game

Update July 2020: I have now taken the plunge and written this into a LaTeX package called nimsticks. The version in the package is an improved version of the macro given below in a couple of ways – it works with LuaTeX and XeTeX, and it has both block-centred and inline modes. I describe this in a new blog post nimsticks: LaTeX package for drawing Nim sticks and games.

I am preparing to teach our new final year module ‘Game Theory and Recreational Mathematics’. So I’m thinking about game typesetting in LaTeX (texlive-games is useful in this regard). I was looking for an easy way to display multi-pile Nim games. Usually, I find searching “latex thing” finds numerous options for typesetting “thing” in LaTeX, but here I was struggling.

Nim objects could be anything, of course, but conventionally sticks or stones are used. There are various types of dot in LaTeX that might look like stones, but somehow a line of dots didn’t seem satisfactory. There are various ways to draw a line (not least simply typing ‘|’), including some tally markers (e.g. in hhcount). My problem with these (call me picky) is that they are all identical lines, and a ‘heap’ of them just looks very organised. Really, I want a set of lines that looks like someone just threw them into heaps (though probably without crossings for the avoidance of ambiguity). So I wrote my own.

### All Squared, Number 5: Favourite maths books (part 1)

Good maths books are simultaneously plentiful and rare. While there are a few classics almost everyone knows about and has copies of (Gardner, Hardy, etc.), the trade in lesser-known maths books is considerably less well-organised. Very few bookshops have well-stocked maths sections, and insipid pop maths books dominate. Unless you hear about a good maths book through word of mouth, you’ll often only encounter it once it’s ended up in a second-hand bookshop, usually a refugee from an emptied maths department library.

But books, more than anything else, are where the beauty of maths really manifests itself. It’s where ideas are presented most clearly, after they’ve had time to percolate through a few more brains. We talked to David Singmaster, professor of maths and metagrobologist, about his favourite maths books.