Thing a week

Game of Life Update!

By | Thing a week | No Comments

Every time I get to a significant milestone on a project I feel like Victor Frankenstein giving birth to my monster. I’m happy to report I have a working version of Conway’s game of life. The rules are super simple.

3 of my neighbors are alive – I’m alive

< 2 of my neighbors are alive – I’m dead

3 of my neighbors are alive – I’m dead

I created a simple javascript implementation using the html5 canvas element. I know what I have right now isn’t the most elegant solution and there are many improvements I can make. I plan on doing a little more optimization and cleanup after I research how other implementations work.

I think I want to rip out all of the drawing logic and put it in it’s own class. I’m not sure though….sometimes it is difficult to decide if you want to reinvent the wheel or not. I’ve been reading the source code for Kineticjs and I’m liking it’s approach to drawing and managing objects on the canvas. More to come later! If you’re interested in checking out my humble little project here’s a link to my github repo:

Game of Life Update

By | Thing a week | No Comments

I’ve been plugging away on this little game of life project. So far there are a few problems I’ve run into that have been fairly interesting to solve:

  • Detecting mouse clicks on an element. Currently I’ve got a decent solution for this but I think that I want to explore making it a little more robust in the future
  • Drawing lots of objects at once is really slow, I still haven’t fully addressed this problem. I still have a few things I want to try. I think pre-rendering may help the initial load. I also need to break out my old rendering techniques book to get some ideas. I need to experiment with the concept of buffers if I want to go forward with rolling my own api for drawing stuff. I’m also considering digging into a library like kineticjs for drawing.

Up next is getting the actual game of life rules functioning and making the animation

of it all work. Currently what I have is simple but I think it demonstrates the power of the canvas and it’s totally fun!

Tonight I also updated my Gruntfile to watch my js files so I don’t have to bother running a grunt task to compile every time I want to test something. I’ve gotta say Grunt is a pretty awesome tool for automating your workflow. Stay tuned for more later!!

Well now that I know this works….

By | Thing a week, Uncategorized | No Comments

So I recently started using evernote. And now I’ve found an awesome way to publish blog entries. Hopefully this will encourage a lot more activity on my site!

Again I’ve stayed up way too late. I got to working on my personal project implementing Conway’s Game of Life using the canvas element and javascript. I’m really excited to get this thing wrapped up. And obviously I’m pretty far off from my lofty goal of doing a thing a week. It turns out that’s really hard!!!

The state of things so far is that I have my tiles and my game board all set up. I ran into some fun optimization problems with drawing large sets of tiles… I still think there’s some work I could do here to get things loading even faster but I’ll leave that for later. Next up will be making this thing light up tiles and following Conway’s rules.

Anywho, that’s all for now. If anyone cares to check out my progress I’m making commits to my github repo that’s available by clicking on the link in the footer of this page!

~ Levi

The falling of Hawking’s Coulton Conway domino of life

By | Games, Random Thoughts, Thing a week, Uncategorized | No Comments

So I had an idea. It’s not an original idea and by the title you can extrapolate where I get my inspiration.

I often feel like I’m the opposite of Jonathan Coulton (if you click this link sign up for his
newsletter he’s an awesome guy!). In his song Code Monkey he talks about a programmer that’s fed up with his career but he can’t leave because he’s in love with a pretty girl. This song is a reflection of his life as a coder that decides to drop everything and go become a musician. My situation is exactly the opposite. I was a professional musician for 10 years and shifted gears to my other love: programming. Ok, that may be an over simplification but at it’s core that’s kinda how things went. While I didn’t completely drop being a musician, coding did take over as how I spend a predominant amount of my time.

To my point! Coulton went through a period where he had something he called “A thing a week” where he wrote a song a week. It was somewhat of an experiment to try and coax some musical creativity out of himself.  Which brings me to my own personal experiment. I’m going to be taking on a small personal project every week. With the goal of exploring different programming paradigms and ideas. At the start I want to set some rules.

#1 The project must be simple enough that it can be completed in one week
#2  If that project is not completed I’ll drop it and move on to the next thing
#3 Each Project will be defined on Monday
#4 All source code will be available on Github and regular updates/thoughts will be posted here

Onward to project 1’s definition and the genesis of that idea.

A week or two ago I was fumbling through my Netflix queue. Coupled with a recent binge on The Big Bang Theory and a general interest in all things science I discovered a show that Stephen Hawking narrates. I think it’s called Into The Universe or something. In the first episode they explore what the meaning of life is. Really fascinating stuff! In the show they talk about a “game” it’s called Conway’s Game of Life. This isn’t new to the world of computer science but it is something I’ve become really interesting in building.

The rules are simple: (From Wikipedia)

Any live cell with fewer than two live neighbours dies, as if caused by under-population.
Any live cell with two or three live neighbours lives on to the next generation.
Any live cell with more than three live neighbours dies, as if by overcrowding.
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

I’ve recently gotten really into build automation and testing. For this project I’ll be using Javascript.  I plan to use Grunt for build and test automation. And Jasmine as my testing framework. I want to give the user the ability to set up starting patterns and a start, stop, and reset button to control the game.

A I said before this isn’t new ground I’m breaking. I’m sure there are plenty of other implementations of the game of life floating around out there but as a start to a personal journey I think it’s a fun place to begin!

I’ll post updates as the week progresses. It’s going to be a busy week on the road for me and I’ve got a lot of other things going on with work and other personal projects to this will be a real challenge!