thomasahle / sunfish

Sunfish: a Python Chess Engine in 111 lines of code
https://www.chessprogramming.org/Sunfish
Other
2.95k stars 543 forks source link

Cant seem to play as black #81

Closed tamirha2530 closed 3 years ago

tamirha2530 commented 3 years ago

Can anyone give an explanation about how to play as black with the engine? Thank you.

afentev commented 3 years ago

There is no built-in possibility to play as black. But you can easily change several parts of the code to do this. Firstly, you'll need to make a computer to make the first turn. Secondly, you should change the rule of the first pawn move; you can do this by modifying 147's line in the sunfish.py. The point is this line controls if a black pawn is on the 7'th rank when it wants to move on 2 squares with the first move. So if the computer plays as white you should check not the 7'th rank, but the second. Also this question has already been discussed earlier: https://github.com/thomasahle/sunfish/issues/14. Hope this will be useful

thomasahle commented 3 years ago

You can now play as black by running python fancy.py instead of sunfish.py.

tissatussa commented 1 year ago

the newest "version 2023" seems to be able to play with Black !? And it supports UCI .. nice !