#### Wythoff's Nim

Wythoff's Nim is a small board game for two players. The idea is rather simple; thus, it is called a "nim". The goal of each player is to be the first to reach the coordinates (0, 0). Once there, the opponent naturally loses because there are no other possible moves. The rules governing the movement of the pieces are as follows: A player may either move a single piece any distance or both pieces the same distance. This Java applet is actually my first shot at AI. You don't get to play against another person but against the computer. This may seem tricky at first (unless, of course, you are given a really easy starting position), but once you master the mathematics involved in this game, you'll realize it's really easy to win most of the time.

Define the sequences *a _{n}* and

*b*as follows:

_{n}*a*_{0}= 0,*b*_{0}= 0- For each
*n*> 0,- let
*a*= the smallest positive integer number not in {_{n}*a*_{0},*b*_{0},*a*_{1},*b*_{1},*a*_{2},*b*_{2},*a*_{3},*b*_{3},...,*a*_{n}_{-1},*b*_{n}_{-1}}, and - let
*b*=_{n}*a*+_{n}*n*.

- let

All ordered pairs (

*a*,

_{n}*b*) are losing positions.

_{n}

*Screen shot of Wythoff's Nim.*