Saturday, 28 March 2015

Dots and Boxes game with python and pygame!

Yes! it is Dots and Boxes this time and its really working and that too without those complex algorithms that you get to see when you search the web.

My Algorithm:

1. Let the user play first.
2. When the computer gets its turn, it first searches for boxes that can be completed in one move.
3. It completes one of such boxes if found else it finds out the 'two-sided' boxes (those which have two sides marked) and stores in a list.
4. Now the list stores the boxes which will lead the computer to lose one precious point to the user.
5. The computer dares not even to touch the boxes and finds the lines which are safe to mark.
6. If the computer finds no safe lines then it finds out the chains of boxes which the user can form if the computer takes its turn.
7. Then it finds out the smallest chain and marks one line in it to minimise the loss.
8. This way, the computer has a good chance of winning and this is an enjoyable game.

HIT +1 IF YOU LIKE THE IDEA

Give it a try: Download




No comments:

Post a Comment