the renju game by abhishek jain, pranshu gupta & rhythm das pclub summer project presentation...

10
THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

Upload: erin-warner

Post on 21-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

THE RENJU GAME

BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS

PCLUB SUMMER PROJECT PRESENTATION 2014

23 JUNE, L7

IIT KANPUR

MENTOR – SANIL JAIN

Page 2: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

WHAT IS RENJU ? RENJU is a strategy board game played by

two people. One of them takes the black stone and the other one white. They place their stones by turns on the board. The player who first makes five stones (of his/her colour) in a line wins the game. The line can be in any direction, horizontal, vertical or any of the two diagonals.

The board has a grid of 15 x 15 on it such that there are 255 intersections. The stones must be placed on one of the EMPTY intersections.

The first move is always played by the player with the black stone and it must be played on the intersection at the centre of the board. After that the white player makes his/her move.

Page 3: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

OUR PROJECT

Our project goal was to make a desktop app which would let the user play THE RENJU GAME in two different modes, one with another human player and the other with the computer, in GUI.

We coded the entire game in PYTHON, using the PYGAME and WXPYTHON libraries.

We used the MINIMAX and ALPHA BETA PRUNING algorithms for designing the AI of our game.

The boards (grids) were designed with ADOBE PHOTOSHOP and the game icon, buttons etc., were entirely designed with MICROSOFT PAINT.

Page 4: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

ABOUT OUR APP

This is our game window, it is coded using the WXPYTHON library.

The four buttons, for the one player game, two player game, changing the theme and the about button are encoded with methods written in PYGAME.

There is also a quit button which you can use to exit this window when you are done with the game. You can also exit the window by clicking the close button on title bar.

The quit button is encoded with WXPYTHON.

Page 5: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

THE TWO PLAYER GAME

When you click the two player game button. You are asked to enter the name of the two players and if you enter both the names and click OK, the game begins.

You click anywhere on the board and the stones are placed at the nearest intersection from the point where you clicked.

As the game continues, the app checks after each step if any of the player has made FIVE IN A LINE. If any such sequence of stones is found the game immediately stops and a message window appears declaring the winner.

As you close this window the app quits the PYGAME method.

The winner’s name appears here.

Page 6: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

THE USER INTERFACE You can also change the theme of the board

by clicking the theme button. Once you choose a theme the game will always open with that theme until you change it again.

The game also notifies you if you make an INVALID MOVE.

If the user does not know about the game, he/she can use the ABOUT button to see help content.

Page 7: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

THE ARTIFICIAL INTELLIGENCE OUR IMPLEMENTATION MINIMAX is a depth first search algorithm. In our

game, after the user makes his/her move, the ATTACK method is called, we have a GETMOVES method within the ATTACK method which looks for all the empty nodes adjacent to the occupied nodes. After that it calls the EVALUATE method which assigns each move a score. This score is assigned on the basis of priority of moves. For example, moves which convert a sequence of four stones into a sequence of five are assigned highest score and so on.

When the scores are assigned, the moves with highest scores are filtered out and returned as a list to the ATTACK method.

Page 8: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

Then, the ATTACK method runs a loop on this list. Each of these moves is played (virtually) and the ATTACK method is called again (recursively). The search is now said to have reached the depth of one from depth zero. Thus, our algorithm works as a RECURSION TREE.

In this call, the computer has already made its move, so the EVALUATE method turns to the HUMAN PLAYER’S POINT OF VIEW. Now the GETMOVES method will search for the available moves and EVALUATE them according to the human player. Then the moves with highest score (in Human player’s point of view) are returned.

Now, these moves are virtually played on the behalf of the human player and then ATTACK method is called again, increasing the depth to TWO.

Thus, we have tried to implement the concept of PERFECT PLAY from both players. The ATTACK method searches up to the DEPTH OF FOUR.

When the last branch of the fourth depth is visited then the corresponding move and score are stored and compared with previous move’s score. The move with greater score is replaced with the previously stored move. The depth now starts rolling back and the move which is stored at depth zero is assigned to a variable named BESTMOVE.

The BESTMOVE is then appended to the CPU player, and the human player makes his/her next move and the game continues.

Page 9: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

ALPHA BETA PRUNING Alpha–beta pruning is a search algorithm that seeks to decrease

the number of nodes that are evaluated by the minimax algorithm in its search tree. It stops completely evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move. Such moves need not be evaluated further. When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.

We have also applied ALPHA BETA PRUNING in our MINIMAX algorithm.

Page 10: THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION 2014 23 JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN

THANK YOU ! With special thanks to SANIL JAIN and PANKAJ PRATIK …………….!

PRESENTED BY PRANSHU GUPTA, RHYTHM DAS & ABHISHEK JAIN FOR PCLUB SUMMER CAMP 2014