pgn-viewer icon indicating copy to clipboard operation
pgn-viewer copied to clipboard

Guess the Move

Open steinitz-zz opened this issue 9 years ago • 18 comments

Hi mliebelt,

I thought you might be interested to know that I've used your fine work as a foundation for a Guess The Move prototype. I integrated PgnViewerJS into Meteor (a story in itself), added some enhancements and deployed it (just for fun) to chesstraining.meteor.com

Note that it doesn't work on the first move (e4), after that it's ok. I'll fix that soon.

Thanks for making public your excellent work. I'd be interested in your comments. You're welcome to the modified code.

All the best,

Steve

steinitz-zz avatar Jun 08 '15 02:06 steinitz-zz

Nice, my first user! So keep me informed who your work is going. Are your changes available anywhere? You have not forked my repo, so I don't have the chance to see your changes. I will look at it as soon I see your ideas in code.

And hopefully I will finish the work (edit mode is not finished yet) this year, had too much work lately in the company (and too many hours spent on chess.com and lichess.org).

mliebelt avatar Jun 08 '15 11:06 mliebelt

Ah, good, your first user. I like it.

I am happy to provide the changes directly to you, if you are interested. You may want to use them. However, I've made many, many formatting changes, so I'm not sure if a fork or pull request would be appropriate. Specifically, I can read and understand code better when it's like this:

function ()
{
    if (condition)
    {
        console.log ("1");
    }
    else
    {
        console.log ("2");
    }
}

but many people find that annoying, or worse -- I saw someone propose putting people to death who format like I do :)

Feel free to send me a private email: steve at dtctc dot com

steinitz-zz avatar Jun 08 '15 12:06 steinitz-zz

I was able to debug the Guess the Move issue with the first move (the solution seems slightly drastic :) ). The fixed version is now running at chesstraining.meteor.com . Again, I'd be delighted to provide the entire Meteor project directly to you. Feel free to contact me at steve at dtctc dot com If you are interested. In the meantime, you can download the modified pgnvjs.js here: https://gist.github.com/steinitz/7ddcbbd8fdd9f2f436b3

The project is too much changed (for Meteor) for a pull request. I suppose I could make a special project for the purpose of a pull request, but perhaps it would be better if you were to look over my changes first. My non-standard (but beautiful :) ) formatting, the fact that Meteor has problems with 'use strict' and other issues may make a pull request inappropriate. I welcome your thoughts.

In any case, please accept my sincere appreciation for your fine work.

steinitz-zz avatar Jun 09 '15 01:06 steinitz-zz

Hi,

I have noticed that the pgn of, say Bxb4 is displayed as Bb4. I'd like to have the 'x'. Did you intentionally remove the x or is it an artifact of chess.js or pgn.js?

Thanks for any hints.

Cheers,

Steve

ps. I have a much changed version of pgnvjs.js for you if you are interested.

steinitz-zz avatar Aug 19 '15 03:08 steinitz-zz

Hi,

I made two simple mods to pgn.js to add 'x' for captures. Here are the details.

In eachMoveVariation, save the flags from chess.js:

...
var fen = game.fen();
move.fen = fen;
move.notation.flags = pgn_move.flags; // SJS - save this to know to draw a capture symbol, 'x'.  

$.each (move.variations,
...

Then modify san() as follows:

var san = function (notation)
{
    if (typeof notation.row == 'undefined')
    {
        return notation.notation; // move like O-O and O-O-O
    }
    var fig     = $.t(notation.fig);
    var capture = notation.flags == game.FLAGS.CAPTURE ? 'x' : '';   // SJS - add 'x' for captures 
    var disc    = notation.disc ? notation.disc : "";
    var check   = notation.check ? notation.check : "";
    var prom    = notation.promotion ? notation.promotion : "";
    return fig + disc + capture + notation.col + notation.row + prom + check;  // SJS - capture
};

Cheers

steinitz-zz avatar Aug 20 '15 04:08 steinitz-zz

See issue #5 which I have added to separate this issue from the missing capture symbol. I have taken your input, and searched for the "best" place to insert the right code then. Will make some tests, and then publish my changes soon.

mliebelt avatar Sep 07 '15 09:09 mliebelt

Hi @mliebelt,

Thanks for sharing such great stuff. Are you still working on this issue? I would like to integrate such behavior into Anki (user guessing the next moves which is noted in pgn and computer replying with the next move in the pgn).

There are some working solutions for Anki, but rather old or buggy.

khoramshahi avatar Jun 25 '20 16:06 khoramshahi

@khoramshahi Do you have a reference to Anki, I never heard of it. I cannot say when I will have time to work on that issue, but the requirements should be easy:

  • No variations, only one line.
  • Don't show any moves at the beginning.
  • Allow the user to make a move, and deny it, if it is the wrong one.
  • If the move is correct, play automatically the move of the other side, and wait for the next move.
  • Until last move given is found
  • (optional) Give hints, if wished by user.
  • (optional) Allow to solve (partially).

Am I missing anything here?

mliebelt avatar Jun 27 '20 15:06 mliebelt

There is a great tool to generate Lichess style PUZZLES from PGN file, which works really well. https://github.com/linrock/chess-puzzle-maker The puzzle output from this is the PGN file starting with FEN position and the first move is basically a BLUNDER, which refutation should be found as a puzzle.

So, all your @mliebelt assumptions, like "No variations, only one line" holds, but moreover:

  • board should be initiated at the postition after first move
    • and the last move must be highlighted
  • the orientation of the board must match the side which is to solve the puzzle

Dunno, what is the state of this issue, the requirements looks really straightforward.

I am absolutely new to PgnViewerJS, so I can easily misinterpret the ideas. If I decide to implement it, am I right the new modus, like pgnPuzzle, is to be introduced? image

Bebul avatar Mar 19 '21 19:03 Bebul

@Bebul Thank you a lot for investing time in that topic. I think you are right. Here is what I would do if I would tackle that issue:

  1. Create a new mode pgnPuzzle.
  2. Decide what is needed: board, parts of editing (only making moves, not recording new ones), mostly viewer mode.
  3. Take your idea from above: pgn has to be one straight line (variants only, if you want to include feedback to wrong moves, see studies in Lichess, interactive excercise), start after first move.
  4. Necessary changes: show only moves made and accepted; have a feedback for success.

The changes will be only in the viewer module, no changes to reader.

I wish you good luck in your challenge!

mliebelt avatar Mar 20 '21 08:03 mliebelt

After finishing the puzzle I have disabled mooving pieces, so the chessground is frozen, unless user returns by prevMove. Implementation looks good, because using hasMode('puzzle') makes changes impossible to break other functionality which is most important.

But I must still do:

  • disable showing moves (or moves after current puzzle progress)
  • create progress info instead with something like "puzzle failed" - "congratulation" - "in progress"
  • maybe support of more puzzles in PGN with possibility to navigate nextPuzzle

What I dunno is creating documentation and examples. I have puzzle.html as example with one generated by https://github.com/linrock/chess-puzzle-maker

I am looking forward to finishing it and making PULL Request soon.

Bebul avatar Mar 22 '21 10:03 Bebul

First of all thank you @mliebelt for this wonderful package and all your work. I have tried to contribute by implementing a guess-the-move mode. I am happy to hear any feedback and further help on this issue as well as on other parts of the package.

ppeloton avatar Mar 06 '24 19:03 ppeloton

@ppeloton Thank you a lot for providing that functionality. I have to check it (hopefully on weekend), but on first sight it should be doable. If it seems to be ok, I will create a new version that includes your new mode, and check as well the documentation how that could be expanded. If that is all ok, I will publish a new version that includes your changes.

mliebelt avatar Mar 07 '24 08:03 mliebelt