Method: Chess::Game#move

Defined in:
lib/chess/game.rb

#move(notation) ⇒ String Also known as: move=, <<

Note:

This add a new Board in the Chess::Game.

Make a move.

Parameters:

  • notation (String)

    Represents the short algebraic chess notation string of the move. ‘notation` can be also from_square plus to_square _(’e2e4’, …, ‘b1c3’)_ (coordinate chess notation).

Returns:

  • (String)

    Returns a string that represents the short algebraic chess notation of the move.

Raises:



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/chess/game.rb', line 59

def move(notation)
  expand = expand_move(notation)
  if expand[:from]
    move2(expand[:from], expand[:to], expand[:promotion])
  else
    super(expand[:name], expand[:dis], expand[:to], expand[:promotion])
  end
rescue IllegalMoveError
  raise IllegalMoveError.new("Illegal move '#{notation}'\nStatus: #{self.status}\nPlayer turn #{self.active_player}\n#{self}") if ENV['DEBUG']

  raise IllegalMoveError.new("Illegal move '#{notation}'")
end