Comments (3)
OK, I got it, it is described in the documentation of chess.js, under .move(move, [ options ])
about the sloppy
flag, is written:
// correctly parses incorrectly disambiguated moves
chess = new Chess(
'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7'
)
chess.move('Nge7') // Ne7 is unambiguous because the knight on c6 is pinned
// -> null
chess.move('Nge7', { sloppy: true })
// -> { color: 'b', from: 'g8', to: 'e7', flags: 'n', piece: 'n', san: 'Ne7' }
So move Nge2 is wrong because it is unambiguous, correct would be "Ne2".
But I have adjusted something, I have now also included the "sloppy" flag in the constructor of Pgn, so now it works if you use new Pgn(sloppyPgn, {sloppy: true})
.
from cm-pgn.
Yes, thanks for reporting. This looks like a problem of chess.js, because, when I initialize chess.js with this fen:
r1bqk2r/pppp1ppp/2n2n2/4p3/1bB1P3/2NP4/PPP2PPP/R1BQK1NR w KQkq - 1 5
chess.js returns "null", when moving "Nge2":
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.3/chess.min.js"></script>
<script>
let chess = new Chess("r1bqk2r/pppp1ppp/2n2n2/4p3/1bB1P3/2NP4/PPP2PPP/R1BQK1NR w KQkq - 1 5")
let result = chess.move("Nge2")
console.log(result) // is null
</script>
What do you think, did we both miss something or is it a failure in chess.js?
from cm-pgn.
That worked for me! Thanks!
from cm-pgn.
Related Issues (15)
- Add Multiple variations to history fails with invalid move error HOT 1
- How to render a pgn including subvariations HOT 2
- Support PGN database files with multiple PGNs HOT 1
- Fix failures in the unit tests
- Failed to resolve import HOT 2
- Parsing fails on PGN with multiple comments after final move HOT 3
- How to run unit tests? HOT 1
- commentMove not set on first move in history if it's not the first move in the game
- The first move of a variation over-writes the previous move's "next" pointer to point to the alternate line rather than its own line HOT 1
- Variation on White's first move
- Allow rendering of PGNs with variations
- Documentation HOT 1
- Can this give the FEN of a specific move? HOT 1
- Uncaught peg$SyntaxError HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cm-pgn.