RosettaCodeData/Task/Generate-Chess960-starting-position/FreeBASIC/generate-chess960-starting-position.basic

21 lines
615 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
Randomize Timer
For i As Byte = 1 To 10
Dim As String inicio = "RKR", pieza = "QNN"
Dim As Byte posic
For n As Byte = 1 To Len(pieza)
posic = Int(Rnd*(Len(inicio) + 1)) + 1
inicio = Left(inicio, posic-1) + _
Mid(pieza, n, 1) +_
Right(inicio, Len(inicio) - posic + 1)
Next n
2025-02-27 18:35:13 -05:00
2023-07-01 11:58:00 -04:00
posic = Int(Rnd*(Len(inicio) + 1)) + 1
inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1)
2025-02-27 18:35:13 -05:00
posic += 1 + 2 * (Int(Rnd*(Len(inicio) - posic)) \ 2)
2023-07-01 11:58:00 -04:00
inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1)
2025-02-27 18:35:13 -05:00
2023-07-01 11:58:00 -04:00
Print inicio
Next i