module BlunderLib.Units.Knight where

import Data.Maybe

import BlunderLib.Types
import BlunderLib.Util

allKnightMoves :: Board -> Color -> Position -> [Move]
allKnightMoves brd col pos =
  mapMaybe (moveOrCap brd col pos) (knightPositions pos)

knightPositions :: Position -> [Position]
knightPositions pos = catMaybes
  [ up pos >>= upLeft
  , up pos >>= upRight
  , right pos >>= upRight
  , right pos >>= downRight
  , down pos >>= downRight
  , down pos >>= downLeft
  , left pos >>= upLeft
  , left pos >>= downLeft ]
