Open undera opened 5 years ago
Nice idea! I never had thought that this could possibly work. The reason is, that the library used for playing and controlling chess is (as I think) not able to check Chess960. I will check that, and if it is possible will add the option to use the PgnViewerJS for it.
See https://github.com/jhlywa/chess.js/issues/122 for an issue in the library I am using. There is the mentioning of a branch that includes a (partial) implementation, I will give it a try. But this "we need X-FEN instead of FEN" frightens me, that does not sound easy ...
Found the castling rules here, they seem to be simple. Don't know how easy it would be to implement them generally in chess.js, however.
I have just added (in a branch) the version of sesse instead of the original one, and added an example to show the effect.
You have to do the following:
clone https://github.com/mliebelt/PgnViewerJS.git
.cd PgnViewerJS
git checkout ticket-121
npm install
grunt dev
npm install -g http-server
(to have a local web server, necessary to run the examples).http-server --cors
, this will display an URL (with port) that servers that directory. This is named <URL>
in the following.<URL>/examples/tickets/ticket121.html
I have to check the changes of course if it is possible to include them into main line of PgnViewerJS. If there is not too much risk, I will do that, and create a new release for easier user of PgnViewerJS (with support for Chess960).
Playing (in edit mode), I have seen that I have no support for castling that works well. That means, the king is set correct, but the rook not. And I have the problem that castling is sometimes not even possible. So in your game (with Rb1 and Kd1), moving the king to c1 is ambiguous: it could be castling, and it could be a normal move. So playing the moves with pgnView would be ok, but not using pgnEdit to create a game for Chess960.
Of course this is only a first draft. There should be an attribute for it (variant: "chess960"
, default: "chess"
), the read of the TAG [Variant "Chess960"]
, but this is all trivial in comparison to the change of castling rules.
Thanks for all your research. Currently, I'm only using PGNView and castling in PGN is unambiguous with special O-O
-kind declarations.
Are you able to build it for yourself?
I'm not big JS guy. When I'm using it, I generated the config via web UI and downloaded the release and use dist
directory.
Sorry, I don't have npm
or grunt
on my machine.
Well, I made it to build dist
somehow, played ticket121.html and it worked as expected.
Great! So you have at least a version that works for you, and I have some more time to do some checks and to ensure that nothing else will break then.
Yes, thank you very much for your help.
I have just added (in a branch) the version of sesse instead of the original one, and added an example to show the effect.
You have to do the following:
- Clone the repository:
clone https://github.com/mliebelt/PgnViewerJS.git
.- Go into the directory of the repository:
cd PgnViewerJS
- Checkout branch ticket-121:
git checkout ticket-121
- Run
npm install
- Run
grunt dev
- Run
npm install -g http-server
(to have a local web server, necessary to run the examples).- Run
http-server --cors
, this will display an URL (with port) that servers that directory. This is named<URL>
in the following.- Open the browser at
<URL>/examples/tickets/ticket121.html
- Play through the game (including castling).
I have to check the changes of course if it is possible to include them into main line of PgnViewerJS. If there is not too much risk, I will do that, and create a new release for easier user of PgnViewerJS (with support for Chess960).
Can't find the branch ticket-121
I have just added (in a branch) the version of sesse instead of the original one, and added an example to show the effect.
You have to do the following:
- Clone the repository:
clone https://github.com/mliebelt/PgnViewerJS.git
.- Go into the directory of the repository:
cd PgnViewerJS
- Checkout branch ticket-121:
git checkout ticket-121
- Run
npm install
- Run
grunt dev
- Run
npm install -g http-server
(to have a local web server, necessary to run the examples).- Run
http-server --cors
, this will display an URL (with port) that servers that directory. This is named<URL>
in the following.- Open the browser at
<URL>/examples/tickets/ticket121.html
- Play through the game (including castling).
I have to check the changes of course if it is possible to include them into main line of PgnViewerJS. If there is not too much risk, I will do that, and create a new release for easier user of PgnViewerJS (with support for Chess960).
@mliebelt Thank you, also need this feature, but I can't find branch ticket-121, had it been merged into the main branch?
@intothephone Sorry for the inconvenience, but I did a trial ~4.5 years ago, that never made it into any release. The commit is there, you can see what I tried here. See the commit on Github. Hopefully that is sufficient to understand the idea. As you may see, the ticket is open ...
Got it, thank you very much! Your project is great!
@intothephone Sorry for the inconvenience, but I did a trial ~4.5 years ago, that never made it into any release. The commit is there, you can see what I tried here. See the commit on Github. Hopefully that is sufficient to understand the idea. As you may see, the ticket is open ...
@mliebelt I've tried your commit, it works perfectly for short castle, but not work for long castle: O-O-O, take following pgn as example(Ding Liren VS Carlsen at 2024 Freestyle Chess GOAT Prel):
O-O is ok at step 17, but fails at step 23 for O-O-O
I know it has been long years for this commit, and this also should be a feature request for the backend chess.js lib, but I would be appreciate for your help if you can make long castle works too.
Anyway, great work, thanks again!
Hi, I'm applying this nice viewer to Chess960 PGNs. It works well except castling moves, which breaks it with message
No legal move: O-O
.Here is PGN:
Here is my JS code.