Open yukitakahashi1 opened 4 years ago
Hi Yuki,
it is definitely possible to implement the solution algorithms you link to in Javascript. The SliderPuzzle class includes a property "board" which represents the board as a two-dimensional array (like I define it in Python). Every move changes this internal representation, so it should be up to date at any time. This is what you could base the calculation of solution steps on.
Basically, you would react to the "move" event and calculate the necessary steps and compare it to the steps it took before that move.
Unfortunately, I do not use this puzzle at all, so I cannot really spend too much time developing it further. Seeing that you already have the solution algorithms ready, I am sure you can incorporate it in the Javascript code yourself.
Thank you Christian! Then I'll try by myself. Is the only file I have to modify is Game.html (in addition to defining an appropriate variable in models.py and call it in get_form_fields in pages.py)?
Hi Christian, I want to determine whether a given move is good or bad based on the number of minimum moves to solve the puzzle. A good move is a move that decreases the number of minimum moves, and a bad move is a move that increases the number of minimum moves.
I've modified python codes from this website (http://www.openbookproject.net/py4fun/tiles/tiles.html) which return the number of minimum moves for a given board (attached - both files should be in the same directory). I might be able to do this using
move_history
by recovering the board at each move from the initial board and comparing the number of minimum moves before and after the move, but it'll be a long code. Would it by chance be possible to incorporate this in the javascript, so that it returns whether a given move is good or bad (in addition topuzzle_solved
andmove_history
)?Archive.zip