pioz / chess

A fast chess library that use bitboards to play chess with Ruby
GNU Lesser General Public License v3.0
59 stars 17 forks source link

Could use move generation #13

Closed dkappe closed 7 years ago

dkappe commented 8 years ago

For a chess library, it seems the absence of legal move generation is an is an oversight. Hopefully it would be easy to add. It's the only thing keeping this library from being truly useful.

pioz commented 8 years ago

There is a draft: http://blog.pioz.it/chess/classes/Chess/Gnuchess.html

dkappe commented 8 years ago

I meant legal love generation, I.e. A list of all legal moves, not the best move selected by an engine.

DJK

Sent from my iPad

On Mar 17, 2016, at 7:31 AM, Enrico notifications@github.com wrote:

There is a draft: http://blog.pioz.it/chess/classes/Chess/Gnuchess.html

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub

pioz commented 8 years ago

Ok, I will work on this, but I dont know when -.-

dkappe commented 8 years ago

I can give it a whack, but a hint on how to do it most efficiently would be appreciated.

DJK

On Thu, Mar 17, 2016 at 12:49 PM, Enrico notifications@github.com wrote:

Ok, I will work on this, but I dont know when -.-

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/pioz/chess/issues/13#issuecomment-197997923

pioz commented 8 years ago

I think that a efficiently way is to use the xray bitboard. For example I want to know all the possible valid move that Qd1 can make: I can get the xray bboard with xray (cur_board, 3, FALSE). Now you can use the method try_move for every pseudo legal move indicated by the xray bboard.

pioz commented 7 years ago

Now you can generate all legal moves for the piece in a square position:

:001 > g = Chess::Game.new
 => #<Chess::Game:0x007f88a529fa88>
:002 > g.board.generate_moves('b1')
 => ["Na3", "Nc3"]

http://pioz.github.io/chess/Chess/Board.html#generate_moves-instance_method