Professional Documents
Culture Documents
Pingpong Bot
Pingpong Bot
A Report Submitted to
Jawaharlal Nehru Technological University Kakinada, Kakinada
in partial fulfillment for the award of the degree of
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING
Submitted by
THOTA HANISH MANIKANTA
(20KN1A05G9)
2020-2021
NRI INSTITUTE OF TECHNOLOGY
(An Autonomous Institution, Approved by AICTE, Permanently Affiliated to JNTUK, Kakinada)
Accredited by NBA (CSE, ECE & EEE), Accredited by NAAC with ‘A’ Grade
ISO 9001: 2015 Certified Institution
Pothavarappadu (V), (Via) Nunna, Agiripalli (M), Krishna Dist., PIN: 521212, A.P, India.
CERTIFICATE
This is to certify that the “Internship report” submitted by THOTA HANISH MANIKANTA (Regd.
No.: 20KN1A05G9) is work done by his/her and submitted during YEARS academic year, in partial
fulfillment of the requirements for the award of the degree of BACHELOR OF TECHNOLOGY in
COMPUTER SCIENCE AND ENGINEERING, at BLACKBUCK ENGINEERS PVT LTD,
Road No:36, Jubilee Hills, Hyderabad, Telangana.
EXTERNAL EXAMINER
Internship Experience Letter
Best regards,
I take this opportunity to thank all who have rendered their full support to my work.
The pleasure, the achievement, the glory, the satisfaction, the reward, the appreciation and the
construction of my project cannot be expressed with a few words for their valuable suggestions.
I am thankful to the Principal, Dr. C. NAGA BHASKAR garu for his encouragement to
complete the Project work.
I am extending my sincere and honest thanks to the Chairman, Dr. R. VENKATA RAO
garu & Secretary, Sri K. Sridhar garu for their continuous support in completing the Project
work.
20KN1A05G9
ABSTRACT
INTRODUCTION:
Being one of the earliest computer games, the Pong game is well-known for its
simplicity, which makes it suitable for becoming one of the very first problems in
Artificial Intelligence and Machine Learning. The goal is to create a self-playing
agent that can compete against humans. In the past there have been introduced
various Machine Learning approaches to solve this problem.
In this project, we are going to create a Pong Game using Python Turtle. Pong is a
well-known computer game that is similar to table tennis. The two players in this
game control the two paddles on either side of the game window. To hit the moving
ball, they move the paddles up and down. A player’s score rises when he or she hits
the ball or when the opponent misses the hit.
Libraries and Technologies used:
• turtle
• python
Project Flow:
Finally task of building the game of Pong from scratch is done. We successfully
developed the Pong Game using Python Turtle We learned how to make forms for
blocks and balls, as well as how to modify the pace and refresh the screen. Using just
those 2 parameters, it learns what moves it needs to make to become better.
Methodologies:
We follow a structured methodology for our projects which starts from designing
the solution to the implementation phase. Well planned Project reduces the time to
deliver the project and any additional ad-hoc costs to our clients, hence we dedicate
majority of our time understanding our clients business and gather requirements.
This ground up approach helps us deliver not only the solution to our clients but also
add value to your investments.
a. Modules ............................................................................................................3
2. Analysis…………………………………………………………………………….4-6
4. Technology………………………………………………………………………….9-12
a. PYTHON……………………………………………………………………….10
b. Turtle…………………………………………………………………………11-12
5. Architecture……………………………………………………………………….13-14
6. Coding……………………………………………………………………………….15-19
7. Screenshots………………………………………………………………………….20-21
8. Conclusion……………………………………………………………………….…22-23
9. Bibliography………………………………………………………………………..24-25
Learning Objectives/Internship Objectives
An objective for this position should emphasize the skills you already possess
in the area and your interest in learning more
Utilizing internships is a great way to build your resume and develop skills
that can be emphasized in your resume for future jobs. When you are applying
for a Training Internship, make sure to highlight any special skills or talents
that can make you stand apart from the rest of the applicants so that you have
an improved chance of landing the position.
WEEKLY OVERVIEW OF INTERNSHIP ACTIVITIES
INTRODUCTION
1
INTRODUCTION
Ping pong:
Pong is one of the famous computer games that resembles table tennis. In this game,
the two players control the two paddles on either side of the game window.
They move the paddles up or down to hit the moving ball. The score of a player
increases either when he/she hits the ball or when the opponent misses the hit.
The rules of this game are simple:
There are two players.
Both have control over the paddle of their side.
They can move the paddle on vertical sides from up to down and down to up.
Players can strike back and forth on the ball by using the paddle.
2
1.1Module Description:
The first step is to import the turtle module. We will use this module to build the
whole game.
Turtle: The turtle is a built-in module in Python which is used for graphical
illustrations. The users can use it as a pen and panel to illustrate the graphics.
The following are the steps used for illustrating Ping Pong game:
o Step 1: The user has to create two Paddles for the "Left Side" and "Right Side"
of the screen.
o Step 2: The user then has to create the ball.
o Step 3: Then, create an event for moving the paddles vertically by pressing the
particular keys, that is, for "Left Paddle": "R" for "Up" and "C" for "Down", for
"Right Paddle": "Up key ()" for "Up" and "Down key ()" for "Down".
o Step 4: At last, create the function for updating the score after each player misses
the strike on the ball.
3
CHAPTER -2
SYSTEM ANALYSIS
4
SYSTEM ANALYSIS
REQUIREMENT ANALYSIS:
Existing System:
PING PONG Table tennis, also known as ping-pong is a sport in which two
players hit a lightweight ball, also known as the ping-pong ball, back and forth
across a table using small rackets. The game takes place on a hard table divided by a
net . The game of Pong is an excellent example of a simple RL task. In the ATARI
2600 version we’ll use you play as one of the paddles (the other is controlled by a
decent AI) and you have to bounce the ball past the other player. On the low level
the game works as follows: we receive an image frame (a 210x160x3 byte array
(integers from 0 to 255 giving pixel values)) and we get to decide if we want to
move the paddle UP or DOWN (i.e. a binary choice). In the code, after illustrating
the outlook of the screen with paddles and ball, we will first initialize the score of
both the players, that is, Zero. Then, we will display the score on the screen, which
will increase with the opposite player missing the strike. We will then implement
the functions for moving the paddle vertically. We will bind the keys for each
function, that is, for "Left Paddle": "R" for "Up" and "C" for "Down", for "Right
Paddle": "Up key" for "Up" and "Down key" for "Down". Then, we will initiate
how the ball and striking of the paddle will work, as if the ball hit the paddle, it will
go for the opposite player, but if the paddle missed the ball, then the ball will hit the
border, and the opposite player will get the score. If the code is correct and no error
is found, the screen of Ping Pong Game will pop up after running the code, and the
players can play. The ball will first go for the right player.
5
Proposed System:
we can also use HTML and JavaScript to implement Ping Pong Bot
game. Here we have a canvas to render the game and two paragraph tags to display
the scores. The block with class small-device is to disable the game and display the
message on small screens because there won’t be keyboard controls.
The CSS file style.css and JavaScript file script.js are linked to this HTML file.
Now we have to add some styles to our page to make it look nice. The look and feel
of a page are also an important part. Game logic is implemented by using JavaScript
6
CHAPTER -3
7
SOFTWARE REQUIREMENTS SPECIFICATIONS
System configurations
The software requirement specification can produce at the culmination of the
analysis task. The function and performance allocated to software as part of system
engineering are refined by established a complete information description, a detailed
functional description, a representation of system behavior, and indication of
performance and design constrain, appropriate validate criteria, and other
information pertinent to requirements.
Software Requirements:
Hardware Requirement:
8
CHAPTER-4
TECHNOLOGY
9
TECHNOLOGY
PYTHON:
10
TURTLE:
The turtle is a built-in module in Python which is used for graphical illustrations.
The users can use it as a pen and panel to illustrate the graphics.
Color
color() name Changes the color of the turtle’s pen
11
Method Parameter Description
12
CHAPTER-5
ARCHITECTURE
13
Architecture Of Ping pong bot using Turtle
14
CHAPTER-6
CODING
15
CODING
import os
import turtle
# Left paddle
left_paddle = turtle.Turtle()
left_paddle.speed(0)
left_paddle.shape("square")
left_paddle.color("Red")
left_paddle.shapesize(stretch_wid = 6, stretch_len = 2)
left_paddle.penup()
left_paddle.goto(-400, 0)
# Right paddle
right_paddle = turtle.Turtle()
right_paddle.speed(0)
right_paddle.shape("square")
right_paddle.color("Blue")
right_paddle.shapesize(stretch_wid = 6, stretch_len = 2)
right_paddle.penup()
right_paddle.goto(400, 0)
16
hit_ball.dx = 5
hit_ball.dy = -5
def paddle_L_down():
y = left_paddle.ycor()
y -= 20
left_paddle.sety(y)
def paddle_R_up():
y = right_paddle.ycor()
y += 20
right_paddle.sety(y)
def paddle_R_down():
y = right_paddle.ycor()
y -= 20
right_paddle.sety(y)
17
# Then, binding the keys for moving the paddles up and down.
screen_1.listen()
screen_1.onkeypress(paddle_L_up, "Left")
screen_1.onkeypress(paddle_L_down, "Right")
screen_1.onkeypress(paddle_R_up, "Up")
screen_1.onkeypress(paddle_R_down, "Down")
while True:
screen_1.update()
hit_ball.setx(hit_ball.xcor() + hit_ball.dx)
hit_ball.sety(hit_ball.ycor() + hit_ball.dy)
18
# Collision of ball and paddles
if (hit_ball.xcor() > 360 and
hit_ball.xcor() < 370) and (hit_ball.ycor() < right_paddle.ycor() + 40 and
hit_ball.ycor() > right_paddle.ycor() - 40):
hit_ball.setx(360)
hit_ball.dx *= -1
19
CHAPTER-7
SCREENSHOTS
20
SCREENSHOTS
21
CHAPTER-8
CONCLUSION
22
CONCLUSION
With this Python project, we have successfully built the Pong game. For
this, we used the turtle module. We learned how to create shapes for blocks, balls,
change the speed and update the screen.
we have created a simple illustration of a ping pong game on the screen by using the
built-in library of Python, that is, Turtle. The user can create different moving
illustrations by using the turtle library and its different functions.
By the end of this project, we have created The Classic Ping Pong game
using Python and Turtle graphics. we also be able to identify and use most of
Turtle’s modules and functions that helps you develop and build your own game.
Moreover, we are able to edit and manipulate the objects created by Turtle however
we like.
23
CHAPTER-9
BIBLIOGRAPHY
24
BIBLIOGRAPHY
25