search.rb
# Generates a FEN string representation of the current gamestate
Generates a FEN string representation of the current gamestate
Generates a FEN string representation of the current gamestate
def make_fen(idx)
    m, rows, c = @mv[idx], [], ''
    8.times do |i|
      row, empty = [], 0
      8.times do |j|
        sq = SQ[(i * 8) + j]
        if @squares[sq] == EMPTY
          empty += 1
          next
        end
        row << empty.to_s if empty > 0
        row << TO_FEN[@colors[sq]][@squares[sq]]
        empty = 0
      end
      row << empty.to_s if empty > 0
      rows << row.join
    end
    'KQkq'.chars.each_with_index { |l, i| c += l if m.castling[3 - i] == 1 }
    [rows.join("/"), ['w','b'][m.mx], c == '' ? '-' : c, SQ_ID[m.ep], m.half_moves, m.full_moves].join(" ")
  end
def make_fen ( idx ) m , rows , c = @mv [ idx ] , [ ] , '' 8 . times do | i | row , empty = [ ] , 0 8 . times do | j | sq = SQ [ ( i * 8 ) + j ] if @squares [ sq ] == EMPTY empty += 1 next end row << empty . to_s if empty > 0 row << TO_FEN [ @colors [ sq ] ] [ @squares [ sq ] ] empty = 0 end row << empty . to_s if empty > 0 rows << row . join end 'KQkq' . chars . each_with_index { | l , i | c += l if m . castling [ 3 - i ] == 1 } [ rows . join ( "/" ) , [ 'w' , 'b' ] [ m . mx ] , c == '' ? '-' : c , SQ_ID [ m . ep ] , m . half_moves , m . full_moves ] . join ( " " ) end
Generates a FEN string representation of the current gamestate
Generates a FEN string representation of the current gamestate
idx
<not_specific>