0% found this document useful (0 votes)
48 views28 pages

Annexure-I Micro-Project Proposal: "A Ludo Game"

The micro-project aims to develop a Ludo Game using Python, focusing on game mechanics, player movements, and GUI interactions. The project includes researching game rules, implementing game logic, and testing for functionality, with a structured action plan and required resources outlined. It also emphasizes learning Python programming concepts, object-oriented programming, and event-driven programming through game development.

Uploaded by

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

Annexure-I Micro-Project Proposal: "A Ludo Game"

The micro-project aims to develop a Ludo Game using Python, focusing on game mechanics, player movements, and GUI interactions. The project includes researching game rules, implementing game logic, and testing for functionality, with a structured action plan and required resources outlined. It also emphasizes learning Python programming concepts, object-oriented programming, and event-driven programming through game development.

Uploaded by

skillzifyind2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Programming With Python (22616) A Ludo Game

Annexure–I
Micro-Project Proposal
“A Ludo Game”
1.0 Aim of the Micro-Project:

The aim of this micro-project is to develop a Ludo Game in Python, focusing on game
logic, player movements, dice rolling, and multiplayer gameplay mechanics.

2.0 Intended Course Outcomes:


a. Display Message on screen using Python script IDE.
b. Develop python program to demonstrate use of Operators.
d. Develop functions for given problem.
e. Design classes for given problem.

3.0 Proposed methodology:

I. Researched the rules and mechanics of Ludo.


II. Designed the game layout using Python libraries.
III. Implemented the game logic and movement rules.
IV. Integrated a graphical user interface (GUI) for user interaction.
V. Tested the game for functionality and optimized performance.
VI. Compiled all findings and prepared the final report.

4.0 Action Plan:


Planned Planned Name of
Sr. Start Finish responsible team
No. Details of Activity
Date Date members
Study the rules and mechanics of
Ludo. 17/02/25 24/02/25
1 Vikas Patil

Department of Computer Technology Academic Year 2024-25 1


Programming With Python (22616) A Ludo Game

Learn and choose suitable Python


libraries (Tkinter/Pygame). 24/02/25 03/03/25 Vikas Patil
2

Implement game logic, dice rolling, 10/03/25 17/03/25 Vikas Patil


3 and player movements.

Debug, test, and refine the game for 17/03/25 24/03/25 Vikas Patil
4 errors.

24/03/25 04/04/25 Vikas Patil


5 Prepare the final report.

5.0 Resources Required:


Sr. No. Resources required Specifications

1 Computer system Intel(R) Pentium CPU, RAM 8 GB

2 Operating System Windows 10, 64 Bit Operating System

3 Software VS Code

6.0 Team Members:

Sr No. Roll No. Name

1 12 Vikas Patil

Department of Computer Technology Academic Year 2024-25 2


Programming With Python (22616) A Ludo Game

Annexure–II
Micro-Project Proposal
“A Ludo Game”
1.0 Rationale

Ludo is a popular board game that has been played for generations. With the rise of
digital gaming, developing A Ludo game in Python will provide an opportunity to
explore Python programming concepts, graphical user interfaces, and event-driven
programming. The project will help in understanding game development techniques,
object-oriented programming, and user interaction handling in Python.

2.0Aim of the Micro-Project:

The aim of this micro-project is to design and develop a Ludo Game in Python,
implementing game mechanics, player movements, dice rolling, and GUI-based
interactions.

3.0 Course Outcomes Addressed:


a. Display Message on screen using Python script IDE.
b. Develop python program to demonstrate use of Operators.
d. Develop functions for given problem.
e. Design classes for given problem.

4.0 Literature Review:

LUDO GAME DEVELOPMENT


Abstract:

Game development in Python has become an essential learning tool for understanding event-
driven programming, GUI handling, and logic implementation. This project discusses the
step-by-step implementation of Ludo game mechanics, including dice rolling, movement, and
winning conditions using Python and Pygame/Tkinter.

1. Game Mechanics:

 The game consists of a board, dice, and four player tokens per player.
 Players take turns rolling a six-sided die to move their tokens.
 If a player lands on an opponent's token, they send them back to the starting position.
 The first player to move all tokens to the final home wins.

