Anonymous user
Generate random chess position: Difference between revisions
m
→{{header|Haskell}}
m (→{{header|REXX}}: added/changed comments and whitespace; split some compound statement DO groups.) |
|||
Line 685:
-- State functions
currentState <- get
let gen1 = generator currentState
Line 696:
randomPos = do
boardState <- gets board
let pos = (chr, num)
if isPosOccupied pos boardState then
randomPos
else
pure pos
randomPiece :: State BoardState Square
randomPiece = ChessPiece <$>
placeKings :: State BoardState ()
Line 720:
placePawns :: State BoardState ()
placePawns =
where
go :: Int -> State BoardState ()
Line 727:
currentState <- get
pos <- randomPos
color <-
let pawn = ChessPiece Pawn color
let currentBoard = board currentState
Line 745:
placeRemaining :: State BoardState ()
placeRemaining =
where
remaining = filter (\case
|