| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
BishBosh.Attribute.MoveType
Description
AUTHOR- Dr. Alistair Ward
DESCRIPTION- Categorises moves, & provides ancillary information as required.
Synopsis
- data MoveType
- tag :: String
- shortCastle :: MoveType
- longCastle :: MoveType
- enPassant :: MoveType
- nPiecesMutator :: Enum nPieces => MoveType -> nPieces -> nPieces
- apply :: (IsShort -> a, a, (Maybe Rank, Maybe Rank) -> a) -> MoveType -> a
- mkMaybeNormalMoveType :: Maybe Rank -> Maybe Rank -> Maybe MoveType
- mkNormalMoveType :: Maybe Rank -> Maybe Rank -> MoveType
- isCastle :: MoveType -> Bool
- isEnPassant :: MoveType -> Bool
- isCapture :: MoveType -> Bool
- isPromotion :: MoveType -> Bool
- isQuiet :: MoveType -> Bool
- isSimple :: MoveType -> Bool
- isAcyclic :: MoveType -> Bool
- getMaybeExplicitlyTakenRank :: MoveType -> Maybe Rank
- getMaybeImplicitlyTakenRank :: MoveType -> Maybe Rank
- getMaybePromotedRank :: MoveType -> Maybe Rank
Types
Type-synonyms
Data-types
The sum-type of distinct types of move.
Constructors
| Castle IsShort | Castling between the |
| EnPassant | Capture by a |
Instances
| Eq MoveType Source # | |
| Read MoveType Source # | |
| Show MoveType Source # | |
| Default MoveType Source # | |
Defined in BishBosh.Attribute.MoveType | |
| NFData MoveType Source # | |
Defined in BishBosh.Attribute.MoveType | |
| FixedMembership MoveType Source # | |
Defined in BishBosh.Attribute.MoveType | |
| Promotable MoveType Source # | |
Defined in BishBosh.Attribute.MoveType | |
Constants
shortCastle :: MoveType Source #
Constant value required to denote a short castle.
longCastle :: MoveType Source #
Constant value required to denote a long castle.
Functions
nPiecesMutator :: Enum nPieces => MoveType -> nPieces -> nPieces Source #
Returns the mutator required to adjust the number of pieces after a move.
Arguments
| :: (IsShort -> a, a, (Maybe Rank, Maybe Rank) -> a) | The handlers for each move-type; Castle, En-passant & Normal. |
| -> MoveType | |
| -> a |
Permit the caller to react in an arbitrary way, according to a specific move-type.
Constructors
mkMaybeNormalMoveType Source #
Arguments
| :: Maybe Rank | The rank of any opposing piece which was just taken. |
| -> Maybe Rank | The rank to which a |
| -> Maybe MoveType | Maybe the required move-type. |
Smart constructor for normal move-types.
Arguments
| :: Maybe Rank | The rank of any opposing piece which is to be taken. |
| -> Maybe Rank | The rank to which a |
| -> MoveType |
Smart-constructor for normal move-types.
Predicates
isEnPassant :: MoveType -> Bool Source #
Predicate.
isCapture :: MoveType -> Bool Source #
Whether a piece was captured, including Pawns taken En-passant.
isPromotion :: MoveType -> Bool Source #
Whether the move includes Pawn-promotion.
isAcyclic :: MoveType -> Bool Source #
- Whether the move can't be a member of a repeated cycle.
- CAVEAT: one can't infer from a negative result that the move can be repeated, since the mover may have been a
Pawn.
Query
getMaybeExplicitlyTakenRank :: MoveType -> Maybe Rank Source #
Query whether a piece was explicitly taken, excluding Pawns taken En-passant.