RosettaCodeData/Task/Generate-Chess960-starting-position/Yabasic/generate-chess960-starting-position.basic
2023-07-01 13:44:08 -04:00

12 lines
462 B
Text

start$ = "RKR"
piece$ = "QNN"
for piece = 1 to len(piece$)
pos = int(ran(len(start$) + 1)) + 1
start$ = left$(start$, pos-1) + mid$(piece$, piece, 1) + right$(start$, len(start$) - pos + 1)
next
pos = int(ran(len(start$) + 1)) + 1
start$ = left$(start$, pos-1) + "B" + right$(start$, len(start$) - pos + 1)
pos = pos + 1 + 2 * int(int(ran(len(start$) - pos)) / 2)
start$ = left$(start$, pos-1) + "B" + right$(start$, len(start$) - pos + 1)
print start$