KingHunt
Uneasy lies the head that wears a crown.
– Shakespeare, Henry IV Part II
I wanted to write an app for FirefoxOS.
- It would help me sharpen my mobile development skills;
- I could learn more about AngularJS;
- I own a Firefox phone, and wanted to learn its API.
I decided to write a chess puzzle app. The parts were all out there already. Chess.js enforces legal moves, and detects check, checkmate, and draw. ChessboardJS provides the UI: the pieces, the board, the drag-n-drop. I found a large collection of puzzles at Yet Another Chess Problem Database. I contacted Dmitri Turevski at the site and confirmed that I could use the problems in my app, and he very graciously agreed. Dmitri also mentioned I should include the problem’s author with the problem, and I followed that advice.
So with all the pieces lined up, the problem was mostly a matter of wiring everything together. Here is what the app does:
- Loads a default “book” of about 200 problems.
- You move the pieces for both sides looking for a solution to the problem in the stipulated number of moves.
- When you are satisfied that you have solved the problem, then you can mark the problem solved. The app stores the problems you have solved so that you may filter them out when browsing the list, or moving from one problem to the next.
- You can undo moves, or reload the original position. You can also navigate to the next or previous problem.
- The app does not require network access, it works entirely offline.
What the app doesn’t do (yet):
- There is no AI, so you gotta find the best moves for both sides. I think this is reasonable for this type of problem which is training you to explore lines from both sides point of view. On the other hand, I may add an AI mode to try and find the defender’s optimal line in future.
- You can’t load other books of problems. I really want to add this feature. The book is just a JSON file, so it should be straightforward to integrate that. But I haven’t had time to look into it yet.
- I would also like the ability to use more problem types than just “mate in N” problems, e.g., general tactical studies, endgames, etc.
Despite the “work in progress” state that the app is in, I submitted it to the Firefox Marketplace. I found out a few days ago that my application KingHunt was accepted. Although it says it’s just for FirefoxOS, it should work in any modern browser. But I have only tested it in FirefoxOS.
You can check out the source code at the KingHunt GitHub repository.
Buzz de Cafe
28 November 2013