Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't setup initial fen without king #413

Open
snk-js opened this issue Jun 1, 2023 · 2 comments
Open

can't setup initial fen without king #413

snk-js opened this issue Jun 1, 2023 · 2 comments

Comments

@snk-js
Copy link

snk-js commented Jun 1, 2023

Hi I need a slight parameter to setup the board without the king, for custom boards purposes, how can I achieve that?

Error: Invalid FEN: missing white king```
@jhlywa
Copy link
Owner

jhlywa commented Jun 3, 2023

Illegal FEN is currently not supported. A temporary work-around would be to use .remove to remove the king after calling .load with valid FEN.

I may entertain the idea of adding a {strict: false} option to .load to bypass the FEN verification.

@snk-js
Copy link
Author

snk-js commented Jun 4, 2023

Hey I made changes to fix this without breaking changes, added a test too, you can find the PR here #414

now we can bypass any rule than we want altogether within an array:

test('non-strict fen validation parameter (FEN with no kings)', () => {
  const noKingFen = '8/8/8/8/4R3/8/8/8 w - - 0 1'
  // chess: Chess(fen, config: { bypass: number[] }) -> Chess
  // strict is false will by bypass the 4th to 11th checks in validateFen

  // 1st criterion: 6 space-seperated fields?
  // 2nd criterion: move number field is a integer value > 0?
  // 3rd criterion: half move counter is an integer >= 0?
  // 4th criterion: 4th field is a valid e.p.-string?
  // 5th criterion: 3th field is a valid castle-string?
  // 6th criterion: 2nd field is "w" (white) or "b" (black)?
  // 7th criterion: 1st field contains 8 rows?
  // 8th criterion: every row is valid?
  // 9th criterion: is en-passant square legal?
  // 10th criterion: does chess position contain exact two kings?
  // 11th criterion: are any pawns on the first or eighth rows?

  const chess = new Chess(noKingFen, {
    // if not strict, we don't need to check the remaining criterions
    bypass: [4, 5, 6, 7, 8, 9, 10, 11],
  })
  expect(chess.fen()).toBe(noKingFen) // success
})

@jhlywa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants