Generate Chess960 starting position: Difference between revisions
Content added Content deleted
(Added Wren) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 15: | Line 15: | ||
The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions. You will show the result as the first rank displayed with [[wp:Chess symbols in Unicode|Chess symbols in Unicode: ♔♕♖♗♘]] or with the letters '''K'''ing '''Q'''ueen '''R'''ook '''B'''ishop k'''N'''ight. |
The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions. You will show the result as the first rank displayed with [[wp:Chess symbols in Unicode|Chess symbols in Unicode: ♔♕♖♗♘]] or with the letters '''K'''ing '''Q'''ueen '''R'''ook '''B'''ishop k'''N'''ight. |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python: Correct by construction}} |
|||
<lang 11l>F random960() |
|||
V start = [‘R’, ‘K’, ‘R’] |
|||
L(piece) [‘Q’, ‘N’, ‘N’] |
|||
start.insert(random:(start.len + 1), piece) |
|||
V bishpos = random:(start.len + 1) |
|||
start.insert(bishpos, Char(‘B’)) |
|||
start.insert(random:(bishpos + 1), Char(‘B’)) |
|||
R start |
|||
print(random960())</lang> |
|||
{{out}} |
|||
<pre> |
|||
[Q, B, N, R, K, B, N, R] |
|||
</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |