Learning Javascript; A simple game

The 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 :)

Share and Enjoy:
  • bodytext
  • del.icio.us
  • Technorati
  • Slashdot
  • StumbleUpon
  • Sphinn
  • Facebook
  • Mixx
  • Google
  • TwitThis
  • Live

4 Responses to “Learning Javascript; A simple game”

  1. pramur Says:

    Numpang nimbrung nih Mas…
    Wah, aku isi “Nyonya pramur” kok salah ya? Aku ga kenal artisnya. Hehe, jadi inget pas dulu ada game serupa dengan angka 1 sampai 15 (kotaknya empat kali empat, dengan satu bolong, konsepnya kayaknya sama), harganya lima ratus perak, jaman aku SD uang segitu bisa untuk jajan seminggu.

  2. Agro Rachmatullah Says:

    Nyonya Pramur? Enak aja :)….

    Ingetanku samar, tapi sepertinya aku mengenal permainan ini pertama kali di komputer. Tapi pernah main yang versi “dunia nyata”-nya juga.

    Yang jauh lebih susah itu Rubik’s Cube yang 3 dimensi. Aku belum pernyah menyelesaikannya :).

  3. pramur Says:

    Numpang nimbrung nih Mas…
    Hehe… Sedang ngawur waktu itu, maklum. Rubik’s Cube itu bukannya kubus yang punya 6 warna berbeda di masing2 sisi, dan kita disuruh “membenarkan”nya? Aku punya kok, dikasih sama mantan temen kos. Aku udah bisa sih, perlu waktu sekitar 12 hari (non stop) nyoba-nyoba, ngawur dan tak kenal lelah. Ditambah waktu itu solvingnya di atas laut 2 hari, berhenti hanya untuk sholat, makan, buang air atau tidur. Sekarang 10 menit udah bisa solved. Sebuah curiousity yang akhirnya membawa hasil..

  4. Agro Rachmatullah Says:

    Wuaaa hebat… Aku waktu itu nyoba pas lagi di tempat temen, main sekitar 2 jam. Setelah itu belum pernah megang lagi.

Leave a Reply