Skip to content

Conversation

@allanjoseph98
Copy link
Member

Closes #1662

.orElse(get("fen"))
.map(Fen.Full.clean)
val parsed960: Option[Fen.Full] = input
.ifTrue(variant.chess960)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this takes the FEN input, if the variant is chess960

val parsed960: Option[Fen.Full] = input
.ifTrue(variant.chess960)
.orElse(get("position"))
.flatMap(_.toIntOption.flatMap(Chess960.positionToFen))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then, if position isn't defined, it attempts to convert the FEN into an Int?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping .map(Fen.Full.clean) on line 38 would help prevent that, as scala will then refuse to convert a Fen.Full to an Int

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to account for /chess960?poisiton={num} as well as /chess960/positionNum like we allow for fen. But I realise that was probably unnecessary

Comment on lines 45 to 48
Chess960.positionNumber(inputFen | variant.initialFen)
) // no input fen or num defaults to standard start position
)
val decodedFen: Option[Fen.Full] = chess960PositionNum.flatMap(Chess960.positionToFen).orElse(inputFen)
Copy link
Member Author

@allanjoseph98 allanjoseph98 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow /chess/960?position={num} or /chess960/{fen} (which could be a starting fen). Like we currently do while linking to a start position. That should probably also be changed to the num format for brevity.

But the fentoposition followed by the positiontofen doesn't feel right to me.

@ornicar ornicar merged commit bdb6d62 into lichess-org:master Mar 24, 2025
4 checks passed
@allanjoseph98 allanjoseph98 deleted the analysis-960 branch April 1, 2025 15:35
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 this pull request may close these issues.

Chess960 analysis starting position support

2 participants