0% found this document useful (0 votes)
9 views31 pages

PWD Complete

The document is a project report on 'The Ludo Game' submitted by students of Government Polytechnic Hingoli, guided by Prof. P. P. Deshpande. It outlines the project's objectives, methodology, and the development process of the game using Python, while also discussing the advantages and disadvantages of playing Ludo. The report emphasizes the importance of resource management and sustainability in the context of the game.

Uploaded by

Niyati Khandare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views31 pages

PWD Complete

The document is a project report on 'The Ludo Game' submitted by students of Government Polytechnic Hingoli, guided by Prof. P. P. Deshpande. It outlines the project's objectives, methodology, and the development process of the game using Python, while also discussing the advantages and disadvantages of playing Ludo. The report emphasizes the importance of resource management and sustainability in the context of the game.

Uploaded by

Niyati Khandare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

A Project Report on

“The Ludo Game”

Submitted By:
1.Anushka Umesh Bhaat 3314
2.Niyati Gulab Khandare 3328
3.Rashmi Dayanand Pandey 3343
4. Gauri Laxmikant Purohit 3349

Guided By:
Prof. P. P. Deshpande

Submitted To:
DEPARTMENT OF COMPUTER ENGINEERING
GOVERNMENT POLYTECHNIC HINGOLI
Maharashtra State Board of Technical Education, Mumbai

CERTIFICATE
This is to certify that, Miss. 1.Anushka Umesh Bhaat 2.Niyati Gulab Khandare ,
3.Rashmi Dayanand Pandey, 4.Gauri Laxmikant Purohit Roll No. 3314, 3328,
3343, 3349 of Sixth Semester of Diploma in Computer Engineering of
Government Polytechnic Hingoli has completed the Micro Project satisfactorily in
course Management (22509) for the academic year 2024-25 as prescribed in the
curriculum.

Place : Hingoli Enrollment No: 2211630147, 2211630166,


2211630183, 2211630190

Date : / /2025

Course Coordinator HOD Principal

Prof.P.P.Deshpande Prof. N. S Jadhao Prof. B.P. Deosarker


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI
MICRO PROJECT

Progress Report / Weekly Report


Name of the Project: The Ludo Game Course: Management
(22509) Program: Computer Engineering (CO6I) Roll No. 3314, 3328,
3343, 3349

Sign of the
Week Date Duration Work / Activity Performed Faculty
No in
Hrs.
1 10/01/25
1/2 INTRODUCTION OF PYTHON
2 10/01/25 1/4 Features Of Python
3 15/01/25 1 Advantages Of Python

4 17/01/25 1/2 Disadvantages Of Python

5 22/01/25 1 Import The Required Modules


6 24/01/25 2 Creating a class each for the tokens and the grids
class grid
7 29/01/25 1/2 Creating global variables
8 07/02/25 4 Creating all the token and grid objects
9 12/02/25 2 Writing function to draw grid
10 21/02/25 2 Writing functions to move the tokens
11 24/02/25 Writing functions to check id, current player and
2 collision of two players
12 28/02/25 1 Function to Move the Computer Token Automatically

13 04/03/25 1/4 Writing the Function to get the Next Player


14 04/03/25 1 Writing and Code Of The Main Game

15 07/03/25 1/2 Conclusion

16 - Submitting Report To The Teacher


Teacher’s Evaluation Sheet for Micro Project
Course Title and Code: - : Management (22509)
Title of the Project: The Ludo Game
Group No: -

COs addressed by the Micro Project:

Use basic management principles to execute daily activities.


CO a:
Use principles of planning and organising for accomplishment of tasks.
CO b:
Use principles of directing and controlling for implementing the plans.
CO c:
Apply principles of safety management in all activities.
CO d:
Understand various provisions of industrial acts.
CO e:

Marks:-

Marks obtained
Marks for by the Total
Roll No. Name Of Student Group Work individual Marks
(06) based on viva (10)
(04)
3314 Anushka Umesh Bhaat
3328 Niyati Gulab Khandare
3343 Rashmi Dayanand Pandey
3349 Gauri Laxmikant Purohit

