Terminal Life

Terminal-life

After completing my first iteration of Conway’s Game of Life I was unhappy with the performance. After a bit of testing I discovered that the real bottleneck wasn’t in my algorithm, but in the overhead associated with the pygame module that was taking care of the graphics.

 

I just completed a branch of the code that does away with the pygame module. Instead, it runs in a bash shell. The program uses tput to read in lines and columns available in the terminal, and also to move the cursor back to the top left before each new generation is drawn. Of course the limitation here is that it only works on Linux. I was able to maintain the look by using a Unicode character which draws a box. That’s a screenshot of the code running.

Leave a Reply