Comments (3)
Hey @sombor-shuffle,
unfortunately, we don't have a documentation about scalachess. Can you please tell us about your usecase with scalachess, so we can help?
In the mean time, please refer to tests, lila/lila-ws for some references. I also have some standalone examples here:
- https://github.com/lenguyenthanh/scalachess-tests
- https://github.com/lenguyenthanh/chess-position-generator
- https://github.com/lenguyenthanh/scala-examples
Please take a look!
Also you can join our discord and we ask there: https://discord.gg/lichess
from scalachess.
Hello, @lenguyenthanh!
Apologies for not writting back faster. Thank you for helping me out!
I wanted to highlight all legal moves (with the rules of antichess) for a selected piece, as seen below:
My solution ended up using chessops, instead (roughly paraphrased from a component in my Next.js project):
import { Chessground } from 'chessground';
import { chessgroundDests } from 'chessops/compat';
import { Antichess } from "chessops/variant";
import { parseSquare } from 'chessops/util';
import "chessground.base.css";
import "chessground.brown.css";
import "chessground.cburnett.css";
// Create a container for chessground.
const container = document.createElement("div");
document.body.appendChild(container);
// Give it some size. Otherwise it won't be visible.
container.style.width = "500px";
container.style.height = "500px";
// Handles logic and initializes to starting position.
const ops = Antichess.default();
// Chessground config file:
const config = {
movable: {
color: "white",
// Only the moves given below are allowed to be made.
free: false,
// chessops has a built-in function that can be assigned to dests.
// This will highlight all legal moves.
dests: chessgroundDests(ops),
}
}
const cg = Chessground(container, config);
// Can't be set in config as it references cg (which won't exist yet)
cg.set({
movable: { events: { after: handleMove(cg, ops) } }
});
// Called when a move is made.
function handleMove(cg, ops) {
return (orig, dest) => {
// Converts e1 - h8 to 0 - 63, for chessops.
const from = parseSquare(orig), to = parseSquare(dest);
if(from && to) {
const move = { from, to }
// Updates the internal board of chessops.
ops.play(move);
// Updates Chessground with new active color
// and new legal moves.
cg.set({
turnColor: ops.turn,
movable: {
color: ops.turn,
dests: chessgroundDests(ops)
}
});
}
}
}
Thank you for linking me these resources. I'm very interested to learn more about how Lichess works and will dive into them. Appreciate it king!
from scalachess.
that's great too hear! good luck on your adventure!
from scalachess.
Related Issues (20)
- Rename Paulsen Variation => Taimanov Variation?
- test failures (ForsythTest, HashTest)
- Fix En Passant in Horde for pawns in rank 1 HOT 1
- Use Scalacheck for testing pgn parser HOT 4
- Reject pgn files that have invalid tags format HOT 1
- PGN cleanup may break comments HOT 1
- Master doesn't currently compile HOT 2
- variant: DFRC HOT 1
- timeout vs insufficient material in NvN antichess HOT 1
- Publish in a sbt repository HOT 1
- Expose situationAfter via MoveOrDrop HOT 5
- Rename `Pos` to `Square` HOT 2
- Support impossible checks when validate position HOT 14
- Migrate specs2 to munit HOT 3
- Consider if we should stop using `TotalWrapper` for `OpaqueBitboard` for performance gain HOT 3
- rename `OpeningFen`
- Regression with regard to castling rights of inner rooks HOT 3
- Make all endgame drills same color HOT 1
- Generalize Pgn
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalachess.