Generate Chess960 starting position: Difference between revisions
Content added Content deleted
(relaxing tax requirements (making it less English-centric)) |
(add Unix shell) |
||
Line 2,849: | Line 2,849: | ||
♘♕♗♖♔♖♘♗ |
♘♕♗♖♔♖♘♗ |
||
♘♘♖♔♗♗♕♖</pre> |
♘♘♖♔♗♗♕♖</pre> |
||
=={{header|UNIX Shell}}== |
|||
{{trans|raku}} |
|||
{{works with|bash}} |
|||
<syntaxhighlight lang=bash>declare -a pieces=(♖ ♖ ♖ ♕ ♗ ♗ ♘ ♘) |
|||
declare -i pick |
|||
declare -ai picking_history |
|||
declare attempt |
|||
until [[ "$attempt" =~ ♗(..)*♗ ]] |
|||
do |
|||
attempt='' |
|||
picking_history=() |
|||
for _ in {1..8} |
|||
do |
|||
while ((pick=RANDOM%8, picking_history[pick]++)) |
|||
do : |
|||
done |
|||
attempt+="${pieces[pick]}" |
|||
done |
|||
done |
|||
declare -i index |
|||
for i in {0..7} |
|||
do |
|||
if [[ "${attempt:i:1}" = ♖ ]] && ((index++)) |
|||
then echo "${attempt:0:i}♔${attempt:i+1}"; break; |
|||
fi |
|||
done</syntaxhighlight> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |