Skip to main content

Posts

Project 7 - Maze Generation

Maze generation is a fascinating topic. There are many ways to generate mazes and each one of them generates mazes with its own unique properties. In this blog post, I look some of the ways in which we can generate mazes. Before we can get into any of these algorithms, we must first figure out how our maze is modeled and stored inside our program.  Modelling the maze To get started, we can think of our maze a n by n grid of cells where a cell contains information about its index in the grid. Note: The cell can also contain references to its neighbors. This is helpful when you want to solve the maze using state space search algorithms like Depth First Search, Breadth First Search, etc. Next, we need to be able to store which cells are connected, i.e., which cells do not have a wall separating them. For this we use what is known as an adjacency matrix. The adjacency matrix is a m by m grid where m is the number of cells in our maze = n 2 . In the matrix the value at row i and column j
Recent posts

Project 6 - State Space Search - 8-Puzzle

State space search is a process which is used to create simple artificial intelligence. It can be used when the problem can be represented as a set of simple states and the player / agent is the only one who can affect the environment. It allows us to generate a path from the initial state to the goal state (of which there can be many depending on the problem). 8-Puzzle / Sliding Puzzle ,  N-queens  and  Route Finding  are some of the various problems which can be solved using state space search. Let us explore the process of solving the 8-Puzzle problem using various path finding algorithms and comparing how effective each of them is. To get started, we need to start by creating the 8-Puzzle game itself. First, we need a simple way to represent different states of the puzzle. A good way to do this is to store the state as a string. For example: Next up, we need a way to generate the actions that are possible from a particular state. We can  think of it as moving the empty space itself

Project 5 - Live Captioning App

In this blog post, I am going to show you how create a app in python which converts speech to text from the selected audio input device. To achieve this, I am going to be using an open-source speech recognition toolkit called Vosk . NOTE: Before you start following the further steps, it is recommended that you create a virtual environment. For instructions on creating a virtual environment head over to  Venv docs . To start off, we are first going to need to way to capture audio input. To do this, we are going to use the python-sounddevice library. To get started follow the installation steps here . Then, import the library into your script by adding the following at the top of your script. import sounddevice as sd Now, we need to find the sample rate of our input device. To do this, we are going to use the query devices function. device_info = sd . query_devices(device = None, kind = 'input' ) samplerate = int(device_info[ 'default_samplerate' ]) In this

Project 4 - Particle Collision Simulation (Part-1)

In a simple particle collision simulation, the goal is to simulate n particles colliding with each other or with the walls of the container. So how can we simulate these collisions? To start with simulating these collisions, we will start to looking at what we need to know when simulating collisions. For the sake of simplicity, let us assume that the particles are circular and that only elastic collision takes place. 1. Dimensions of the container which acts as the boundaries for the particles. 2. Position of each of the particles. 3. Velocity vector of each of the particles. 4. Mass of each of the particles. 5. Radius of each of the particles. The position of the particles changes depending on the velocity of the particles and the velocity of the particles changes when a particle either collides with a wall or with another particle. Now, we know how to calculate the new velocities when two particles collide.  So, how do we check when two particles collide? This is quite simple to do. 

Project 3 - Analysis of sorting algorithms

Sorting algorithms are one of the most basic as well as one of the most used algorithms. They form the basis for many other data structures and algorithms and are also a great way to learn to analyse algorithms.  In this post, I would like to perform my own analysis of these sorting algorithms to understand where and why various sorting algorithms should be used. My main focus is going to be practical analysis of these sorting algorithms and I am also going to be considering the simplicity of these algorithms. So first, let us think about what basis we are going to use for these sorting algorithms. To analyse any sorting algorithm, let us measure the time it takes to sort an array of integers. The array of integers that we are going to give to the sorting algorithms should be of the following types: Random arrays. Ex: [5, 2, 9, 7, 0, 4]. Sorted arrays. Ex: [3, 5, 7, 8, 11]. Sorted arrays in reverse order. Ex: [14, 11, 7, 3, 1]. Sorted arrays with a few random elements added to the end.

Project 2 - Load Balancing Simulation

Have you ever wondered how websites are able to handle millions of requests from people all over the world without crashing ? Here is the answer:  All the requests that are made to a website are sent to a server which redirects your request to various other servers based on which servers are free and which servers are not free. This process is called Load Balancing . This process can be simulated easily using queues. All servers operate on a First-In, First-Out (FIFO) basis. You can simulate load balancing by having a queue for each server. The main server which handles the requests will be sending the requests to the other servers in the network in order to be processed.  But how will the main server know which server to redirect the request to ? This can be easily solved by maintaining a score for each server. This score will be dependent on the speed of the server, number of different requests that the server is already handling and the approximate time each request might take. Depe

Project 1 - Browser linked list implementation

All of us use a browser to surf through the internet. In fact you are using one right now. Have you ever wondered how the forward and backward buttons of the browser work ? Or how the undo and redo functions of your text editor works ? The answer to this is a doubly linked list. A linked list consists of various individual nodes which store some data as well as a pointer to the next node. A doubly linked list has nodes which have pointers to the previous node as well. In a circular linked list, the last node points to the first node. Here is how the application is going to work: Whenever you go to a new website, a new node is added in front of the current node. And the forward and backward button traverse through the linked list.  If you wish to tinker with the code, here is the Github Repository . You can easily expand this program to act like undo and redo buttons of a text editor. Linked list are used in various other practical applications such as photo viewers and music players. A