Department of Computer Technology Academic Year 2024-25 3


Programming With Python (22616) A Ludo Game

2. Implementation Approach:

 Used Pygame/Tkinter to create the board and GUI.


 Implemented dice rolling using random module.
 Designed player movement logic with OOP concepts.
 Ensured turn-based gameplay mechanics.
 Added collision detection for player interactions.

3. Case Studies of Similar Games:

 Ludo King (Mobile App): Implementation of Ludo in mobile platforms.


 Snakes and Ladders (Python Implementation): A similar board game developed using
Python.
 Monopoly (Python Board Game): Another Python-based board game using OOP.

4. Evolution of Ludo Game Development:

 From Physical to Digital: The game transitioned from board games to mobile
applications.
 Multiplayer Capabilities: Online and AI-based Ludo versions have emerged.
 Integration of AI Opponents: Some versions include computer players.

5. Countermeasures & Game Security:

 Implemented randomization logic to ensure fair dice rolls.


 Restricted unauthorized modifications to game rules.
 Ensured proper turn management in multiplayer mode.

5.0 Code:
import pygame
import sys
import random
from typing import List, Dict, Tuple, Optional
import time

# Initialize pygame
[Link]()

Department of Computer Technology Academic Year 2024-25 4


Programming With Python (22616) A Ludo Game

# Constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800
FPS = 60

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
GREY = (200, 200, 200)

# Game constants
BOARD_SIZE = 600
MARGIN = 100
CELL_SIZE = BOARD_SIZE // 15
HOME_SIZE = BOARD_SIZE // 3
PLAYER_COLORS = [RED, GREEN, BLUE, YELLOW]
COLOR_NAMES = ["RED", "GREEN", "BLUE", "YELLOW"]

class Token:
def _init_(self, color: Tuple[int, int, int], token_id: int):
[Link] = color
self.token_id = token_id

Department of Computer Technology Academic Year 2024-25 5


Programming With Python (22616) A Ludo Game

[Link] = -1 # -1 means in home yard


[Link] = False
self.home_position = self.get_home_position()

def get_home_position(self) -> Tuple[int, int]:


"""Return the position in the home yard."""
color_index = PLAYER_COLORS.index([Link])
offset = 20 # Offset from the edges of home yard

if color_index == 0: # RED (top-left)


base_x = MARGIN + offset
base_y = MARGIN + offset
if self.token_id == 0:
return (base_x, base_y)
elif self.token_id == 1:
return (base_x + HOME_SIZE//2, base_y)
elif self.token_id == 2:
return (base_x, base_y + HOME_SIZE//2)
else:
return (base_x + HOME_SIZE//2, base_y + HOME_SIZE//2)

elif color_index == 1: # GREEN (top-right)


base_x = MARGIN + BOARD_SIZE - HOME_SIZE + offset
base_y = MARGIN + offset
if self.token_id == 0:
return (base_x, base_y)
elif self.token_id == 1:

Department of Computer Technology Academic Year 2024-25 6


Programming With Python (22616) A Ludo Game

return (base_x + HOME_SIZE//2, base_y)


elif self.token_id == 2:
return (base_x, base_y + HOME_SIZE//2)
else:
return (base_x + HOME_SIZE//2, base_y + HOME_SIZE//2)

elif color_index == 2: # BLUE (bottom-left)


base_x = MARGIN + offset
base_y = MARGIN + BOARD_SIZE - HOME_SIZE + offset
if self.token_id == 0:
return (base_x, base_y)
elif self.token_id == 1:
return (base_x + HOME_SIZE//2, base_y)
elif self.token_id == 2:
return (base_x, base_y + HOME_SIZE//2)
else:
return (base_x + HOME_SIZE//2, base_y + HOME_SIZE//2)

else: # YELLOW (bottom-right)


base_x = MARGIN + BOARD_SIZE - HOME_SIZE + offset
base_y = MARGIN + BOARD_SIZE - HOME_SIZE + offset
if self.token_id == 0:
return (base_x, base_y)
elif self.token_id == 1:
return (base_x + HOME_SIZE//2, base_y)
elif self.token_id == 2:
return (base_x, base_y + HOME_SIZE//2)

Department of Computer Technology Academic Year 2024-25 7


Programming With Python (22616) A Ludo Game

else:
return (base_x + HOME_SIZE//2, base_y + HOME_SIZE//2)

def get_screen_position(self) -> Tuple[int, int]:


"""Convert the token's position to screen coordinates."""
if [Link] == -1: # In home yard
return self.home_position
elif [Link]: # In the center finish area
color_index = PLAYER_COLORS.index([Link])
if color_index == 0: # RED
return (MARGIN + 7*CELL_SIZE, MARGIN + 7*CELL_SIZE -
CELL_SIZE//2)
elif color_index == 1: # GREEN
return (MARGIN + 7*CELL_SIZE, MARGIN + 7*CELL_SIZE +
CELL_SIZE//2)
elif color_index == 2: # BLUE
return (MARGIN + 7*CELL_SIZE - CELL_SIZE//2, MARGIN +
7*CELL_SIZE)
else: # YELLOW
return (MARGIN + 7*CELL_SIZE + CELL_SIZE//2, MARGIN +
7*CELL_SIZE)
else:
# Convert board position to screen coordinates
path = self.get_path()
pos = path[[Link]]
return (MARGIN + pos[0] * CELL_SIZE + CELL_SIZE//2,
MARGIN + pos[1] * CELL_SIZE + CELL_SIZE//2)

Department of Computer Technology Academic Year 2024-25 8


Programming With Python (22616) A Ludo Game

def get_path(self) -> List[Tuple[int, int]]:


"""Get the path for the token's color."""
color_index = PLAYER_COLORS.index([Link])

# Common path for all colors (the outer square path)


common_path = []

# Start positions for each color


start_positions = {
0: (6, 13), # RED starts from bottom
1: (1, 6), # GREEN starts from left
2: (8, 1), # BLUE starts from top
3: (13, 8) # YELLOW starts from right
}

# Define the path segments


if color_index == 0: # RED
# Move up the right side
for i in range(13, 6, -1):
common_path.append((6, i))
# Move left at top
for i in range(5, -1, -1):
common_path.append((i, 6))
# Move down the left side
for i in range(5, 14):
common_path.append((0, i))
# Move right at bottom

Department of Computer Technology Academic Year 2024-25 9


Programming With Python (22616) A Ludo Game

for i in range(0, 6):


common_path.append((i, 14))

elif color_index == 1: # GREEN


# Move right from left
for i in range(1, 8):
common_path.append((i, 6))
# Move down on right side
for i in range(5, -1, -1):
common_path.append((8, i))
# Move left at bottom
for i in range(9, 15):
common_path.append((i, 0))
# Move up on left side
for i in range(0, 6):
common_path.append((14, i))

elif color_index == 2: # BLUE


# Move down from top
for i in range(1, 8):
common_path.append((8, i))
# Move left at bottom
for i in range(9, 15):
common_path.append((i, 8))
# Move up on right side
for i in range(9, 15):
common_path.append((14, i))

Department of Computer Technology Academic Year 2024-25 10


Programming With Python (22616) A Ludo Game

# Move right at top


for i in range(13, 7, -1):
common_path.append((i, 14))

else: # YELLOW
# Move left from right
for i in range(13, 6, -1):
common_path.append((i, 8))
# Move up on left side
for i in range(9, 15):
common_path.append((6, i))
# Move right at top
for i in range(5, -1, -1):
common_path.append((i, 14))
# Move down on right side
for i in range(13, 7, -1):
common_path.append((0, i))

# Add the final path to the center


if color_index == 0: # RED
final_path = [(7, i) for i in range(13, 7, -1)]
elif color_index == 1: # GREEN
final_path = [(i, 7) for i in range(1, 7)]
elif color_index == 2: # BLUE
final_path = [(7, i) for i in range(1, 7)]
else: # YELLOW
final_path = [(i, 7) for i in range(13, 7, -1)]

Department of Computer Technology Academic Year 2024-25 11


Programming With Python (22616) A Ludo Game

return common_path + final_path

class LudoGame:
def _init_(self):
[Link] = [Link].set_mode((SCREEN_WIDTH,
SCREEN_HEIGHT))
[Link].set_caption("Ludo Game")
[Link] = [Link]()
[Link] = [Link](None, 30)

# Game state
[Link] = 4
[Link] = []
for color in range([Link]):
for i in range(4):
[Link](Token(PLAYER_COLORS[color], i))

self.current_player = 0
self.dice_value = None
self.dice_rolled = False
[Link] = None
self.moving_token = None
self.move_timer = 0
[Link] = "Roll the dice to start!"

Department of Computer Technology Academic Year 2024-25 12


Programming With Python (22616) A Ludo Game

def roll_dice(self) -> int:


"""Roll the dice and return a random value between 1 and 6."""
return [Link](1, 6)

def is_token_at_position(self, position: Tuple[int, int]) -> List[Token]:


"""Check if any token is at the given screen position."""
tokens_at_pos = []
for token in [Link]:
token_pos = token.get_screen_position()
dx = token_pos[0] - position[0]
dy = token_pos[1] - position[1]
distance = (dx*2 + dy2)*0.5
if distance < CELL_SIZE // 2:
tokens_at_pos.append(token)
return tokens_at_pos

def get_clickable_tokens(self) -> List[Token]:


"""Get tokens that the current player can move."""
clickable_tokens = []

for token in [Link]:


if [Link] == PLAYER_COLORS[self.current_player] and not
[Link]:
# Token in home yard requires a 6 to move out
if [Link] == -1 and self.dice_value == 6:
clickable_tokens.append(token)
# Token already on the board

Department of Computer Technology Academic Year 2024-25 13


Programming With Python (22616) A Ludo Game

elif [Link] >= 0:


# Check if the move would make the token complete or is valid
new_pos = [Link] + self.dice_value
if new_pos < len(token.get_path()):
clickable_tokens.append(token)

return clickable_tokens

def move_token(self, token: Token) -> None:


"""Move the token according to the dice value."""
if [Link] == -1: # Token is in home yard
if self.dice_value == 6:
[Link] = 0 # Move to starting position
# Check for capture
self.check_capture(token)
else: # Token is on the board
new_pos = [Link] + self.dice_value
if new_pos < len(token.get_path()):
[Link] = new_pos
# Check if token has completed the path
if new_pos == len(token.get_path()) - 1:
[Link] = True
self.check_winner()
else:
# Check for capture
self.check_capture(token)

Department of Computer Technology Academic Year 2024-25 14


Programming With Python (22616) A Ludo Game

# Reset dice
if self.dice_value != 6:
self.current_player = (self.current_player + 1) % [Link]
[Link] = f"{COLOR_NAMES[self.current_player]}'s turn. Roll
the dice!"
else:
[Link] = f"{COLOR_NAMES[self.current_player]} rolled a 6!
Roll again!"

self.dice_rolled = False

def check_capture(self, moved_token: Token) -> None:


"""Check if the moved token captures an opponent's token."""
for token in [Link]:
# Skip tokens of the same color and tokens in home/completed
if [Link] == moved_token.color or [Link] == -1 or
[Link]:
continue

# Check if the paths intersect at this position


moved_path = moved_token.get_path()
token_path = token.get_path()

moved_coords = moved_path[moved_token.position]
token_coords = token_path[[Link]]

# If they're at the same board position and not in a safe zone

Department of Computer Technology Academic Year 2024-25 15


Programming With Python (22616) A Ludo Game

if moved_coords == token_coords and not


self.is_safe_position(moved_coords):
# Send the captured token back home
[Link] = -1
[Link] += f" Captured a
{COLOR_NAMES[PLAYER_COLORS.index([Link])]} token!"

def is_safe_position(self, position: Tuple[int, int]) -> bool:


"""Check if a position is a safe zone where tokens can't be captured."""
safe_positions = [
(6, 2), (2, 6), (12, 6), (8, 12), # Star positions
(7, 7), # Center
(6, 13), (1, 6), (8, 1), (13, 8) # Starting positions
]
return position in safe_positions

def check_winner(self) -> None:


"""Check if a player has won the game."""
for color_idx in range([Link]):
all_completed = True
for token in [Link]:
if [Link] == PLAYER_COLORS[color_idx] and not
[Link]:
all_completed = False
break
if all_completed:
[Link] = color_idx
[Link] = f"{COLOR_NAMES[color_idx]} has won the game!"

Department of Computer Technology Academic Year 2024-25 16


Programming With Python (22616) A Ludo Game

break

def draw_board(self) -> None:


"""Draw the Ludo board."""
# Fill background
[Link](WHITE)

# Draw the main board outline


[Link]([Link], BLACK, (MARGIN-5, MARGIN-5,
BOARD_SIZE+10, BOARD_SIZE+10), 5)

# Draw the home yards (corners)


# RED (top-left)
[Link]([Link], RED, (MARGIN, MARGIN, HOME_SIZE,
HOME_SIZE))
[Link]([Link], WHITE, (MARGIN+10, MARGIN+10,
HOME_SIZE-20, HOME_SIZE-20))
# GREEN (top-right)
[Link]([Link], GREEN, (MARGIN+BOARD_SIZE-
HOME_SIZE, MARGIN, HOME_SIZE, HOME_SIZE))
[Link]([Link], WHITE, (MARGIN+BOARD_SIZE-
HOME_SIZE+10, MARGIN+10, HOME_SIZE-20, HOME_SIZE-20))
# BLUE (bottom-left)
[Link]([Link], BLUE, (MARGIN,
MARGIN+BOARD_SIZE-HOME_SIZE, HOME_SIZE, HOME_SIZE))
[Link]([Link], WHITE, (MARGIN+10,
MARGIN+BOARD_SIZE-HOME_SIZE+10, HOME_SIZE-20, HOME_SIZE-
20))
# YELLOW (bottom-right)

Department of Computer Technology Academic Year 2024-25 17


Programming With Python (22616) A Ludo Game

[Link]([Link], YELLOW, (MARGIN+BOARD_SIZE-


HOME_SIZE, MARGIN+BOARD_SIZE-HOME_SIZE, HOME_SIZE,
HOME_SIZE))
[Link]([Link], WHITE, (MARGIN+BOARD_SIZE-
HOME_SIZE+10, MARGIN+BOARD_SIZE-HOME_SIZE+10, HOME_SIZE-
20, HOME_SIZE-20))

# Draw cells for the outer track


for i in range(15):
for j in range(15):
# Skip the corners (home yards)
if (i < 6 and j < 6) or (i < 6 and j > 8) or (i > 8 and j < 6) or (i > 8 and j
> 8):
continue

# Draw the cell


cell_color = WHITE

# Color the paths


if i == 7: # Vertical middle path
if j < 7:
cell_color = BLUE
elif j > 7:
cell_color = RED
elif j == 7: # Horizontal middle path
if i < 7:
cell_color = GREEN
elif i > 7:

Department of Computer Technology Academic Year 2024-25 18


Programming With Python (22616) A Ludo Game

cell_color = YELLOW

# Safe spots (stars)


safe_spots = [(6, 2), (2, 6), (8, 12), (12, 8)]
if (i, j) in safe_spots:
cell_color = GREY

# Starting positions
start_positions = [(6, 1), (1, 6), (8, 13), (13, 8)]
if (i, j) in start_positions:
cell_color = GREY

[Link]([Link], cell_color,
(MARGIN + i * CELL_SIZE, MARGIN + j * CELL_SIZE,
CELL_SIZE, CELL_SIZE))
[Link]([Link], BLACK,
(MARGIN + i * CELL_SIZE, MARGIN + j * CELL_SIZE,
CELL_SIZE, CELL_SIZE), 1)

# Draw the center


[Link]([Link], WHITE, (MARGIN + 6*CELL_SIZE,
MARGIN + 6*CELL_SIZE, 3*CELL_SIZE, 3*CELL_SIZE))

# Draw colored triangles in the center pointing to each home


# RED (pointing down)
[Link]([Link], RED, [
(MARGIN + 7*CELL_SIZE, MARGIN + 6*CELL_SIZE),

Department of Computer Technology Academic Year 2024-25 19


Programming With Python (22616) A Ludo Game

(MARGIN + 6*CELL_SIZE, MARGIN + 7.5*CELL_SIZE),


(MARGIN + 8*CELL_SIZE, MARGIN + 7.5*CELL_SIZE)
])
# GREEN (pointing right)
[Link]([Link], GREEN, [
(MARGIN + 6*CELL_SIZE, MARGIN + 7*CELL_SIZE),
(MARGIN + 7.5*CELL_SIZE, MARGIN + 6*CELL_SIZE),
(MARGIN + 7.5*CELL_SIZE, MARGIN + 8*CELL_SIZE)
])
# BLUE (pointing up)
[Link]([Link], BLUE, [
(MARGIN + 7*CELL_SIZE, MARGIN + 9*CELL_SIZE),
(MARGIN + 6*CELL_SIZE, MARGIN + 7.5*CELL_SIZE),
(MARGIN + 8*CELL_SIZE, MARGIN + 7.5*CELL_SIZE)
])
# YELLOW (pointing left)
[Link]([Link], YELLOW, [
(MARGIN + 9*CELL_SIZE, MARGIN + 7*CELL_SIZE),
(MARGIN + 7.5*CELL_SIZE, MARGIN + 6*CELL_SIZE),
(MARGIN + 7.5*CELL_SIZE, MARGIN + 8*CELL_SIZE)
])

def draw_tokens(self) -> None:


"""Draw all tokens on the board."""
for token in [Link]:
pos = token.get_screen_position()

Department of Computer Technology Academic Year 2024-25 20


Programming With Python (22616) A Ludo Game

# Draw the token


[Link]([Link], [Link], pos, CELL_SIZE // 3)
[Link]([Link], BLACK, pos, CELL_SIZE // 3, 2)

# Draw the token ID


text = [Link](str(token.token_id + 1), True, BLACK)
text_rect = text.get_rect(center=pos)
[Link](text, text_rect)

def draw_dice(self) -> None:


"""Draw the dice and roll button."""
# Draw dice roll button
[Link]([Link], GREY, (SCREEN_WIDTH - 150,
SCREEN_HEIGHT - 100, 100, 50))
[Link]([Link], BLACK, (SCREEN_WIDTH - 150,
SCREEN_HEIGHT - 100, 100, 50), 2)

text = [Link]("Roll Dice", True, BLACK)


text_rect = text.get_rect(center=(SCREEN_WIDTH - 100,
SCREEN_HEIGHT - 75))
[Link](text, text_rect)

# Draw dice value if rolled


if self.dice_value is not None:
[Link]([Link], WHITE, (SCREEN_WIDTH - 150,
SCREEN_HEIGHT - 180, 100, 60))
[Link]([Link], BLACK, (SCREEN_WIDTH - 150,
SCREEN_HEIGHT - 180, 100, 60), 2)

Department of Computer Technology Academic Year 2024-25 21


Programming With Python (22616) A Ludo Game

text = [Link](str(self.dice_value), True, BLACK)


text_rect = text.get_rect(center=(SCREEN_WIDTH - 100,
SCREEN_HEIGHT - 150))
[Link](text, text_rect)

def draw_player_turn(self) -> None:


"""Draw whose turn it is."""
[Link]([Link], PLAYER_COLORS[self.current_player],
(50, SCREEN_HEIGHT - 100, 20, 20))
text = [Link](f"{COLOR_NAMES[self.current_player]}'s Turn",
True, BLACK)
[Link](text, (80, SCREEN_HEIGHT - 100))

# Draw message
text = [Link]([Link], True, BLACK)
[Link](text, (50, SCREEN_HEIGHT - 70))

# Draw winner if there is one


if [Link] is not None:
font = [Link](None, 50)
text = [Link](f"{COLOR_NAMES[[Link]]} WINS!", True,
PLAYER_COLORS[[Link]])
text_rect = text.get_rect(center=(SCREEN_WIDTH // 2, 40))
[Link](text, text_rect)

def highlight_movable_tokens(self) -> None:


"""Highlight the tokens that can be moved."""
if self.dice_rolled:

Department of Computer Technology Academic Year 2024-25 22


Programming With Python (22616) A Ludo Game

clickable_tokens = self.get_clickable_tokens()
for token in clickable_tokens:
pos = token.get_screen_position()
[Link]([Link], WHITE, pos, CELL_SIZE // 2, 3)

def run(self) -> None:


"""Main game loop."""
running = True
while running:
# Handle events
for event in [Link]():
if [Link] == [Link]:
running = False

if [Link] == [Link] and [Link] is


None:
pos = [Link].get_pos()

# Check if dice roll button is clicked


if (SCREEN_WIDTH - 150 <= pos[0] <= SCREEN_WIDTH - 50
and
SCREEN_HEIGHT - 100 <= pos[1] <= SCREEN_HEIGHT - 50
and
not self.dice_rolled):
self.dice_value = self.roll_dice()
self.dice_rolled = True

# Check if the player can move any token

Department of Computer Technology Academic Year 2024-25 23


Programming With Python (22616) A Ludo Game

if not self.get_clickable_tokens():
[Link] = f"No valid moves. Next player's turn."
self.dice_rolled = False
self.current_player = (self.current_player + 1) % [Link]
else:
[Link] = f"Select a token to move."

# Check if a token is clicked


elif self.dice_rolled:
clickable_tokens = self.get_clickable_tokens()
for token in clickable_tokens:
token_pos = token.get_screen_position()
dx = token_pos[0] - pos[0]
dy = token_pos[1] - pos[1]
distance = (dx*2 + dy2)*0.5
if distance < CELL_SIZE // 2:
self.move_token(token)
break

# Update display elements


self.draw_board()
self.draw_dice()
self.draw_player_turn()
self.draw_tokens()
self.highlight_movable_tokens()

# Update the display

Department of Computer Technology Academic Year 2024-25 24


Programming With Python (22616) A Ludo Game

[Link]()

# Cap the frame rate


[Link](FPS)

[Link]()
[Link]()

if _name_ == "_main_":
game = LudoGame()
[Link]()
6.0 Output:

Department of Computer Technology Academic Year 2024-25 25


Programming With Python (22616) A Ludo Game

7.0 Actual Methodology Followed:

I. Researched the rules and mechanics of Ludo.


II. Designed the game layout using Python libraries.
III. Implemented the game logic and movement rules.
IV. Integrated a graphical user interface (GUI) for user interaction.
V. Tested the game for functionality and optimized performance.
VI. Compiled all findings and prepared the final report.

6.0 Actual Resources Required:

Department of Computer Technology Academic Year 2024-25 26


Programming With Python (22616) A Ludo Game

Sr. No. Resources required Specifications

1 Computer system Intel(R) Pentium CPU, RAM 4 GB

2 Operating System Windows 10, 64 Bit Operating System

3 Software Microsoft Word

7.0 Skills Developed:


During the course of this micro-project, following skills were developed:

 Understanding of game logic and development.


 Application of Python programming and OOP concepts.
 Experience with GUI design and event-driven programming.
 Debugging and optimizing game performance.
 Technical documentation and report writing skills.

8.0 Applications of this Micro-project:


This micro-project finds its application in:
1. Learning Tool for Beginners
2. Entertainment App
3. AI vs Human Simulation
9.0 Area of Future Improvement:
The Python Ludo game can be significantly enhanced in the future by improving its
graphical user interface using advanced libraries like Pygame or transitioning to
mobile platforms with tools like Kivy. Introducing online multiplayer support, AI
opponents with smarter decision-making, and real-time game statistics or leaderboards
would add depth and interactivity. Additionally, incorporating animations, sound
effects, and customizable rules would create a more engaging and user-friendly
experience. These improvements would not only elevate the game’s appeal but also
expand its practical use as a full-fledged software development project.

10.0 Conclusion

In conclusion, this micro-project successfully implemented a Ludo Game in Python,


demonstrating fundamental game development principles, Python programming, and GUI
interaction. The project provided hands-on experience in coding, debugging, and optimizing
game mechanics.

Department of Computer Technology Academic Year 2024-25 27


Programming With Python (22616) A Ludo Game

11.0 References
 [Link]
 [Link]
 [Link]

Department of Computer Technology Academic Year 2024-25 28

You might also like