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

Not possible to set custom premove squares #271

Closed
melgrove opened this issue Jul 9, 2023 · 0 comments
Closed

Not possible to set custom premove squares #271

melgrove opened this issue Jul 9, 2023 · 0 comments

Comments

@melgrove
Copy link
Contributor

melgrove commented Jul 9, 2023

Problem

state.movable.dests takes the Dests map, and it's possible to set custom piece movement rules by passing a custom map with .set(). However, state.premovable.dests takes Key[] and just stores the possible premove squares for a particular selected square. These values are calculated here

state.premovable.dests = premove(state.pieces, key, state.premovable.castle);

and are hardcoded to use the rules of chess (premove.ts). It's not possible to set custom premove squares like state.movable.dests using .set() or mutating cg.state directly because the rules of chess are automatically used in line 206 on every selection.

Solution

Make a new optional property state.premovable.customDests which uses the Dests format like state.movable.dests. When this property is present, it is used to set state.premovable.dests instead of calling premove() and using the rules of chess. To use custom premoves you can use .set() to set premovable.customDests.

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

No branches or pull requests

2 participants