Delete pieces that are not present in current FEN string. Go through all the pieces on board, calculate their new locations and start animating.Find the squares to move to, and mark the pieces that must travel to these squares.Go through all the squares, mark empty cells, pieces that are already in place, and pieces that need traveling (animating).The algorithm of this method consists of 4 phases: Second important detail is the AnimateTransition - method of PgnCtrl object (JSON format is used). I found a wonderful example of a Timer at and tweaked it slightly to correspond to my needs. Each must work separately and must not interfere the others. ![]() If, say, 10 pieces must simultaneously travel to 10 different onboard positions, then 10 MoverTimer objects must be created. This happens when you select the arbitrary move from the list of moves at the right side of the control. One of the most interesting things in this project is the MoverTimer - JavaScript object (prototype function) that allows you to simultaneously animate many images (pieces on the chess board). It is quite another story, the story that can arouse some inspiration. Yes, I know that this problem is solved, now anyone can play chess through the web, but using your own code (for the purpose of smoothly animating chess pieces) makes a difference. I plan to use this code in application that allows to play chess with my friends by the net. You also may add some of your favourite chess games texts to the existing list and use this application to spend a good time. ![]() You may use the script of this project to develop a web application that takes PGN-text from the user and gives him a possibility to watch the animation of any chess game, navigate through the moves, analyze the game and learn to play chess (the best game to develop one's mind). I risk to make a mistake, but it seems as if they all were created by hand (huge efforts!). The best PGN-viewer I know ( ), uses predefined FEN strings for all the moves. The last feature is called pawn promotion. You must consider: irregularity (pawn on e2 may go to e3 or e4, but after that it may advance only by one square), en passant capture and possibility to transform to any piece (rank) on the last row. The greatest troubles are brought by the pawns' moves. The problem does not seem very hard, but if you take into account that a move may have different formats depending on the current situation ( Nc3, Nec3, N2c3, Nxc3, Nexc3, N2xc3, Nc3+, Nec3+, N2c3+, Nxc3+, Nexc3+, N2xc3+), then you would realize that there is something to do here. For instance, suppose that previous FEN-like string is: I mused the problem for several years and only now (in Christmas holidays), I found some time to implement the algorithm of calculating a FEN-like string (describing a chess position after a current move) out of the previous FEN string and current move notation.įEN - Forsyth–Edwards Notation ( FEN). When I realized the power of JavaScript and necessity to use it in modern web applications, I selected the problem of PGN-Viewer as a starting point. ![]() To test this assertion, one may try to develop some "useful" application. They say that JavaScript supports object oriented style. ![]() This style of programming looks awkward and does not arouse inspiration. But examples I stumbled upon were written using document.write("Some HTML") operators. There are many chess PGN-viewers written in different languages and JavaScript is among them. Portable Game Notation (PGN) is used to record chess games' moves and comments (e.g., 1. One might argue the assertion, but I believe that any software developer must like chess. I am sorry, but that was an old, buggy version. Please, download this (corrected) version of ChessViewer if you have downloaded it earlier (January 4). Download ChessViewer_HTML_and_Script_ - 510.5 KB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |