Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View file

@ -11,6 +11,6 @@ With those constraints there are '''960''' possible starting positions, thus the
;Task:
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 using either the [[wp:Chess symbols in Unicode|chess symbols in Unicode (♔♕♖♗♘)]], the letters '''K'''ing '''Q'''ueen '''R'''ook '''B'''ishop k'''N'''ight, or the corresponding letters in a language other than English.
<br><br>

View file

@ -0,0 +1,17 @@
VDU 23, 22, 240; 360; 8, 16, 16, 136
*FONT Arial, 20
FOR I% = 1 TO 10
Rank1$ = "202"
FOR Piece = 1 TO 3
P% = RND(LENRank1$ + 1)
Rank1$ = LEFT$(Rank1$, P% - 1) + MID$("144", Piece, 1) + MID$(Rank1$, P%)
NEXT
P% = RND(7)
Rank1$ = LEFT$(Rank1$, P% - 1) + "3" + MID$(Rank1$, P%)
IF P% > 5 P% += 1 ELSE P% += RND(4 - (P% >> 1)) * 2 - 1
Rank1$ = LEFT$(Rank1$, P% - 1) + "3" + MID$(Rank1$, P%)
FOR Piece = 1 TO 8
VDU &E2, &99, &94 + VALMID$(Rank1$, Piece, 1)
NEXT
PRINT
NEXT

View file

@ -0,0 +1,23 @@
declare -a pieces=(♖ ♖ ♖ ♕ ♗ ♗ ♘ ♘)
declare -i i pick index
declare -ai picking_history
declare attempt
until [[ "$attempt" =~ ♗(..)*♗ ]]
do
attempt=''
picking_history=()
for _ in {1..8}
do
while ((picking_history[pick=RANDOM%8]++))
do :
done
attempt+="${pieces[pick]}"
done
done
for i in {0..7}
do
if [[ "${attempt:i:1}" =]] && ((index++))
then echo "${attempt:0:i}${attempt:i+1}"; break;
fi
done

View file

@ -1,6 +1,6 @@
import "random" for Random
import "/dynamic" for Tuple
import "/fmt" for Fmt
import "./dynamic" for Tuple
import "./fmt" for Fmt
var Symbols = Tuple.create("Symbols", ["k", "q", "r", "b", "n"])