You are on page 1of 24

PROJECT REPORT

on
CARDS GAME
INDUSTRIAL TRAINING PROJECT REPORT

Submitted in partial fulfillment of the requirements for the award of the degree

of

BACHELOR OF TECHNOLOGY
in
INFORMATION TECHNOLOGY

by

PRATHAM KAKKAR
Enrollment No: 09115603120

to
MS. NEETU SWAROOP

DEPARTMENT OF INFORMATION TECHNOLGY


DR.AKHILESH DASS GUPTA INSTITUTE OF TECH & MGMT
(AFFILIATED TO GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY, DELHI)
NEW DELHI – 110053
CERTIFICATE OF TRAINING
ABSTRACT

In this CARD GAME, each player draws a card from the deck and
the player with the highest card wins. I’m going to build this card
game by defining classes representing a card, a deck, a player and
finally the game itself.

Description of functions:

 pc() function will decide the next move of the system.


 winner() function will check whether the player won the match or
not.
 isfull() function will check the deck is full or not.
ACKNOWLEDGEMENT

The completion of any project depends on the cooperation, coordination


and combined efforts of served sources of material, time knowledge and
energy. Hence this opportunity is taken to thank and acknowledge all the
people who directly or indirectly helped me in the completion of the
project.

I owe a debt of gratitude to Mr. Ashish Sukralia (Co-Founder &


CTO) CODING NINJAS or his willingness to adopt me as his project
student and for the unwavering support he provided throughout the
summer project by encouraging us.

I would also like to thank Ms. Neetu Swaroop, for giving me the opportunity
to work on this project.
TABLE OF CONTENTS

ABSTRACT Iii
ACKNOWLEDGEMENT Iv
TABLE OF CONTENTS V
LIST OF FIGURES Vii

Chapter 1: Introduction ix-x

1.1. What is python?


1.2. History
1.3. PyCharm

Chapter 2 : Project xi-xiii

2.1. What is the card game ?


2.2. Objective
2.3. Gameplay
2.4. Strategy
Chapter 3 : Methodology Used xiv-xvii

3.1. Steps
3.2. Libraries Used

Chapter 4: Result Analysis xviii-xxv

4.1 Snapshots of Project

Chapter 5 : Conclusions and Future Scope xxvi

5.1 Conclusions
5.2 Future Scope
LIST OF FIGURES

1. Certificate
2. Card Game
3. Methodology
4. Snapshots of project
CHAPTER 1: INTRODUCTION
1. Introduction

Playing Cards are very popular in gaming, so let’s implement an


automatic card game using Python.

1.1. What is python?

Python is an interpreted high-level general-purpose
programming language. Its design philosophy emphasizes code
readability with its use of significant indentation.
Its language constructs as well as its object-oriented approach
aim to help programmers write clear, logical code for small and
large-scale projects. Python is dynamically-typed and garbage-
collected.

It supports multiple programming paradigms,


including structured (particularly, procedural), object-oriented
and functional programming. It is often described as a "batteries
included" language due to its comprehensive standard library.

Guido van Rossum began working on Python in the late 1980s,


as a successor to the ABC programming language, and first
released it in 1991 as Python 0.9.0. Python 2.0 was released in
2000 and introduced new features, such as list
comprehensions and a cycle-detecting garbage collection system
(in addition to reference counting).
Python 3.0 was released in 2008 and was a major revision of the
language that is not completely backward-compatible. Python 2
was discontinued with version 2.7.18 in 2020. Python consistently ranks
as one of the most popular programming languages.

1.2. History :-

Python was conceived in the late 1980s by Guido van


Rossum at Centrum Wiskunde & Informatica (CWI) in
the Netherlands as a successor to the ABC programming
language, which was inspired by SETL, capable of exception
handling and interfacing with the Amoeba operating system.

 Its implementation began in December 1989. Van Rossum


shouldered sole responsibility for the project, as the lead
developer, until 12 July 2018, when he announced his "permanent
vacation" from his responsibilities as Python's "benevolent
dictator for life", a title the Python community bestowed upon him
to reflect his long-term commitment as the project's chief
decision-maker. In January 2019, active Python core developers
elected a five-member "Steering Council" to lead the project.
1.3. What is PyCharm?

PyCharm is an integrated development environment (IDE) used


in computer programming, specifically for the Python language. It
is developed by the Czech company JetBrains (formerly known as
IntelliJ). It provides code analysis, a graphical debugger, an
integrated unit tester, integration with version control
systems (VCSes), and supports web development with Django as
well as data science with Anaconda.
PyCharm is cross-platform,
with Windows, macOS and Linux versions. The Community
Edition is released under the Apache License, and there is also
Professional Edition with extra features – released under
a proprietary license.
CHAPTER 2: PROJECT

2.1. What is the card game?

This card game is made with Python. In this card game, each
player draws a card from the deck and the player with the highest
card wins. I’m going to build this card game by defining classes
representing a card, a deck, a player and finally the game itself.

2.2 Objective

This card game is created using the concept of playing cards. the
computer designates player one and player two and the computer
asked them to enter a random value and then the computer
chooses two cards and tells the player who has the bigger card
sequence. The person who has bigger card sequence wins the
round. The computer then analyses the winner of each round and
tells the winner of the game.

