jordanbray / chess

A rust library to manage chess move generation
https://jordanbray.github.io/chess/
MIT License
243 stars 55 forks source link

Feature request: easier way to inspect the board, e.g. to_fen() #19

Closed fanzier closed 5 years ago

fanzier commented 5 years ago

It would make debugging way easier if there was a way to convert a Board into a human-readable string or at least a FEN string (which is somewhat human-readable). I think the library once contained a Display implementation for Board but that seems to have been removed.

I would suggest adding a method Board::to_fen(&self) -> String that converts the board to a FEN string but I'm open to other proposals.

jordanbray commented 5 years ago

Yeah. Do you think it's a bad idea to impl Display for Board { ... } where the result is the FEN string? I think that would be the most "sane" implementation.

To put it another way, if you execute println!("{}", board) or format!("{}", board), it "feels" like I should get an FEN string back to me.

fanzier commented 5 years ago

I think a Display impl returning the FEN string would be a good solution. It's standard, compact and contains all the information.

jordanbray commented 5 years ago

impl Display for Board is now completed. Not on https://crates.io/crates/chess/ yet, but should be soon.

fanzier commented 5 years ago

Great, thank you for implementing this! :)

jordanbray commented 5 years ago

Released in 3.1.0.