Mentors

  • Hemant Kumar Bajaj
  • Meet Banthia

Members

  • Sthuthi S.
  • Varahi Suvarna
  • Vignesh Ittikkatt Jagannivasan
  • Nidhi Kumari

Acknowledgements

We would like to thank the IEEE NITK Student Branch for conducting Envision 2023.

Aim

The project aims to create an interactive and enjoyable version of the classic Sudoku game that can be enjoyed by players of all skill levels.

Introduction

Sudoku is a popular number-placement puzzle game that has been around for decades. The objective of the game is to fill a 9x9 grid with numbers such that each row, column, and 3x3 sub-grid contains all of the digits from 1 to 9. The game can be challenging and requires logical thinking and problem-solving skills. Creating a Sudoku game can be a fun and educational project for those interested in game development or programming. The project can be implemented using various programming languages and frameworks, and can include features such as a user interface, a timer, and difficulty levels. One could start by creating a basic grid and allowing the user to input numbers. Then, implementing the logic to check if the user input is correct and if the game is solved. Finally, adding extra features like the timer, different level of difficulty, and even a scoreboard could be added to make the game more engaging. Overall, the project aims to create an interactive and enjoyable version of the classic Sudoku game that can be enjoyed by players of all skill levels. image 1

PyGame Python Library

Pygame is a popular cross-platform library in Python used for developing 2D games, multimedia applications, and graphical user interfaces. It provides a comprehensive set of functions and tools for game development, making it easier to create interactive and visually appealing applications.

PyGame Features

Key Features of Pygame:

Simple and Easy to Use

Pygame is designed to be beginner-friendly and straightforward. It provides a simple and intuitive API that allows developers to quickly start building games without much complexity.

Cross-platform Compatibility

Pygame is compatible with multiple platforms, including Windows, macOS, Linux, and others. This allows developers to create games that can run on different operating systems without major modifications.

Graphics and Animation

Pygame offers a wide range of features for graphics and animation. It provides functions for drawing shapes, lines, and images, as well as support for sprite-based animation, blending, and transparency effects.

Sound and Music

Pygame includes modules for handling sound and music. Developers can load and play sound effects and music tracks in various formats, control volume, and apply effects like fading and mixing.

Input Handling

Pygame simplifies user input handling. It supports keyboard, mouse, and joystick input, allowing developers to easily capture and respond to user actions such as key presses, mouse clicks, and joystick movements.

Collision Detection

Pygame provides built-in collision detection functions that enable developers to detect collisions between game objects. This is useful for implementing game mechanics such as hit detection, collision-based scoring, and object interaction.

Networking

Pygame incorporates networking capabilities, allowing developers to create multiplayer games and applications. It includes functions for network communication, allowing data exchange between clients and servers.

Documentation and Community

Pygame has extensive documentation and an active community of developers. The official Pygame website provides detailed documentation, tutorials, examples, and a forum where developers can ask questions and share their projects.

Extensibility

Pygame is built on top of the SDL (Simple DirectMedia Layer) library, which provides low-level access to multimedia components such as graphics, audio, and input. This allows developers to extend Pygame’s functionality by directly accessing SDL features when needed.

Open Source and Free

Pygame is open source and released under the GNU Lesser General Public License (LGPL). This means it is free to use, modify, and distribute, making it accessible to developers of all levels.

Overall, Pygame is a versatile and powerful library for game development and multimedia applications in Python. Its simplicity, cross-platform compatibility, and rich feature set make it a popular choice among developers for creating interactive and engaging games. image 2 image 3

Backtracking Algorithm

Backtracking is a technique used to solve the Sudoku puzzle by systematically trying different possibilities and backtracking whenever a contradiction or invalid move is encountered. It is an algorithmic approach that exhaustively explores the search space until a solution is found.

  1. Start with an empty Sudoku grid or partially filled grid obtained from the initial puzzle.

  2. Find the first empty cell in the grid. If there are no empty cells, the puzzle is solved.

  3. Try numbers from 1 to 9 in the empty cell, one by one.

  4. For each number tried, check if it violates any of the Sudoku rules (i.e., if the same number is already present in the same row, column, or subgrid). If a violation is detected, move to the next number.

  5. If the number being tried satisfies the Sudoku rules, place it in the empty cell and move to the next empty cell.

  6. Recursively repeat steps 3 to 6 for the next empty cell.

  7. If the recursive calls reach a point where no valid numbers can be placed in an empty cell (i.e., all numbers 1 to 9 violate the rules), backtrack to the previous cell and try the next number.

  8. Repeat the process until the entire grid is filled, and a solution is found.

image 4 image 5 image 6 image 7 image 8

Project Features

Random Solvable Board

A new board is generated each time we begin a new game.

Check

Once the user is sure that the inputted number is the correct entry, by pressing the enter key will attempt to input the number onto the board. Correct answers will be permanently displayed while incorrect answers will be removed.

Timer

The timer feature enables the user to monitor their progress through the sudoku puzzle.

Solver

If the user is unable to solve the sudoku, they can obtain the complete solution by using the solver.The backtracking algorithm is used by the solver to solve the entire board.

Hint

It can provide assistance to players when they get stuck or need a nudge in the right direction.

image 9 image 10

Conclusion

Created a Sudoku game with a timer to add a level of challenge and excitement to the game by incorporating a time-based element and maintained a difficulty level of this game so that all level skilled players can play.

References

  1. PyGame, Link
  2. Backtracking Algorithm , Link
  3. Python, Link