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

Suggestion to add Move.IsPromotion and Move.IsEnpassant #20

Open
shishiraiyar opened this issue Jan 24, 2024 · 3 comments
Open

Suggestion to add Move.IsPromotion and Move.IsEnpassant #20

shishiraiyar opened this issue Jan 24, 2024 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@shishiraiyar
Copy link

I found a way to achieve this
move.Parameter is MovePromotion returns true when the move is a promotion.

And to find out what the promoted piece is, I do

Piece p = new Piece(move.Parameter.ShortStr[1]);
Console.WriteLine(p.Type);

And to check whether a move is EnPassant, I do
move.Parameter is MoveEnPassant

I guess this works since a move can't be both En Passant and promotion at the same time. But it's not very straightforward.

It would be nice if the library supported
Move.Promotion which returns the promoted piece or null when there is no promotion.

Also consider adding Move.IsEnPassant and Move.IsCastling

Anyways, thanks for the amazing library.

@shishiraiyar shishiraiyar added the enhancement New feature or request label Jan 24, 2024
@Geras1mleo
Copy link
Owner

Geras1mleo commented Jan 25, 2024

I like the idea! Will do this in future versions...
Thank you for your feedback!

@AlphaYui
Copy link
Contributor

First of all, thanks for this awesome project! Also thanks for making this specific issue, I had the exact same problem and was happy with the solution shown here.

Knowing the solution, I'm honestly quite happy with the current implementation. You can elegantly check the type of move with an is statement and cast it to the specific type (e.g. MovePromotion) to get detailed information (e.g. to which piece the pawn is being promoted). For me this is mainly an issue of documentation. The Parameter property is named very generically and isn't found in the main documentation.

So my suggestion would be to rename the Parameter property to something more intuitive like "SpecialMoveDetails", add a more detailed description than "Move additional parameter", and include a short example in the main documentation on how it can be used to check for move type and get the move details from it.

@Geras1mleo
Copy link
Owner

@AlphaYui thank you for the feedback, I will make sure the docs are more descriptive

@Geras1mleo Geras1mleo added the documentation Improvements or additions to documentation label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants