Here is a selection of projects that I worked on in the past, and am at least marginally proud of.
I develop in Python, and use the Pygame library for drawing.
The projects are listed in approximately chronological order, with old things on the bottom.



Vision: Reading in Rubik's Cube from video

This project tackles the problem of real-time object detection and localization. More specifically, I attempt to locate a Rubik’s Cube in a video stream and extract the sticker colors with minimal help from the user. The edge based approach I take is invarient to various camera settings and does not assume a particular color scheme for the cube.

See more detailed description, report, and code on this dedicated project page

Evolving social bots

This is a simulation of open ended evolution. The bots can sense each other, communicate with colors, and reproduce. They can become carnivors and hunt other bots for food, or they can choose to escape other bots and feed on herbs that grow on the ground. The aim of the project is not to evolve any particular behavior or optimize some rigid fitness function, but rather observe free evolution at work. The fitness function in the simulation is not only a function of the genes of every bot, but also of other currently living bots, which makes things much more interesting.


To model the brain of every bot I use a multilayer perceptron. There are 12 input neurons that are fed into a hidden layer that is allowed to form recurrent connections. Finally the 6 ouput neurons change the state of the bot in the world.


I love working on this project and there are many more things I want to try in the future. Right now I am most interested in trying different models of the brain.

Evolution Simulation

This program simulates an environment in which simple organisms with brains can evolve. The brains are directed graphs with nodes as the neurons and edges as axon/dendrite pairs.


The neural network is simulated fully with each signal traveling down the edges, instead of using the conventional approach where all neurons are updated every simulation tick.


The DNA for each organism is composed of the structure of the brain, (i.e. the set of existing edges), the parameters for neurons (firing threshold, excitation decay rate), and edges (speed, strength). Genetic algorithm with sexual reproduction is used to find brains that maximize the number of simulation ticks that an organism survives.

Sketcher

This program attempts to imitate the way an artist would draw an image with a pencil.


The pencil follows the perpendicular of the first order approximation of the image gradient of the pixel intensities. Every path containing a high number of high intensity gradients is stored as a stroke, and all strokes are rated based on their strength and length. Then the pencil shades them in one by one, starting with the strong strokes and moving down. Strokes that are close to each other are likely to be drawn consecutively for more pleasing visual effect.

SCALE

This is a game I developed with a friend for TOJAM #4 (2009) in two days. It is a winner of the "best use of theme" award.


You direct a small ball around a level, and solve simple puzzles using your amazing ability to scale the entire world around you.

Robot Arm

This is a robot arm that solves Towers of Hanoi! The number of bricks is an input parameter to the program. The arm also computes all points and trajectories on fly. I used clamped cubic splines for the paths.

Graph Layout

My attempt to display a graph neatly on the screen. I took a force based approach where every edge is modelled as a spring, and then the system is simulated until the total kinetic energy is below a certain threshold.

 

The most challanging part of course was coming up with heuristics for initial placement, and spring constants.

Evolution of locomotion

This program tries to evolve successful movement strategies of a small organism. The organisms are made up of rigid rods and can apply angular forces at the joints. A motion is then just a result of well timed applications of forces at the correct joints.

 

A big set of random motions is put under artificial selection based on the resulting speed, and a genetic algorithm is used to find successful motion strategies.

 

In the clip attached you can find one of my dog like creatures, and a motion it evolved that looks very similar to running.

Progger

This is a game I developed with a friend of mine for a programming competition. It is a simple puzzle game where you use the force of gravity and your sticky tongue to travel across the cosmos!

4 Seasons

I wanted to create an animation for a long time, and eventually came up with an idea of having a tree simulated through all four seasons.

 

And this is the result! All movements are generated procedurally in Python. I do use images for leafs, the tree, and the flowers. (though I did entertain the idea of generating all of those procedurally as well)

Tetris AI

This is a project I worked on with a friend of mine - It is an AI for Tetris! He was playing Tetris and I watched him play it thinking only about how I would write AI for it, and this is the result :)


We wrote a set of functions that each evaluate the board in some way, given the current and next piece. So for example one function looks at the number of holes in the grid. Another looks at the height of the squares. Another function looks at how well a piece fits into some position, etc. We then loop all possible places to drop the current piece, evaluate every function on every possibility, and weigh them according to a vector of weight values. These weights essentially determine the relative importance of each function.


The problem then becomes to find the vector of weights that yields good results. A genetic algorithm was used to fine tune our initial guesses. Overall, we were very pleased with the results.

3D Engine

This is a simple 3D engine that I put togther a while ago. I derived all math for it from scratch - the projection matrices, rotation transformations, vector classes, etc. The only API I used were to draw lines/points/polygons in 2D on screen.


It can also load arbitrary geometry, so you can import files created in Maya or 3D Max.


It can only do simple colorings and wireframes, and there is no texture/lighting support.

Crowd Simulation

This is a simulation of walking pedestrians. Each pedestrian has a "danger field" associated with him that is eliptical, expoentially decaying, and extending slightly in the direction that he is walking. Each agent tries to get to it's destination while also trying to minimize danger. I found the minimum by finding the gradient vectors in the danger function.


This simulation was a pretty big success I thought because very familiar phenomena resulted in it that result in a real life. For example, pedestrians prefer to stick behind another person who then acts as a "danger shield". Also, pedestrians can sometimes be indecisive about which direction they should walk in if faced with another pedestrian.