# File lib/libttc.rb, line 445
  def undo_move!
    if @history.length > 1
      # general case
      state_to_restore = @history[-2]
      @current_player = @history[-1].player
      @pieces.each do |name, piece| 
        copy_piece = state_to_restore.pieces_after_move[name]
        piece.position = copy_piece.position
        piece.captured = copy_piece.captured
        piece.contains = []
        copy_piece.contains.each do |p|
#          piece.capture(@pieces[p.name])
          piece.contains << @pieces[p.name]
        end
      end
      @history.pop    
    elsif @history.length == 1
      # reset to start
      @current_player = 'a'
      @pieces.each do |name, piece| 
        piece.position = @board.positions[piece.colour]
        piece.captured = false
        piece.contains = []
      end
      @history.pop    
    end
  end