Blogger Widgets

Search This Blog

Thursday, 10 January 2013

Some Intresting Implimentations using Pygame

                      Pygame is python module designed to writing games. Pygame was written by Pete Shinners and released under open source.It provides excellent GUI so that we can design the games easily rather than text based programmings.

A quick introduction about pygame is available here

Some Interesting Implementations using pygame is explained below
  •         Koch snowflake
  •         Conway's game of life
  •         Sierpinski triangle

Koch snowflake

     
    Is it possible to think a shape whose area is finite, but the perimeter is infinite?  Yes  ,Koch snow flake is an interesting mathematical curve whose area is converging, But the perimeter is infinite.It is an example of non euclidean geometry. Another property is that the koch curve is continues every where,but not differentiable  any where.


I construct this koch curve using pygame in recursive  fasion. Here I cunstuct a order-1 fractal first, then call that function repeatedly.

My recursive function is 


def koch(screen,order,a):
        if order == 0:
           for angles in [60,-120,60,0]:
               forward(1)
               right(angles)
        else:
           for angles  in [60,-120,60,0]:
               koch(screen, order - 1,a)  
               right(angles)
 


Blogger Widgets