Comp games

I like to write code for games/puzzles. Well, really I like solving puzzles using computer code. The first attempt turns out to be brute force though I do not like it to be that way.

Here I present the code for games that you can play and enjoy. At some point I will make them interactive so that you can play them right here using your browser. For now you have to download them and run them using perl e.g. save one as game_one and run it as
PROMPT> perl game_one
I will also put in better comments asap.

Nim is a two-person-zero-sum game i.e. it is played between two people and one of them ends up winning. You start with n piles containing different number of things. You take turns picking up any number of items from any one pile on your turn. The aim is to be the one who picks up the very last one. This game has a strategy which is not too difficult to find out and then you may not lose to the computer.

Mastermind has you guess a code that the computer sets up. A 4 letter code made from 6 possible alphabets. When you guess, a correct letter in the correct location earns you a black (B) while a correct letter in a wrong place gets you a white (W). The game is over when you get 4 blacks. Normally 4-5 guesses suffice. You get 10 chances.

Tiles is a game I first saw on cricinfo and was fascinated. You go on removing tiles in a 8x8 matrix which have identical neighbours. You get more marks if you remove more tiles at one go. The marks increase as the Fibonacci series so that its best for you to collect as many together as possible first. 2,3 tiles get you (n-1), 4 onward you get f(n-1)+f(n-2). Once you clear the board, you get bonus marks (5000 + your best clearing during the round) and you get a new set with one additional type of tile. I have reached a max score of 200K+ so far and I am sure there should be ways of doing better.

The pentomino challenge

The game of gess

All the best and let me know how you like the stuff.

Science Fun Philosophy Personal Miscellaneous

Ashish Mahabal
Last Outdated: Oct 18 2001