Closed sfogarty closed 1 year ago
https://github.com/TU-CSCI2322-FL22/solver-the-connectors/blob/ec3768dbb3f7b8de3314ef33076437f4b7b7cd66/ConnectFour.hs#L54-L63
You don't need the accumulator list.
availableMoves :: Board -> [Move] availableMoves brd = aux brd 1 where aux :: Board -> [Move] -> Int -> [Move] aux (Board [] clr) cnt = [] aux (Board (c:cs) clr) cnt = if length c < rows then cnt:(aux (Board cs clr) (cnt+1)) else aux (Board cs clr) (cnt+1)
Also, I encourage "vertical" decomposition, i.e.
availableMoves :: Board -> [Move] availableMoves (Board cols clr) = [num | (col, num) <- labelCols cols 1, length col < rows] where labeledCols [] num = [] labeledCols (c:cs) num = (c,n):(labeledCols cs (num+1)
https://github.com/TU-CSCI2322-FL22/solver-the-connectors/blob/ec3768dbb3f7b8de3314ef33076437f4b7b7cd66/ConnectFour.hs#L54-L63
You don't need the accumulator list.
Also, I encourage "vertical" decomposition, i.e.