2.3. Gameplay
Just like the concept of a card game where the bigger card sequence
wins the game. In this game also, the computer chooses to random
cards for the players. The player with the bigger card sequence wins.

2.4. Strategy

The strategy in a regular card game is totally luck dependent. If you get
the higher card from the deck which includes suits and numbers of each
card. Suits is a tuple of strings representing all the suits a card can be:
spades, hearts, diamonds, clubs.The cards in each suit are labelled from
2-10 and the jack, the queen, the king and the ace. The ace is of highest
value in the cards. If someone gets an ace of diamonds and the other
player gets a 9 of clubs, the player with the ace of diamonds wins the
game.

CHAPTER 3 : METHODOLOGY USED


3.1. Steps Involved

 Create a interface which asks for the name of player 1 and player
2.
 Creating classes of –

1) Card
2) A deck
3) The player
4) The game itself
 Allow the player to enter a random key from which the computer
chooses the cards for each player.
 Display the message, who won the match.
3.2. Libraries used:

 Tkinter

3.2.1. What is Tkinter?

Python offers multiple options for developing GUI


(Graphical User Interface). Out of all the GUI methods,
tkinter is the most commonly used method. It is a standard
Python interface to the Tk GUI toolkit shipped with Python.
Python with tkinter is the fastest and easiest way to create
the GUI applications. Creating a GUI using tkinter is an
easy task.

3.2.2 What is the process?


The first class in our card game with Python is a Card class, which
has two class variables, suits and values. Suits is a tuple of strings
representing all the suits a card can be: spades, hearts, diamonds,
clubs. value is a tuple of strings representing the different numeric
values a card can be: 2–10, Jack, Queen, King, and Ace.
The elements of the first two indexes of the value tuple are None,
so the strings in the tuple match the index they represent. So the
string “2” in the tuple of values is at index 2.

Card objects have two instance variables: suit and value, each
represented by an integer. Together, the instance variables
represent the card type of the Card object. For example, you create
a 2 of hearts by creating a Card object and passing it the
parameters 2 (for color) and 1.

 THINGS TO REMEMBER :

The code for these magic methods can also handle whether the cards
have the same value, for example, if both cards have a value of 10. If
this happens, the methods use the value of the combinations to break the
tie.

The combinations are ranked in order of strength in the combination


tuple – with the strongest combination last, and thus assigned to the
highest index, and the less powerful combination to the lowest index.

When you initialize the Deck object, the two for loops of __init__ create
Card objects representing all the cards in a 52-card deck and add them to
the card list. The first loop goes from 2 to 15 because the first value of a
card is 2 and the last value of a card is 14 (the ace).

Each time around the inner loop, a new card is created using the integer
from the outer loop as the value (i.e. 14 for an ace) and the integer from
the inner loop as the suit. This process creates 52 cards – one card for
each combination of suit and value.

After the method creates the cards, the shuffle method of the shuffle
module randomly rearranges the items in the card list; imitating the
shuffle of a deck of cards.
Our deck has another method called rm_card which removes and returns
a card from the card list, or returns None if it is empty.

The Player class has three instance variables: wins to keep track of the
number of turns a player has won, card to represent the card a player
currently holds, and name to keep track of a player’s name.

When you create the game object, Python calls the __init__ method and
the input function collects the names of the two players in the game and
stores them in the variables name1 and name2.

Then you create a new Deck object, store it in the instance variable deck,
and create two Player objects using the names in name1 and name2. The
play_game method of the Game class starts the game. There is a loop in
the method that maintains the game as long as there are two or
morecards left in the deck, and as long as the variable response is not
equal to q .

On each loop turn, you assign the variable response to user input. The
game continues until the user types “q” or when there are less than two
cards left in the deck. Two cards are drawn each time in the loop and the
play_game method assigns the first card to p1 and the second card to p2.

Then he prints each player’s name and the card he drew, compares the
two cards to see which card is the bigger one, increments the wins
instance variable for the player with the highest card, and prints a
message indicating who won. The Game class also has a method called
winning which takes two player items, looks at the number of tricks
they’ve won, and returns the player who has won the most tricks.

When the Deck object runs out of cards, the play_game method displays
a message that the war is over, calls the winning method (passing both
p1 and p2), and displays a message with the result – player name who
won.
CHAPTER 4 : RESULT ANALYSIS

4.1 Snapshots of project:


Chapter 5 : Conclusions & Future Scope

5.1 Conclusion:

After so much effort put in, I successfully created a dynamic and responsive
card game.

I would like to extend my gratitude towards:

 CODING NINJAS
 Parikh Sir
 Ankur Sir

Without them, this project and this report would not have been possible.

5.2 Future Scope:

The gaming industry has sparked tremendous interest in recent years. With
several companies investing millions of dollars in developing new and
innovative games, the gaming industry has stepped on a steep growth curve.

It is forecasted that the gaming industry will generate great opportunities for
game developers over the next two years.  The gaming industry has grown
its presence over various platforms – mobile, console, PC, online gaming
and the industry is growing really fast along with the presence on all these
platforms.  Most of the other sectors stick to only one platform and then
move to the another, once they have established their presence on the same. 
However the ‘Gaming Industry’ has a different story to tell.

You might also like