jhlywa / chess.js

A TypeScript chess library for chess move generation/validation, piece placement/movement, and check/checkmate/draw detection
BSD 2-Clause "Simplified" License
3.72k stars 892 forks source link

Viewable Fallen Pieces #324

Open pragmatech opened 2 years ago

pragmatech commented 2 years ago

Not entirely sure if stating the "fog" that exists – whereby in traditional chess (on a table) I can very well see the stash of "fallen pieces" that have been removed from the game – in the absence of this visual cue, the electronic version suffers due to this inability to confirm and assess what has transpired, etc. Again, if this is orthogonal and/or best addressed elsewhere, my apologies. Nonetheless, any pointers/resources in this pursuit of a robust view to the fallen pieces is appreciated! Darren

santafiora commented 2 years ago

Hello Pragmatech since you have the Movehistory let's look at this 1. c4 c5 2. g3 g6 3. Bg2 Bg7 4. Nf3 Nf6 you could loop through the movehistory and see there is no exchange so on the Documentation Website chess.js look at this const chess = new Chess() chess.move('e4') chess.move('e5') chess.move('f4') chess.move('exf4')

chess.history() // -> ['e4', 'e5', 'f4', 'exf4']

you can se exf4 so you can add this to a counter in a loop for white and black ;-)hope that helps in a way

pragmatech commented 2 years ago

Hey santafiora. Thanks for suggesting an approach, in the quest for viewability of the game's 'fallen pieces' ('captured', 'removed'). I still rate such a basic metric as pretty high in what ought to be part of – what is already a compromise – of playing chess electronically. I suppose high-level players are ahead of this visual assessment of the game's state. However, I think for the less adept, that this part of the UI would have significant impact, aesthetic and otherwise. Alas, being equally so-so in my dev chops, I may not be able to implement your approach, but thank you nevertheless for the suggestion! I'm sort of mystified by this feature's absence, but perhaps someone can point to where visual representation of captured pieces is (besides among wooden pieces on my kitchen table).

santafiora commented 2 years ago

Have a Look @ my project so far on youtube search for "ChessSuite Chessdatabase written in C#" or here is the link https://www.youtube.com/watch?v=Xk8OI5PA9Oo&t=1935s