0% found this document useful (0 votes)
13 views

dsa mini project report

This document outlines a mini project for implementing the Snake and Ladders game in Python, aimed at teaching basic programming concepts. The game simulates dice rolls and player movements, incorporating elements like snakes and ladders to enhance gameplay. It serves as a practical example for beginners to understand game development logic and modular programming in Python.

Uploaded by

ishabachhav2410
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)
13 views

dsa mini project report

This document outlines a mini project for implementing the Snake and Ladders game in Python, aimed at teaching basic programming concepts. The game simulates dice rolls and player movements, incorporating elements like snakes and ladders to enhance gameplay. It serves as a practical example for beginners to understand game development logic and modular programming in Python.

Uploaded by

ishabachhav2410
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/ 5

Department of Computer Engineering

Course Name & Code: Data structures and Algorithm (210253)

(2019 course)

Title: Design a mini project to implement Snake and Ladders Game using python.

Abstract:
The Snake and Ladder game is a classic board game that combines luck and strategy, often
used for entertainment and educational purposes. This project presents a digital version of
the game implemented in Python, using basic control structures and logic. The game is
designed for two players and simulates dice rolls, player turns, and the effects of landing on
snakes and ladders. By leveraging Python's randomization and simple I/O operations, the
program creates an interactive, text-based gaming experience. This project serves as a
foundational example for beginners to understand game development logic, user input
handling, condition checking, and modular programming concepts in Python. .

Introduction:
The Snake and Ladder game has been a popular pastime for generations, originating from ancient
India as a tool to teach moral lessons. In modern times, it is enjoyed purely as a game of luck and fun.
The objective is simple: players roll a dice and move forward by the number shown, while
encountering snakes that bring them down and ladders that lift them higher. The first player to reach
square 100 wins.

This project reimagines the traditional board game in a console-based Python application. It uses
fundamental programming concepts like loops, functions, dictionaries, and random number
generation to manage game flow. Snakes and ladders are represented as mappings on the board, and
player movement is simulated through dice rolls. The game alternates turns between two players,
providing a fair and engaging experience. This project not only showcases how a simple board game
can be developed in Python but also demonstrates the power of logic building and code structuring in
programming.
Theory

Code :

import random
import time

# Define snakes and ladders


snakes = {16: 6, 47: 26, 49: 11, 56: 53, 62: 19, 64: 60, 87: 24, 93: 73, 95: 75, 98:
78}
ladders = {1: 38, 4: 14, 9: 31, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91, 80: 100}

# Initialize player positions


player_pos = {1: 0, 2: 0}

def roll_dice():
return random.randint(1, 6)

def move_player(player, current_pos):


input(f"\nPlayer {player}, press Enter to roll the dice...")
dice = roll_dice()
print(f"Player {player} rolled a {dice}")
time.sleep(1)

new_pos = current_pos + dice


if new_pos > 100:
print("Roll too high, stay at same position.")
return current_pos

# Check for snakes or ladders


if new_pos in snakes:
print(f"Oh no! Bitten by a snake at {new_pos}. Go down to {snakes[new_pos]}.")
return snakes[new_pos]
elif new_pos in ladders:
print(f"Yay! Climbed a ladder at {new_pos}. Go up to {ladders[new_pos]}.")
return ladders[new_pos]
else:
print(f"Moved to {new_pos}")
return new_pos

def check_winner(player, position):


if position == 100:
print(f"\n Player {player} wins the game! ")
return True
return False

def play_game():
print("Welcome to Snake and Ladder Game ")
game_over = False
turn = 1

while not game_over:


player = 1 if turn % 2 != 0 else 2
player_pos[player] = move_player(player, player_pos[player])
game_over = check_winner(player, player_pos[player])
turn += 1

play_game()
Snapshots :
Conclusion:

The exploration of Fibonacci search in non-uniform access memory storage and its application in
optimizing unimodal functions reveals its significant advantages in improving search efficiency in
environments where access times vary. By leveraging the Fibonacci sequence, this algorithm effectively
narrows the search space, minimizing the number of memory accesses and enhancing performance,
particularly in scenarios where certain memory locations are faster to access than others. This makes
Fibonacci search a valuable tool in computational tasks that demand quick and efficient data retrieval.

Name : Isha Prashant Bachhav

Roll .No : 57

Date: /5/2025

Class: S.E(Computer) Sem: 4th Sign of Subject Teacher

You might also like