Showing posts with label fun. Show all posts
Showing posts with label fun. Show all posts

Sunday, July 12, 2015

Coding the Rainfall


Written by Jonathan Paul (III MCA)

Its amazing to watch how one can find so much to learn from the nature around us. Inspired by nature is this piece of challenge in which we had to simulate a situation where in rain water would be trapped in trenches and pits.
 
    It always seems to be a daunting task when we face a new challenge, but we have to understand that every problem has a solution. It’s only the time that we need to worry about, nothing else.
    So it began; I loaded a matrix with 1 representing water, 2 representing air and 3 representing land. The challenge I faced was in realising that gravity starts from the surface (a hint :P). Also, we should ensure that molecules behave naturally, fall drop by drop, and last but not the least, we should ensure that we do not add or remove molecules by faulty logic.
    The other constraints were that water molecules need to settle down and ensure they are in a stable equilibrium state. Only a layer of water molecules could settle on the surface of land. Water would flow down slopes and would accumulate in crevices.
    The fun part was added by Prof. Jibrael Jos, when he asked us to drain the water through a hole in the surface. My joy knew no bounds when I saw the water flowing out literally “naturally”.
                                    

 

Coding the Conway’s Game Of Life

Written by Jonathan Paul (III MCA)
 
It was very hard to understand initially, “What is this Game of Life?”. It seemed so confusing. I was puzzled when Prof. Jibrael Jos first spoke to us about it . But then I read the four simple rules which determined the life of cells; approached sir, and he explained the life of an oscillator (Blinker). I was amazed ! It was like knife going through butter.
    I immediately got down to code it. Few if and else conditions, a little bit of concern for boundary conditions and ensure that no cells in the present generation were affected by cells of next generation ; gave me an ample of joy watching my first species oscillating on the terminal.
Then came the time to tweak the simulation. Sir asked us to discover new species. Just imagining the fact that I might find a new species in the huge ocean of the probabilistic matrix was awe-inspiring.
I wrapped the world of this simulation to allow an infinite space. Also provision for loading of discovered species into the world was given. Existing discoveries of interesting species was included in the simulation.

It was an interesting affair. I could watch these little bots moving on my screen for eternity. It has been an amazing experience coding this. And if you are interested to have fun, join the endeavor of finding new species.
 
 
 
I call this life a Village. It has a glider, blinkers which look like windmills, beehives, blocks which resemble huts, and loaves (food barn). I had fun, hope you do too.

Wiki URL : https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

 

Saturday, October 16, 2010

Sudoko Solver

Wrote a small application to solve a Suduko puzzle in C#, I was doing C# coding after some years now and I thoroughly enjoyed it

If you are interested you may wont to give it a try.

Step 1: Make a grid of text boxes (81 of them !!! ), load it into an array of objects
Step 2: Write function checkRow to see if no two numbers are repeated
Step 3:Write function checkColumn
Step 4:Write function checkBox
Step 5:Write function findAllPossible(for a particular position)
Step 6:Write function findAll(for all 81 position)
Step 7: Check is their a number in a row which is allowed only in that position, then that number is to be placed there
Step 8: Check is their a number in a column which is allowed only in that position, then that number is to be placed there
Step 9: Check is their a number in a box which is allowed only in that position, then that number is to be placed there
Step 10:Do color coding for duplicates. Make new entries come in green or something

Future Enhancements : Undo, History, Game Generation, Guessing in case direct solving does not work

Time : ~15 hours of coding ..... more because there was many things I was not sure how to do in C#, because of the gap ... try it, it is fun