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

Taking back a move #15

Closed dsaito closed 8 years ago

dsaito commented 8 years ago

Dear Enrico, how can I take back a move?

pioz commented 8 years ago

You can use rollback!

http://pioz.github.com/chess/classes/Chess/CGame.html#method-i-rollback-21

dsaito commented 8 years ago

I tried the rollback! method, but it clears all moves from moves and coord_moves. That means it is taking back all moves. I don't know what I'm doing wrong here...

pioz commented 8 years ago

Can you show me the code?

Il giorno 23 mar 2016, alle ore 01:56, dsaito notifications@github.com ha scritto:

I tried the rollback! method, but it clears all moves from moves and coord_moves. That means it is taking back all moves. I don't know what I'm doing wrong here...

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

dsaito commented 8 years ago

I feel silly now. I had reset the game object (g = Chess::Game.new) prior to applying the rollback! method. I simply forgot to remove this line of code from my previous script editing. That explains the clearing of the move array. Everything works perfectly now, thanks.