Generate Chess960 starting position: Difference between revisions

add Unix shell
(relaxing tax requirements (making it less English-centric))
(add Unix shell)
Line 2,849:
♘♕♗♖♔♖♘♗
♘♘♖♔♗♗♕♖</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}}==
1,934

edits