{-
	Copyright (C) 2018 Dr. Alistair Ward

	This file is part of BishBosh.

	BishBosh is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	BishBosh is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with BishBosh.  If not, see <http://www.gnu.org/licenses/>.
-}
{- |
 [@AUTHOR@]	Dr. Alistair Ward

 [@DESCRIPTION@]	Defines the algorithm used to sort the immediately available capture-/move/s, before evaluating the fitness of the resulting positions.
-}

module BishBosh.Attribute.CaptureMoveSortAlgorithm(
-- * Types
-- ** Data-types
	CaptureMoveSortAlgorithm(..),
-- * Constants
	tag
--	range
) where

import qualified	BishBosh.Property.FixedMembership	as Property.FixedMembership
import qualified	Control.DeepSeq
import qualified	Data.Default
import qualified	Text.XML.HXT.Arrow.Pickle		as HXT
import qualified	Text.XML.HXT.Arrow.Pickle.Schema

-- | Used to qualify XML.
tag :: String
tag :: String
tag	= String
"captureMoveSortAlgorithm"

-- | The sum-type of algorithms by which moves may be sorted.
data CaptureMoveSortAlgorithm
	= MVVLVA	-- ^ <https://www.chessprogramming.org/MVV-LVA>.
	| SEE		-- ^ <https://www.chessprogramming.org/Static_Exchange_Evaluation>.
	deriving (CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool
(CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool)
-> (CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool)
-> Eq CaptureMoveSortAlgorithm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool
$c/= :: CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool
== :: CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool
$c== :: CaptureMoveSortAlgorithm -> CaptureMoveSortAlgorithm -> Bool
Eq, ReadPrec [CaptureMoveSortAlgorithm]
ReadPrec CaptureMoveSortAlgorithm
Int -> ReadS CaptureMoveSortAlgorithm
ReadS [CaptureMoveSortAlgorithm]
(Int -> ReadS CaptureMoveSortAlgorithm)
-> ReadS [CaptureMoveSortAlgorithm]
-> ReadPrec CaptureMoveSortAlgorithm
-> ReadPrec [CaptureMoveSortAlgorithm]
-> Read CaptureMoveSortAlgorithm
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptureMoveSortAlgorithm]
$creadListPrec :: ReadPrec [CaptureMoveSortAlgorithm]
readPrec :: ReadPrec CaptureMoveSortAlgorithm
$creadPrec :: ReadPrec CaptureMoveSortAlgorithm
readList :: ReadS [CaptureMoveSortAlgorithm]
$creadList :: ReadS [CaptureMoveSortAlgorithm]
readsPrec :: Int -> ReadS CaptureMoveSortAlgorithm
$creadsPrec :: Int -> ReadS CaptureMoveSortAlgorithm
Read, Int -> CaptureMoveSortAlgorithm -> ShowS
[CaptureMoveSortAlgorithm] -> ShowS
CaptureMoveSortAlgorithm -> String
(Int -> CaptureMoveSortAlgorithm -> ShowS)
-> (CaptureMoveSortAlgorithm -> String)
-> ([CaptureMoveSortAlgorithm] -> ShowS)
-> Show CaptureMoveSortAlgorithm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptureMoveSortAlgorithm] -> ShowS
$cshowList :: [CaptureMoveSortAlgorithm] -> ShowS
show :: CaptureMoveSortAlgorithm -> String
$cshow :: CaptureMoveSortAlgorithm -> String
showsPrec :: Int -> CaptureMoveSortAlgorithm -> ShowS
$cshowsPrec :: Int -> CaptureMoveSortAlgorithm -> ShowS
Show)

instance Control.DeepSeq.NFData CaptureMoveSortAlgorithm where
	rnf :: CaptureMoveSortAlgorithm -> ()
rnf CaptureMoveSortAlgorithm
_	= ()

instance Data.Default.Default CaptureMoveSortAlgorithm where
	def :: CaptureMoveSortAlgorithm
def	= CaptureMoveSortAlgorithm
MVVLVA

-- | Constant.
range :: [CaptureMoveSortAlgorithm]
range :: [CaptureMoveSortAlgorithm]
range	= [CaptureMoveSortAlgorithm
MVVLVA, CaptureMoveSortAlgorithm
SEE]

instance Property.FixedMembership.FixedMembership CaptureMoveSortAlgorithm where
	members :: [CaptureMoveSortAlgorithm]
members	= [CaptureMoveSortAlgorithm]
range

instance HXT.XmlPickler CaptureMoveSortAlgorithm where
	xpickle :: PU CaptureMoveSortAlgorithm
xpickle	= String
-> PU CaptureMoveSortAlgorithm -> PU CaptureMoveSortAlgorithm
forall a. String -> PU a -> PU a
HXT.xpAttr String
tag (PU CaptureMoveSortAlgorithm -> PU CaptureMoveSortAlgorithm)
-> ([String] -> PU CaptureMoveSortAlgorithm)
-> [String]
-> PU CaptureMoveSortAlgorithm
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> CaptureMoveSortAlgorithm,
 CaptureMoveSortAlgorithm -> String)
-> PU String -> PU CaptureMoveSortAlgorithm
forall a b. (a -> b, b -> a) -> PU a -> PU b
HXT.xpWrap (String -> CaptureMoveSortAlgorithm
forall a. Read a => String -> a
read, CaptureMoveSortAlgorithm -> String
forall a. Show a => a -> String
show) (PU String -> PU CaptureMoveSortAlgorithm)
-> ([String] -> PU String)
-> [String]
-> PU CaptureMoveSortAlgorithm
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Schema -> PU String
HXT.xpTextDT (Schema -> PU String)
-> ([String] -> Schema) -> [String] -> PU String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> Schema
Text.XML.HXT.Arrow.Pickle.Schema.scEnum ([String] -> PU CaptureMoveSortAlgorithm)
-> [String] -> PU CaptureMoveSortAlgorithm
forall a b. (a -> b) -> a -> b
$ (CaptureMoveSortAlgorithm -> String)
-> [CaptureMoveSortAlgorithm] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map CaptureMoveSortAlgorithm -> String
forall a. Show a => a -> String
show [CaptureMoveSortAlgorithm]
range