Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Board.fen() didn't update when ep_square is updated #1134

Open
winapiadmin opened this issue Jan 19, 2025 · 2 comments
Open

Board.fen() didn't update when ep_square is updated #1134

winapiadmin opened this issue Jan 19, 2025 · 2 comments
Labels

Comments

@winapiadmin
Copy link

winapiadmin commented Jan 19, 2025

winapiadmin@ubuntu:~/venv/bin$ source activate
(venv) winapiadmin@ubuntu:~/venv/bin$ python
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import chess
>>> chess.Board()
Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
>>> x=chess.Board()
>>> x.push_san("e4")
Move.from_uci('e2e4')
>>> x
Board('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1')
>>> x.ep_square
20
>>> x.push_san("e5")
Move.from_uci('e7e5')
>>> x
Board('rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2')

OS:

(venv) winapiadmin@ubuntu:~/venv/bin$ neofetch
           `-mddhhhhhhhhhddmss`             winapiadmin@ubuntu 
        ./mdhhhhhhhhhhhhhhhhhhhhhh.         ------------------ 
     :mdhhhhhhhhhhhhhhhhhhhhhhhhhhhm`       OS: Lubuntu 24.04.1 LTS x86_64 
   :ymhhhhhhhhhhhhhhhyyyyyyhhhhhhhhhy:      Kernel: 6.13.0-061300rc1-generic 
  `odhyyyhhhhhhhhhy+-````./syhhhhhhhho`     Uptime: 50 mins 
 `hhy..:oyhhhhhhhy-`:osso/..:/++oosyyyh`    Packages: 2235 (dpkg), 13 (snap) 
 dhhs   .-/syhhhhs`shhhhhhyyyyyyyyyyyyhs    Shell: bash 5.2.21 
:hhhy`  yso/:+syhy/yhhhhhshhhhhhhhhhhhhh:   Resolution: 1440x900 
hhhhho. +hhhys++oyyyhhhhh-yhhhhhhhhhhhhhs   DE: LXQt 1.4.0 
hhhhhhs-`/syhhhhyssyyhhhh:-yhhhhhhhhhhhhh   WM: Openbox 
hhhhhhs  `:/+ossyyhyyhhhhs -yhhhhhhhhhhhh   Theme: Breeze [GTK3] 
hhhhhhy/ `syyyssyyyyhhhhhh: :yhhhhhhhhhhs   Icons: ePapirus [GTK3] 
:hhhhhhyo:-/osyhhhhhhhhhhho  ohhhhhhhhhh:   Terminal: qterminal 
 sdhhhhhhhyyssyyhhhhhhhhhhh+  +hhhhhhhhs    Terminal Font: Ubuntu Mono 14                                                       
 `shhhhhhhhhhhhhhhhhhhhhhy+` .yhhhhhhhh`    CPU: Intel i3-2100 (4) @ 3.100GHz                                                   
  +sdhhhhhhhhhhhhhhhhhyo/. `/yhhhhhhhd`     GPU: Intel 2nd Generation Core Processor Family                                     
   `:shhhhhhhhhh+---..``.:+yyhhhhhhh:       Memory: 1667MiB / 3367MiB                                                           
     `:mdhhhhhh/.syssyyyyhhhhhhhd:`                                                                                             
        `+smdhhh+shhhhhhhhhhhhdm`                                                                                               
           `sNmdddhhhhhhhddm-`                                                                                                  


Edit: hard-coded FEN generation without EPD is working:

winapiadmin@ubuntu:~/venv/bin$ source activate
(venv) winapiadmin@ubuntu:~/venv/bin$ python
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import chess
>>> chess.Board()
Board('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
>>> x=chess.Board()
>>> x.push_san("e4")
Move.from_uci('e2e4')
>>> f"{x.board_fen()} {"w" if x.turn else "b"} {x.castling_xfen()} {chess.square_name(x.ep_square) if x.ep_square else "-"} {x.halfmove_clock} {x.fullmove_number}"
'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1'
@niklasf
Copy link
Owner

niklasf commented Jan 19, 2025

Hi. There are multiple standards for en passant in FENs. See https://python-chess.readthedocs.io/en/latest/core.html#chess.Board.fen:

board.fen(..., en_passant: Literal['legal', 'fen', 'xfen'] = 'legal')

By default, only fully legal en passant squares are included (has_legal_en_passant()). Pass fen to strictly follow the FEN specification (always include the en passant square after a two-step pawn move) or xfen to follow the X-FEN specification (has_pseudo_legal_en_passant()).

@winapiadmin
Copy link
Author

winapiadmin commented Jan 20, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants