Skip to content

Conversation

@john-sp
Copy link
Member

@john-sp john-sp commented Nov 2, 2025

This PR introduces a new page for generating custom chess odds challenge links.

Implementation Notes

  • While we generally avoid inline CSS, this page contains highly specialized styling that's unique to this component and unlikely to be reused elsewhere Added functionality for this
  • FRC functionality is included but hidden initially as the Odds team isn't ready for this feature yet

Direct link to page added: https://pr182-draft.lc0.org/play/odds/

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@mooskagh
Copy link
Member

mooskagh commented Nov 2, 2025

  • "Play as black" should have "(piece odds)" comment, and "play as white" is "(piece and move odds)"
  • Usually animation on hover means that the pointer is in the active range and if you click, something happens. Here, the entire "card" animates, but to select checkbox you need to move it more precisely. So it makes sense to either remove that completely, or make the clickable area much larger.
  • I'm not sure whether "remove pieces" or "pieces on board" with all checkboxes originally there is better (or maybe show actual rank of a chess board instead)

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@john-sp john-sp marked this pull request as ready for review November 2, 2025 23:35
Copilot AI review requested due to automatic review settings November 2, 2025 23:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a dynamic odds selector feature for generating custom chess odds challenges on Lichess. The implementation introduces a Hugo shortcode system with page-specific CSS/JS loading capabilities.

Key Changes

  • Implements a flexible asset loading system using Hugo's Page.Scratch to load CSS/JS on-demand
  • Adds an interactive odds selector UI with support for standard and Fischer Random Chess (Chess960)
  • Includes comprehensive validation logic for valid piece removal combinations

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
themes/leela/layouts/_partials/head/js.html Adds dynamic JS loading from js/additional/ based on Page.Scratch
themes/leela/layouts/_partials/head/css.html Adds dynamic CSS loading from css/additional/ based on Page.Scratch
themes/leela/layouts/_partials/head.html Passes requiredCSS/JS to partialCached calls
themes/leela/assets/js/additional/odds.js Complete odds selector logic with FEN generation and validation
themes/leela/assets/css/additional/odds.css Styling for the odds selector interface
themes/leela/assets/css/icons.css Adds external-link icon definition
layouts/shortcodes/odds-selector.html Hugo shortcode that registers assets and renders the UI
content/play/odds.md Page content invoking the odds-selector shortcode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Nov 2, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@john-sp
Copy link
Member Author

john-sp commented Nov 2, 2025

I'm not sure whether "remove pieces" or "pieces on board" with all checkboxes originally there is better (or maybe show actual rank of a chess board instead)

While showing the actual board rank would be nice visually, for now I'm concerned it would add significant code complexity (or a lot of heavy dependency for a small visual improvement). I think checking the removed pieces works better conceptually since we're showing what Leela is giving up. This which aligns with the bots names ("LeelaKnightOdds", "LeelaQueenOdds", etc.) to indicate which piece is missing.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@Naphthalin
Copy link
Contributor

Hey :) Great work, thanks a lot! I tested the generated links with a few games against https://lichess.org/@/RefuteMyGambit and it seems to work as intended. I have a few comments about some design choices from my (brief) testing:

  • I somewhat agree with distinguishing between the two rooks, but for bishop and knight I would either prefer a "remove 0, 1, 2", or just renaming them to "knight 1" and "knight 2".
  • FRC will be a separate bot, so it will require generating links to a different name (but I guess you're already handling which odds go to which bot?)
  • most important: clicking "Generate Link" again should IMO generate a new FRC position.

@john-sp
Copy link
Member Author

john-sp commented Nov 5, 2025

I somewhat agree with distinguishing between the two rooks, but for bishop and knight I would either prefer a "remove 0, 1, 2", or just renaming them to "knight 1" and "knight 2".
@Naphthalin

I have the side mostly for non-FRC chess, but I understand for FRC how it can be confusing. I disagree with "remove 0, 1, 2", the essentially a slider, to determine how many of each piece to remove, I think the user should have some choice in which one to remove.

Here is a proposal from Gemini on labels to use:

Piece FRC Disabled (Current) FRC Enabled
Bishops Queen-side / King-side Light-Squared / Dark-Squared
Knights Queen-side / King-side Left / Right

Note the Left/Right also could be confusing when you flip the side the user is on, and is it the User's or Bot's left and right (I am OK changing that to Knight 1 and Knight 2)

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@Naphthalin
Copy link
Contributor

Naphthalin commented Nov 7, 2025

Thanks a lot for the update!

  • The random regeneration of FRC positions, including providing the number, looks great!
  • I like the FRC distinction of the bishops and the rooks, because in both cases it helps the player to conceptualize the additional piece odds intricacies of the position relevant for middle/endgame.
  • There is one error: when removing a rook in FRC mode, your script removes the castling for both rooks on that rank, not just the actual removed one. In regular mode, this works out fine. seems to work fine now, maybe I had an older version of the site?
  • Obviously, the restrictions for regular chess shouldn't apply for FRC, instead only the set of removed pieces should matter.

@mooskagh
Copy link
Member

mooskagh commented Nov 7, 2025

I didn't mean implementing/using full chess board, just aligning checkboxes horiozntally and using chess pieces, like this:

image

https://claude.ai/public/artifacts/0be20e1a-cb81-4255-8eee-0b3f04688ff1

@mooskagh
Copy link
Member

mooskagh commented Nov 7, 2025

Or maybe even like that (not sure about blue color)

image

https://claude.ai/public/artifacts/f2102892-be21-4e79-a318-9384512635db

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@Naphthalin
Copy link
Contributor

Thanks for the update! When reloading the page to get the update, I saw that reloading the page with the FRC checkmark set will show the regular labels for the knight/bishop boxes, only after taking it away and setting it again the FRC specific labels are displayed.

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🚀 Draft Preview: https://pr182-draft.lc0.org/

@john-sp
Copy link
Member Author

john-sp commented Nov 7, 2025

Thanks for clarifying on the design @mooskagh! The chess piece visualization is definitely appealing and intuitive for standard chess positions.

However, there are some difficulties with implementing it this way.

  1. With Fischer Random Chess, the piece arrangement is randomized. Displaying an accurate board would require dynamic piece rearrangement that matches the actual FEN (sounds like some fun CSS animations would be possible). The mirroring of the pieces colors could be an easy CSS change, so I am not worried about that.

  2. Since we generate a random FRC ID on each generation, showing a static board could mislead users about what position they'll actually get. If we maintain the visual as the standard setup, there may be confusion when they get a completely different arrangement.

While we could implement this visual approach for standard chess only, maintaining two different UI paradigms would complicate the codebase unnecessarily at this stage.

For now, I'd like to keep the current form-based approach to ensure accuracy across all game modes, but I'd be happy to revisit this approach later.

@Naphthalin
Copy link
Contributor

One possibility for 2. could be to show the 7 removable pieces in descending value order if in FRC mode, that way it's clear it doesn't represent the actual position.

@github-actions
Copy link

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

🚀 Draft Preview: https://pr182-draft.lc0.org/

@github-actions
Copy link

🚀 Draft Preview: https://pr182-draft.lc0.org/

@Naphthalin
Copy link
Contributor

Perfect, FRC restrictions look good now! I obviously didn't check every possibility, but from what I could see it now matches what we decided for the FRC odds bot to accept. I also checked that it indeed refuses to accept 518. Thanks a lot for the work!

@john-sp john-sp merged commit 13238bb into LeelaChessZero:master Nov 22, 2025
1 check passed
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.

3 participants