Name and designation of Faculty : Prof.P.P.Deshpande


Lecturer,Computer Engg.Dept.

Signature:
Action plan: -

Name of the
Planned Planned responsible
Details of activity finish date Team
start date
Member
Sr. No.
1 10/01/25 15/01/25 Niyati G.
INTRODUCTION OF PYTHON Khandare
Features Of Python 10/01/25 17/01/25 Rashmi D.
2 Pandey
Advantages Of Python 15/01/25 22/01/25 Gauri L. Purohit
3
Disadvantages Of Python 17/01/25 24/01/25 Anushka U.
4 Bhaat
22/01/25 29/01/25 Niyati G.
5 Import The Required Modules Khandare
Creating a class each for the tokens 24/01/25 07/02/25 Rashmi D.
6 and the grids class grid Pandey

29/01/25 12/02/25 Gauri L. Purohit


Creating global variables
7
Creating all the token and grid 07/02/25 21/02/25 Anushka U.
8 objects Bhaat
Writing function to draw grid 12/02/25 24/02/25 Niyati G.
9 Khandare
10 Writing functions to move the tokens 21/02/25 28/02/25 Rashmi D.
Pandey
Writing functions to check id, current 24/02/25 04/03/25 Gauri L. Purohit
11 player and collision of two players
Function to Move the Computer Token 28/02/25 04/03/25 Anushka U.
12 Automatically Bhaat
Writing the Function to get the Next 04/03/25 07/03/25 Niyati G.
13 Player Khandare
14 Writing and Code Of The Main Game 04/03/25 07/03/25 Rashmi D.
Pandey
07/03/25 07/03/25 Gauri L. Purohit
Conclusion
15
All members

Submitting Report to the teacher


16
Resources Required: -

Name of the Resources Specification Quantity Remark


SR.
No.
1 Opreating System Windows 7/ windows 1 -
10/linux or any other

Hardware personal i3-i5 preferable - -


2 computer

Actual Procedure Followed: -


1. Collecting Information
2. Collecting Images
3. Searching About project
4. Collecting Information regarding Its Architecture
5. Preparing the Project Report Format
6. Adding the collected information in the report
7. Adding the images in the report
8. Reformatting the Report
9. Preparing the indexes of the report
10. Making Final Changes in the Report
11. Reviewing the report again and eliminating the mistakes
12. Finalizing the Micro-Project
13. Submitting Report to the teacher
ACKNOWLEDGEMENT

It is my great pleasure to acknowledge my research guide Prof. P. P. Deshpande lecturer


in Government Polytechnic, Hingoli, Her valuable guidance, constant inspiration, unending
support helped me a lot of focus my views in proper perspective.

I would like to express my sincere gratitude to Prof. N.S. Jadhao for their valuable
guidance, support, and encouragement throughout this project. Their expertise, insight, and
advice have been instrumental in helping me to overcome challenges and achieve success. I
am truly grateful for their leadership and mentorship, which have been essential to my growth
and development asa professional. Thank you for your unwavering commitment to excellence
and for being an inspiration to us all.

Our sincere and whole hearted thanks Prof. B. P. Deosarkar, principal Government
Polytechnic, Hingoli for inspiring us to achieve highest goal. Last but not least I am also
thankful to my parents and friends who helped me a lot in finalizing the project within limited
time frame. Thank you.

Name of the student :


1.Anushka Umesh Bhaat 3314
2.Niyati Gulab Khandare 3328
3.Rashmi Dayanand Pandey 3343
4.Gauri Laxmikant Purohit 3349
ABSTRACT

The effective management of resources is a fundamental aspect of achieving sustainability,


economic growth, and operational efficiency in any system, whether it be an organization,
industry, or community. This micro project titled “The Ludo Game” aims to explore the
systematic process of planning, allocating, utilizing, and conserving various types of
resources, including natural, human, financial, and technological assets.

The project begins by defining the concept of resources and categorizing them into renewable
and non-renewable types. It emphasizes the significance of The Ludo Game in the face of
global challenges such as climate change, overpopulation, and resource depletion. The study
focuses on key aspects such as resource planning, demand forecasting, cost control,
environmental impact, and sustainability practices.

