Subscribe via RSS Become a friend on Facebook Follow me on Twitter

Cymons Games

PickUp

January 29th, 2010

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.

LIttlest boy is not napping

5 Responses to “PickUp”

  1. sh228

    Lol…

    Computer takes -2 and leaves 12

    I think there’s a wee bug ;)


  2. Joe

    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.”


  3. sh228

    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.


  4. Joe

    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.


  5. sh228

    It did solve it, thanks. Compiled for linux, if you want it.


Leave a Reply

Cymons Games. All programs provided without guarantee or warranty. Maintained by Joseph Larson.
If you have any questions or notice something is wrong please contact me. Powered by WordPress.