Learning Javascript; A simple game
Tuesday, January 30th, 2007 by Agro RachmatullahThe plan for my final project is a web-based application. Because I don’t usually play with web technologies, there are many things that I have to learn. I chose Javascript as my first subject.
So, I’ve been reading w3school’s tutorial on Javascript. It’s great that the syntax is C-ish, so I could skim most of the syntatic stuffs.
Please don’t misundertand the title of this post. It doesn’t mean that “Learning Javascript is a simple game”. It means that “after learning some Javascript, I made a simple game” :). Here’s the game, please test it. (That’s the beauty of web apps, people can run your programs in any platform without the hassle of installing extra programs)
About the game itself, there were 3 major rewrites. The initial version could actually produce starting points that could not be solved! I rewrote it so that the initial state of the puzzle is generated from the completed state through a series of LEGAL moves. Second, the generator could produce an initial state that could be solved very easily. That sucks, so I added a check to keep shuffling if the initial state is too easy. Third, the “empty” cell is changed from the lower right to the middle. The reason is obvious, so that there is more incentive to solve the puzzle







