Generate random chess position: Difference between revisions

(Added Crystal translation of Ruby version.)
Line 252:
p = rand(e); t = pieces[e]
#pieces[e] = pieces[p]; pieces[p] = t; e -= 1 # in Ruby
pieces = pieces.sub(e, pieces[p]); # in Crystal because
pieces = pieces.sub(p, t); e -= 1 # strings immutable
end
Line 280:
 
# Simpler for same output
8.times{ |row| puts board[row*8..row*8 + 7].join("") }</lang>
</lang>
{{out}}<pre>
1n1P3p/1p1k2Pp/1ppPPprn/2rP4/KNRQ2b1/2Bp1PP1/3qPBN1/2Rp4 w - - 0 1
Line 292 ⟶ 291:
...qPBN.
..Rp....
 
</pre>
 
Anonymous user