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

17 lines
622 B
Text

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
posic = Int(Rnd*(Len(inicio) + 1)) + 1
inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1)
posic = posic + 1 + 2 * Int(Int(Rnd*(Len(inicio) - posic)) / 2)
inicio = Left(inicio, posic-1) + "B" + Right(inicio, Len(inicio) - posic + 1)
Print inicio
Next i