A detailed analysis is carried out on methods and tools used in The Ludo Game, such as
inventory systems, project management software, and environmental management systems.
Real-life case studies and data are reviewed to illustrate the consequences of poor The Ludo
Game and the benefits of efficient practices. Strategies like the 5R concept (Reduce, Reuse,
Recycle, Recover, and Refuse), resource optimization, and renewable energy adoption are
also discussed.

The objectives of the project include understanding the principles of The Ludo Game,
evaluating current practices, identifying areas of improvement, and proposing innovative and
practical solutions that can be implemented at local and organizational levels.

In conclusion, this micro project underlines the urgent need for responsible and strategic The
Ludo Game. It encourages the adoption of sustainable practices to ensure that resources are
available for future generations while meeting present needs effectively and efficiently.
1. Introduction:
Ludo Game is a board game for two to four-player in which the players try to move their four
tokens from start to end by rolling a die at their turns. The turns are taken circularly by each
player.
In each turn, he/she throws a die and moves a token by the number appearing, aiming to reach
the end and trying to prevent the other player(s) from winning.

Ludo is a classic board game that originated from an ancient Indian game called Pachisi. It is a
strategy-based game played by 2 to 4 players, each controlling four tokens of a distinct color:
red, blue, green, or yellow.

The objective is to move all four tokens from the starting area to the home column by rolling a
die and following a predefined path on the board. Players must roll a six to bring a token into
play and can capture opponent tokens by landing on the same square, sending them back to
their starting area.

Ludo is known for its mix of luck and strategy, making it fun and unpredictable. It's popular
among people of all ages and has many modern digital versions available for mobile and online
play.

2. Features of the Ludo game:


 Multiplayer Gameplay: Usually supports 2 to 4 players, either offline or online.
 Color-coded Tokens: Each player gets 4 tokens in a specific color (red, green, blue,
yellow).
 Dice-based Movement: Players roll a die to determine how many steps a token can move.
 Start and Home Zones: Tokens must travel from their starting area to the center "home"
area to win.
 Safe and Attack Zones: Certain spots are “safe” from being attacked, while others allow
players to capture opponent tokens.
 Turn-based Play: Players take turns in a clockwise order, requiring patience and planning.
3. Advantages of playing Ludo:

 Enhances Strategic Thinking: Players need to plan their moves, decide when to attack
or defend, and think ahead—boosting their decision-making and planning skills.
 Improves Patience and Focus: Since the game involves waiting for your turn and
carefully watching others' moves, it develops patience and concentration.
 Promotes Social Interaction: It's a multiplayer game that encourages communication,
bonding, and healthy competition among friends and family.
 Teaches Sportsmanship: Win or lose, players learn how to handle both outcomes with
grace, encouraging fair play and emotional balance.
 Boosts Counting and Math Skills: Especially for kids, moving tokens by counting dice
rolls helps reinforce basic arithmetic.
 Relieves Stress: Playing Ludo can be a fun way to unwind and reduce stress levels by
engaging in a light, entertaining activity.

4. Disadvantages of playing Ludo:


 Can Lead to Frustration: Losing repeatedly or getting sent back to start can frustrate
players, especially younger ones.
 Addictive Potential: Online versions of Ludo can become addictive, leading to
excessive screen time and neglect of responsibilities.
 May Cause Conflicts: Competitive gameplay can sometimes lead to arguments or hurt
feelings, especially among children or overly competitive players.
 Wastes Time if Overplayed: Spending too much time playing Ludo, especially without
moderation, can take away from more productive activities.
 Limited Physical Activity: Since it’s a board or digital game, it doesn't encourage
physical movement, which can be a downside in terms of health.
 Repetitive Gameplay: The mechanics are simple and can become boring or
monotonous over time for some players.
5. Import the required modules

1. import pygame
2. import random
3. from pygame.locals import *
4. import sys
5. from pygame import font
6. import time

Code explanation:

a. Pygame module helps in building in window and controls for the ludo game

b. Random is used to get a number on rolling the dice

c. Pygame.locals imports all the constants in Pygame

6. Creating a class each for the tokens and the grids

class gridObj:
def _init_(self, bgColor, playerList, safe, coordinate):
self.bgColor = bgColor
self.playerList = playerList
self.safe = safe
self.coordinate = coordinate
class Token:
def _init_(self, Id, color, state, coordinate,size):
self.Id = Id
self.color = color
self.state = state
self.coordinate = coordinate
self.size=size
self.original_coordinate = coordinate
Code explanation:

a. The gridObj() class is for each grid on the window that decides the color at that particular
coordinate on the window.

7. Creating global variables

cList = [(1, 6), (2, 6), (3, 6), (4, 6), (5, 6), (6, 5), (6, 4), (6, 3), (6, 2), (6, 1), (6, 0), (7, 0),
(8, 0), (8, 1),
(8, 2), (8, 3), (8, 4), (8, 5), (9, 6), (10, 6), (11, 6), (12, 6), (13, 6), (14, 6), (14, 7),(14, 8),
(13, 8),
(12, 8), (11, 8), (10, 8), (9, 8), (8, 9), (8, 10), (8, 11), (8, 12), (8, 13), (8, 14), (7, 14),(6,
14), (6, 13),
(6, 12), (6, 11), (6, 10), (6, 9), (5, 8), (4, 8), (3, 8), (2, 8), (1, 8), (0, 8), (0, 7),(0, 6)]
#RGBY
initPos=[[[1,1],[1,4],[4,1],[4,4]],[[10,1],[13,1],[10,4],[13,4]],[[1,10],[4,10],[1,13],[4,13]],
[[10,10],[10,13],[13,10],[13,13]]]
pnames=['R','G','B','Y']
height = 1000
width = 800
initx = 0
inity = 0
currentPlayer = 'R'
compTokensLoc=[[1,1],[1,4],[4,1],[4,4]]
n=2
withComputer=False
dice_clicked = False
move_list = []
diceValue = 6
Game_grid = [[-1 for _ in range(15)] for _ in range(15)]
colors=['white','red','green','yellow','blue','black']
colorMatrix = [[-1, -1, -1, -1, -1, -1, 0, 0, 0, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, 0, 2, 2, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, 2, 2, 0, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, 0, 2, 0, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, 0, 2, 0, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, 0, 2, 0, -1, -1, -1, -1, -1, -1],
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0],
a. [0, 1, 1, 1, 1, 1, 0, 5, 0, 4, 4, 4, 4, 4, 0],
b. [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0],
c. [-1, -1, -1, -1, -1, -1, 0, 3, 0, -1, -1, -1, -1, -1, -1],

8. Creating all the token and grid objects

for i in range(15):
for j in range(15):
ob = gridObj(colors[colorMatrix[i][j]], [], safeMatrix[i][j], coordinateMatrix[i][j])
Game_grid[i][j] = ob
for j in range(4):
for i in range(1,5):
p=initPos[j][i-1]
R= Token(pnames[j]+str(i), colors[j+1], 0, (50 *p[0] , 50 * p[1]), 20)
Game_grid[p[0]][p[1]].playerList.append(R)

9. Writing function to draw grid

50, 200, 200)) def drawGrid():


global Game_grid
newSurface = pygame.display.set_mode((height, width))
newSurface.fill('bisque')
for i in range(15):
for j in range(15):
pygame.draw.rect(newSurface, Game_grid[i][j].bgColor, tuple(Game_grid[i][j].coordinate + [50,
50]))
pygame.draw.rect(newSurface, (0, 0, 0), tuple(Game_grid[i][j].coordinate + [50, 50]), 1)
# always constant
pygame.draw.rect(newSurface, colors[1], (initx, inity, 300, 300))
pygame.draw.rect(newSurface, colors[0], (initx + 50, inity + 50, 200, 200))
pygame.draw.rect(newSurface, colors[2], (initx + 450, inity, 300, 300))
pygame.draw.rect(newSurface, colors[0], (initx + 500, inity +
pygame.draw.rect(newSurface, colors[3], (initx, inity + 450, 300, 300))
pygame.draw.rect(newSurface, colors[0], (initx + 50, inity + 500, 200, 200))
pygame.draw.rect(newSurface, colors[4], (initx + 450, inity + 450, 300, 300))
pygame.draw.rect(newSurface, colors[0], (initx + 500, inity + 500, 200, 200))
for i in range(15):
for j in range(15):
relativeToken(Game_grid[i][j].playerList, i * 50, j * 50)
for k in Game_grid[i][j].playerList:
c = k.coordinates
pygame.draw.circle(newSurface, k.color, (c[0] + 25, c[1] + 25), k.size)
pygame.draw.circle(newSurface, colors[-1], (c[0] + 25, c[1] + 25), k.size, 1)
# highlight
if k.Id[0] == currentPlayer:
pygame.draw.circle(newSurface, colors[0], (c[0] + 25, c[1] + 25), k.size - 2, 2)
# chess_faces
face = diceFaces[diceValue]
for i in range(3):
for j in range(3):
pygame.draw.rect(newSurface, 'black', ((0 + 800) + (50 * j), (0 + 300) + (50 * i), 50, 50))
if face[i][j] == 1:
cIndex=pnames.index(currentPlayer)+1
pygame.draw.circle(newSurface, colors[cIndex], ((0 + 800) + (50 * j) + 25, (0 + 300) + (50 *
i) + 25),
10)
pygame.draw.rect(newSurface, colors[pnames.index(currentPlayer)+1], ((0 + 798), (0 +
298), 150, 150), 4)
return newSurface

10. Writing functions to move the tokens

def move(initPos, value, current):


i=0
j = -1
flag = 0
while True:
if cList[i] == initPos or j >= 0:
if current == 'R' and i == 50:
flag = 1
if current == 'G' and i == 11:
flag = 2
if current == 'B' and i == 37:
flag = 3
if current == 'Y' and i == 24:
flag = 4
j += 1
if j == value:
break
i = (i + 1) % len(cList)
if flag == 1:
return (cList[i][0] + 1, cList[i][1] + 1)
elif flag == 2:
return (cList[i][0] + 1, cList[i][1] + 1)
elif flag == 3:
return (cList[i][0] + 1, cList[i][1] - 1)
elif flag == 4:
return (cList[i][0] - 1, cList[i][1] - 1)
else:
return (cList[i][0], cList[i][1])
def relativeToken(pList, x, y):
l = len(pList)
relRad = int((2 / (l + 1)) * 20)
relpt = []
j=0
if l % 2 == 0:
l1 = [i + 1 for i in range((l // 2))]
l2 = [i - 1 for i in range((l // 2))]
relpt = l2[::-1] + l1
else:
l1 = [i + 1 for i in range((l // 2))]
l2 = [i - 1 for i in range((l // 2))]
relpt = l2[::-1] + [0] + l1
for p in pList:
p.size = relRad
p.coordinates = ((x) + (relpt[j] * (relRad // 2)), (y))
j += 1
11. Writing functions to check id, current player and collision
of two players

def check(pos):
if pos in cList:
return True
else:
return False

def gridlocation(pos):
x = pos[0]
y = pos[1]
return (x // 50, y // 50)

def checkCollision(pList):
global currentPlayer
global Game_grid
new_list=[]
for p in pList:
if p.Id[0] == currentPlayer:
new_list.append(p)
else:
p.coordinates=p.original_coordinate
i=p.coordinates[0]//50
j=p.coordinates[1]//50
Game_grid[i][j].playerList.append(p)
return new_list
def checkId(pList):
global currentPlayer
for i in pList:
if i.Id[0] == currentPlayer:
return True
return False

12. Function to Move the Computer Token Automatically


def compLoc(diceValue):
global compTokensLoc
saveLocs=[(1, 7),(2, 7),(3, 7),(4, 7),(5, 7),(6, 7),(7, 7)]
inits=[]
players=[]
if(compTokensLoc[0]==[1,1]):
inits.append(0)
else:
players.append(0)
if(compTokensLoc[1]==[1,4]):
inits.append(1)
else:
players.append(1)
if(compTokensLoc[2]==[4,1]):
inits.append(2)
else:
players.append(2)
if(compTokensLoc[3]==[4,4]):
inits.append(3)
else:
players.append(3)
if(diceValue==6 and len(inits)>0):
tkn=random.randint(1,len(inits))
compTokensLoc[tkn-1]=cList[0]
return compTokensLoc[tkn-1]
cnt=len(compTokensLoc)-len(inits)
print(inits)
if(cnt<=0):
return (1,1)
if(cnt>0):
tkn=random.randint(1,cnt)
tkn=players[tkn-1]
print(tkn)
ind=cList.index(compTokensLoc[tkn])
if(compTokensLoc[tkn] in saveLocs):
ind=saveLocs.index(compTokensLoc[tkn])
if((ind+diceValue) <=(len(saveLocs-1))):
compTokensLoc[tkn]=saveLocs[ind+diceValue]
return compTokensLoc[tkn]
else:
compLoc(diceValue)
elif(ind+diceValue<len(cList)-1):
compTokensLoc[tkn]=cList[ind+diceValue]
else:
stepsLeft= diceValue-(len(cList)-1)
compTokensLoc[tkn]=saveLocs[stepsLeft-1]
return compTokensLoc[tkn]

13. Writing the Function to get the Next Player

def nextPlayer():
global n,currentPlayer
if(n==2):
if currentPlayer == 'R':
currentPlayer = 'B'
elif currentPlayer == 'B':
currentPlayer = 'R'
elif(n==3):
if currentPlayer == 'R':
currentPlayer = 'G'
elif currentPlayer == 'G':
currentPlayer = 'Y'
elif currentPlayer == 'Y':
currentPlayer = 'R'
elif(n==4):
if currentPlayer == 'R':
currentPlayer = 'G'
elif currentPlayer == 'G':
currentPlayer = 'Y'
elif currentPlayer == 'Y':
currentPlayer = 'R'
elif currentPlayer == 'B':
currentPlayer = 'R'

14. Writing The Main Code

i. global DISPLAYSURF
a.def mainGame():
b. height = 1000
c.width = 800
d. pygame.init()
e.DISPLAYSURF = pygame.display.set_mode((height, width))
f. pygame.display.set_caption('PythonGeeks Ludo Game')
g. global cList,
initPos,pnames,initx,inity,currentPlayer,n,dice_clicked,move_list,diceValue,Game_grid,c
olors,colorMatrix, coordinateMatrix,safeMatrix,safeLocs,diceFaces

h. font = pygame.font.SysFont("Calibri", 30,'bold')


i. label = font.render("LUDO GAME", 1, 'black')
j. while (True):
k. for event in pygame.event.get():
a. if(withComputer and currentPlayer=='R') or event.type ==
MOUSEBUTTONDOWN:

if(withComputer and currentPlayer=='R'):

loc=compLoc(random.randint(1, 6))

dice_clicked == True

elif event.type == MOUSEBUTTONDOWN:

loc = gridlocation(event.pos)

if (loc[0] >= 16 and loc[0] <= 18 and loc[1] >= 6 and loc[1] <= 8 and
dice_clicked == False):

# dice_value = 6

diceValue = random.randint(1, 6)

print("dice clicked", currentPlayer)

dice_clicked = True

if diceValue != 6 and dice_clicked == True:

print(1)

flag = 0

for i in cList:

for p in Game _grid[i[0]][i[1]].playerList:

if p.Id[0] == currentPlayer:

flag = 1

if flag == 0:

nextPlayer()

dice_clicked = False

if currentPlayer == 'R' and diceValue == 6 and (loc in [(1, 1), (4,


1), (4, 4), (1, 4)]) and dice_clicked == True:
print(2)

print(Game_grid[1][6].playerList)

Game_grid[1][6].playerList.append(Game_grid[loc[0]][loc[1]].playerList[0
])

Game_grid[1][6].playerList[-1].coordinates = (50 * 1, 50 * 6)

for p in Game_grid[1][6].playerList:

print(p.coordinates)

Game_grid[loc[0]][loc[1]].playerList = []

dice_clicked = False

elif currentPlayer == 'G' and diceValue == 6 and (loc in [(10, 1),


(13, 1), (13, 4), (10, 4)]) and dice_clicked == True:

print(3)

print(Game_grid[8][1].playerList)

Game_grid[8][1].playerList.append(Game_grid[loc[0]][loc[1]].playerList[0
])

Game_grid[8][1].playerList[-1].coordinates = (50 * 8, 50 * 1)

Game_grid[loc[0]][loc[1]].playerList = []

print(Game_grid[8][1].playerList[0].Id)

dice_clicked = False

elif currentPlayer == 'B' and diceValue == 6 and (loc in [(1, 10),


(4, 10), (4, 13), (1, 13)]) and dice_clicked == True:

print(5)

print(Game_grid[6][13].playerList)
Game_grid[6][13].playerList.append(Game_grid[loc[0]][loc[1]].playerList[
0])

Game_grid[6][13].playerList[-1].coordinates = (50 * 6, 50 *
13)

Game_grid[loc[0]][loc[1]].playerList = []

dice_clicked = False

elif currentPlayer == 'Y' and diceValue == 6 and (loc in [(10, 10),


(13, 10), (13, 13), (10, 13)]) and dice_clicked == True:

print(4)

print(Game_grid[13][8].playerList)

Game_grid[13][8].playerList.append(Game_grid[loc[0]][loc[1]].playerList[
0])

Game_grid[13][8].playerList[-1].coordinates = (50 * 13, 50 *


8)

Game_grid[loc[0]][loc[1]].playerList = []

dice_clicked = False

elif currentPlayer == 'R' and (loc in [(1, 7), (2, 7), (3, 7), (4, 7), (5,
7)]) and len(

Game_grid[loc[0]][loc[1]].playerList) > 0 and dice_clicked


== True:

if loc[0] + diceValue <= 6:

Game_grid[loc[0] +
diceValue][loc[1]].playerList.append(Game_grid[loc[0]][loc[1]].playerList[
-1])

Game_grid[loc[0] + diceValue][loc[1]].playerList[-
1].coordinates = (
50 * (loc[0] + diceValue), 50 * (loc[1]))

Game_grid[loc[0]][loc[1]].playerList =
Game_grid[loc[0]][loc[1]].playerList[:-1]

dice_clicked = False

elif currentPlayer == 'G' and (loc in [(7, 1), (7, 2), (7, 3), (7, 4), (7,
5)]) and len(

Game_grid[loc[0]][loc[1]].playerList) > 0 and dice_clicked


== True:

if loc[1] + diceValue <= 6:

Game_grid[loc[0]][loc[1] +
diceValue].playerList.append(Game_grid[loc[0]][loc[1]].playerList[-1])

Game_grid[loc[0]][loc[1] + diceValue].playerList[-
1].coordinates = (

50 * (loc[0]), 50 * (loc[1] + diceValue))

Game_grid[loc[0]][loc[1]].playerList =
Game_grid[loc[0]][loc[1]].playerList[:-1]

dice_clicked = False

elif currentPlayer == 'B' and (loc in [(7, 9), (7, 10), (7, 11), (7,
12), (7, 13)]) and len(

Game_grid[loc[0]][loc[1]].playerList) > 0 and dice_clicked


== True:

if loc[1] + diceValue >= 8:

Game_grid[loc[0]][loc[1] +
diceValue].playerList.append(Game_grid[loc[0]][loc[1]].playerList[-1])

Game_grid[loc[0]][loc[1] + diceValue].playerList[-
1].coordinates = (

50 * (loc[0]), 50 * (loc[1] + diceValue))


Game_grid[loc[0]][loc[1]].playerList =
Game_grid[loc[0]][loc[1]].playerList[:-1]

dice_clicked = False

elif currentPlayer == 'Y' and (loc in [(9, 7), (10, 7), (11, 7), (12,
7), (13, 7)]) and len(

Game_grid[loc[0]][loc[1]].playerList) > 0 and dice_clicked ==


True:

if loc[0] - diceValue >=8:

Game_grid[loc[0] -
diceValue][loc[1]].playerList.append(Game_grid[loc[0]][loc[1]].playerList[
-1])

Game_grid[loc[0] - diceValue][loc[1]].playerList[-
1].coordinates = (

50 * (loc[0] - diceValue), 50 * (loc[1]))

Game_grid[loc[0]][loc[1]].playerList =
Game_grid[loc[0]][loc[1]].playerList[:-1]

dice_clicked = False

elif (check(loc)) and


checkId(Game_grid[loc[0]][loc[1]].playerList) and dice_clicked == True:

print(6)

newpos = move(loc, diceValue, currentPlayer)

new_list = []

flg = 0

for i in Game_grid[loc[0]][loc[1]].playerList:

if i.Id[0] == currentPlayer and flg == 0:

Game_grid[newpos[0]][newpos[1]].playerList.append(i)
Game_grid[newpos[0]][newpos[1]].playerList[-
1].coordinates = (50 * newpos[0], 50 * newpos[1])

#eating pieces

Game_grid[newpos[0]][newpos[1]].playerList=checkCollision(Game_grid[
newpos[0]][newpos[1]].playerList)

flg = 1

else:

new_list.append(i)

Game_grid[loc[0]][loc[1]].playerList = new_list

dice_clicked = False

if diceValue != 6:

nextPlayer()

# DISPLAYSURF.blit(drawGrid(), (0, 0))

# pygame.display.update()

font1 = pygame.font.SysFont("Calibri", 50)

label1 = font1.render(str(diceValue), 1, 'black')

DISPLAYSURF.blit(drawGrid(), (0, 0))

DISPLAYSURF.blit(label, (800, 10))

DISPLAYSURF.blit(label1, (850, 500))

pygame.display.update()

if event.type == QUIT:

pygame.quit()

sys.exit()
15. Code Of The Main Window

pygame.init()

screen = pygame.display.set_mode((1000, 600))

pygame.display.set_caption('PythonGeeks Ludo Game')

clock = pygame.time.Clock()

font = pygame.font.SysFont("Arial", 20)

class Button:

"""Create a button, then blit the surface in the while loop"""

def _init_(self, text,num,comp,pos, font, bg="blue", feedback=""):

self.x, self.y = pos

self.font = pygame.font.SysFont("Arial", font)

self.no=num

self.text=text

self.text = self.font.render(self.text, 1, pygame.Color("White"))

self.cmp=comp

self.change_text(bg)

def change_text(self, bg="blue"):

self.size = self.text.get_size()

self.surface = pygame.Surface(self.size)

self.surface.fill(bg)
self.surface.blit(self.text, (0, 0))

self.rect = pygame.Rect(self.x, self.y, self.size[0], self.size[1])

def show(self):

screen.blit(self.text , (self.x, self.y))

def click(self, event):

x, y = pygame.mouse.get_pos()

font1 = pygame.font.SysFont("Calibri", 50)

label1 = font1.render("PythonGeeks Ludo Game", 1, 'yellow')

screen.blit(label1, (230, 30))

if event.type == pygame.MOUSEBUTTONDOWN:

if pygame.mouse.get_pressed()[0]:

if self.rect.collidepoint(x, y):

global n,withComputer

n=self.no

withComputer=self.cmp

print(n,",",withComputer)

pygame.quit()

mainGame()

def mainloop():

""" The infinite loop where things happen """


while True:

for event in pygame.event.get():

if event.type == pygame.QUIT:

pygame.quit()

button1.click(event)

button2.click(event)

button3.click(event)

button4.click(event)

button1.show()

button2.show()

button3.show()

button4.show()

clock.tick(30)

pygame.display.update()

button1 = Button(

"Play with Computer",2,True,

(400, 150),

font=30,

bg="navy")

button2 = Button(

"2 Players",2,False,

(400, 250),

font=30,
bg="navy")

button3 = Button(

"3 Players",3,False,

(400, 350),

font=30,

bg="navy",)

button4 = Button(

"4 Players",4,False,

(400, 450),

font=30,

bg="navy",)

Output
16. Conclusion
The game of Ludo concludes when one player successfully brings all
four of their tokens to the home triangle. It is a game of both strategy
and luck, requiring tactical moves and careful risk management. The
winner is the first to finish, but the journey is equally engaging for all
players.

You might also like