Coder Social home page Coder Social logo

Comments (3)

shaack avatar shaack commented on June 4, 2024 1

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.

shaack avatar shaack commented on June 4, 2024

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.

joshrouwhorst avatar joshrouwhorst commented on June 4, 2024

That worked for me! Thanks!

from cm-pgn.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.