The rules are simple. Two people take things from a single pile. There is a minimum amount you must take, a maximum amount you can take, the winner and loser is determined by the last piece. There are a multitude of variations on this game, but the solution is surprisingly similar for all of them.
Just like Nim this is a solved game, if both players know what they’re doing the end of the game is determined from the first move. Unlike Nim the solution is simple enough for you to figure out in your head so there’s no need for a trainer. Play the computer on the hardest setting and see if you can’t devise the strategy yourself. Then play it on an easier setting and see if you can’t catch when it makes a mistake and turn things to your advantage.
Pick Up is written by Joe Larson inspired by 23 Matches by Bob Albrecht and Batnum by John Kemeny both found in ‘BASIC Computer Games’ edited by David H Ahl (c) 1978.

Download and Play
Download the source code
February 11th, 2010 - 9:16 pm
Lol…
Computer takes -2 and leaves 12
I think there’s a wee bug ;)
February 11th, 2010 - 10:18 pm
What? I’ve never seen that. That shouldn’t even be possible.
Well, I guess the challenge is now “Figure out how to fix it and send me the patched code.”
February 14th, 2010 - 5:02 pm
I think I found the bug…
gcc ./pickup.c
./pickup.c: In function ‘compmove’:
./pickup.c:90: warning: integer overflow in expression
./pickup.c:91: warning: integer overflow in expression
Unfortunately, I don’t know any C. If I can manage to fix it, I’ll email you.
February 15th, 2010 - 9:54 am
The problem is actually in line 14 up at the top:
#define RANDOM(x) ((int) rand() / ((float)(RAND_MAX + 1) / x))
Change it to this:
#define RANDOM(x) ((int) rand() % x)
See if that don’t solve it.
February 16th, 2010 - 4:33 pm
It did solve it, thanks. Compiled for linux, if you want it.