Pattern advancements in JS

I’m currently working on a different type of JS app: a game. It’s a very simple game: the sliding tiles puzzle. I was playing with the idea of making one for fun since seeing it every day on my daughters new favorite TV show, and when I saw an article about implementing the game in JS (, I started on tinkering with it. The article also explains how to write an AI to solve these puzzles, which tickled my fancy even more.

However, once I got into the code of the article, I noticed it wasn’t very cleanly separated. For example, jQuery calls to animate tiles were performed in the same function as checking for the validity of a move. So, I thought about writing my own game engine before tackling the AI part. After all, it would be nice to swap out different input devices (Adafruit Trello, Wii Nunchuck, computer vision-instructued robots (what?)) and have a separated output, so that a game could be played with a arbitrary photo.

After I started separating the code, I ended up with a browser app which separated presentation (using jQuery) and logic (using a knockout viewmodel). Not quite sufficient: handling input from hardware devices would remain difficult. Off to node! This would allow me to make games persistent, handle multiple games, etc. However, this could make the simple functionality slow, so caching is needed. In the end, I try to learn about:

  • factories
  • commands
  • singleton
Pattern advancements in JS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s