Anonymous user
Generate random chess position: Difference between revisions
improved function pawn_on_extreme_ranks
(added tag language rsplus) |
(improved function pawn_on_extreme_ranks) |
||
Line 1,533:
}
###
# Function that checks whether a pawn is on
# (such a situation is not possible in chess)
###
if (pc
return(TRUE)
else
Line 1,549 ⟶ 1,547:
###
# Function that puts pieces on the board making sure that they
# are not on the same squares, and verifying for
###
# initialization
Line 1,567 ⟶ 1,565:
piece_rank <- sample(1:8, 1) ; piece_file <- sample(1:8, 1)
piece <- sample(pieces, 1)
# check if square is empty and it is not a pawn on
if (brd[piece_rank, piece_file] == " " & !
brd[piece_rank, piece_file] <- piece
n_pieces <- n_pieces - 1
Line 1,614 ⟶ 1,612:
{{out}}
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] " " "
[2,] "
[3,] " " " " "
[4,] " " "
[5,] " " " " " " "
[6,] " " " " " " "
[7,] " " "
[8,] " " "
=={{header|Raku}}==
|