Created
August 4, 2018 07:52
-
-
Save kuribas/1838633c3236ed14c18322421e19374d to your computer and use it in GitHub Desktop.
chess variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies, FlexibleContexts #-} | |
module ChessVariant where | |
import Data.Proxy | |
data Square = Square Int Int Int | |
newtype Side = Side Int | |
data Piece variant = Piece (PieceType variant) Side | |
data MoveStep variant = | |
MovePiece Square Square (Maybe Square) | | |
MovePieceUnder (Piece variant) Square Square (Maybe Square) | | |
SetPiece (Piece variant) Square | | |
SetStaticPiece (Piece variant) Square | | |
RemovePiece Square | | |
RemoveStaticPiece Square | | |
SetUIState (UI variant) | | |
QueryUIState (UIQuery variant) | |
data Move variant = | |
Move [MoveStep variant] String (GameTree variant) | |
data GameTree variant = GameTree (GameState variant -> Square -> [Move variant]) | |
class Enum (PieceType variant) => VariantImpl variant where | |
data PieceType variant :: * | |
data UI variant :: * | |
data UIQuery variant :: * | |
data GameState variant :: * | |
data GameParams variant :: * | |
getPieceName :: PieceType variant -> String | |
pieceFromString :: String -> Maybe (PieceType variant) | |
sides :: Proxy variant -> Int | |
grids :: Proxy variant -> [(Int, Int)] | |
currentSide :: Proxy variant -> state -> Side | |
gameTree :: GameParams variant -> GameTree variant | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment