packages feed

bishbosh 0.0.0.4 → 0.0.0.5

raw patch · 18 files changed

+235/−66 lines, 18 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ BishBosh.Text.Encoding: instance Data.Default.Class.Default GHC.IO.Encoding.Types.TextEncoding
+ BishBosh.Text.Encoding: instance GHC.Classes.Eq GHC.IO.Encoding.Types.TextEncoding
+ BishBosh.Text.Encoding: instance GHC.Read.Read GHC.IO.Encoding.Types.TextEncoding
+ BishBosh.Text.Encoding: instance Text.XML.HXT.Arrow.Pickle.Xml.XmlPickler GHC.IO.Encoding.Types.TextEncoding
+ BishBosh.Text.Encoding: range :: [TextEncoding]
+ BishBosh.Text.Encoding: tag :: String
- BishBosh.ContextualNotation.PGNDatabase: parseIO :: (Enum x, Enum y, Ord x, Ord y, Show x, Show y) => FilePath -> IsStrictlySequential -> ValidateMoves -> [Tag] -> IO (Either String (PGNDatabase x y))
+ BishBosh.ContextualNotation.PGNDatabase: parseIO :: (Enum x, Enum y, Ord x, Ord y, Show x, Show y) => FilePath -> IsStrictlySequential -> ValidateMoves -> TextEncoding -> [Tag] -> IO (Either String (PGNDatabase x y))
- BishBosh.Input.PGNOptions: mkPGNOptions :: FilePath -> IsStrictlySequential -> ValidateMoves -> [Tag] -> NMoves -> PGNOptions
+ BishBosh.Input.PGNOptions: mkPGNOptions :: FilePath -> IsStrictlySequential -> ValidateMoves -> TextEncoding -> [Tag] -> NMoves -> PGNOptions

Files

bishbosh.cabal view
@@ -14,7 +14,7 @@ -- along with BishBosh.  If not, see <http://www.gnu.org/licenses/>.  Name:		bishbosh-Version:	0.0.0.4+Version:	0.0.0.5 Cabal-version:	>= 1.10 Copyright:	(C) 2018 Dr. Alistair Ward License:	GPL@@ -25,7 +25,7 @@ Build-type:	Simple Description:	A chess-game which can be rendered in a terminal (emulator) in raw ASCII, or used as an engine by xboard. Category:	Game-Tested-with:	GHC == 8.0, GHC == 8.2, GHC == 8.4, GHC == 8.6+Tested-with:	GHC == 8.0, GHC == 8.2, GHC == 8.4, GHC == 8.6, GHC == 8.8, GHC == 8.10 Homepage:	https://functionalley.com/BishBosh/bishbosh.html Maintainer:	mailto:bishbosh@functionalley.com Bug-reports:	mailto:bishbosh@functionalley.com@@ -186,6 +186,7 @@         BishBosh.State.MaybePieceByCoordinates         BishBosh.State.Position         BishBosh.State.TurnsByLogicalColour+        BishBosh.Text.Encoding         BishBosh.Text.ShowList         BishBosh.Types         BishBosh.UI.Command@@ -389,6 +390,7 @@         BishBosh.Test.QuickCheck.State.InstancesByPosition         BishBosh.Test.QuickCheck.State.Position         BishBosh.Test.QuickCheck.State.TurnsByLogicalColour+        BishBosh.Test.QuickCheck.Text.Encoding         BishBosh.Test.QuickCheck.UI.Command         BishBosh.Test.QuickCheck.UI.PrintObject         BishBosh.Test.QuickCheck.UI.SetObject
bishbosh.spec view
@@ -24,7 +24,7 @@  Summary:	BishBosh is a chess-game. Name:		bishbosh-Version:	0.0.0.4+Version:	0.0.0.5 Release:	1 License:	GPLv3 # From '/usr/share/doc/packages/rpm/GROUPS'.
changelog.markdown view
@@ -11,3 +11,7 @@  ## 0.0.0.4 Changed references to author's domain-name.++## 0.0.0.5+Added ability to specify the text-encoding used in a PGN-database file.+Updated list of test-compilers.
config/CECP/bishbosh_black.xml view
@@ -52,10 +52,10 @@ 			<identificationTag tag="ECO"/> 			<identificationTag tag="Variation"/> <!---		</pgnOptions><pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="False">+		</pgnOptions><pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="False" textEncoding="ISO8859-1"> 			<identificationTag tag="ECO"/> 			<identificationTag tag="Variation"/>-		</pgnOptions><pgnOptions databaseFilePath="pgn/bundesliga2000.pgn" validateMoves="False">+		</pgnOptions><pgnOptions databaseFilePath="pgn/bundesliga2000.pgn" validateMoves="False" textEncoding="ISO8859-1"> 			<identificationTag tag="Event"/> 			<identificationTag tag="Round"/> 		</pgnOptions><pgnOptions databaseFilePath="pgn/ficsgamesdb_201601_standard2000_nomovetimes_1403205.pgn" validateMoves="False" minimumPlies="8">
config/Raw/bishbosh_black.xml view
@@ -51,17 +51,18 @@ 		<pgnOptions databaseFilePath="pgn/scid.pgn" isStrictlySequential="False" validateMoves="False"> 			<identificationTag tag="ECO"/> 			<identificationTag tag="Variation"/>+		</pgnOptions> <!---		</pgnOptions><pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="False">+		<pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="False" textEncoding="ISO8859-1"> 			<identificationTag tag="ECO"/> 			<identificationTag tag="Variation"/>-		</pgnOptions><pgnOptions databaseFilePath="pgn/bundesliga2000.pgn" validateMoves="False">+		</pgnOptions><pgnOptions databaseFilePath="pgn/bundesliga2000.pgn" validateMoves="False" textEncoding="ISO8859-1"> 			<identificationTag tag="Event"/> 			<identificationTag tag="Round"/> 		</pgnOptions><pgnOptions databaseFilePath="pgn/ficsgamesdb_201601_standard2000_nomovetimes_1403205.pgn" validateMoves="False" minimumPlies="8"> 			<identificationTag tag="FICSGamesDBGameNo"/>---> 		</pgnOptions>+--> 		<uiOptions> 			<nativeUIOptions/> 		</uiOptions>
config/Raw/bishbosh_prof.xml view
@@ -56,7 +56,7 @@ 		</searchDepthByLogicalColour> 	</searchOptions> 	<ioOptions maximumPGNNames="8">-		<pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="True">+		<pgnOptions databaseFilePath="pgn/scid_fr.pgn" validateMoves="True" textEncoding="ISO8859-1"> 			<identificationTag tag="ECO"/> 			<identificationTag tag="Variation"/> 		</pgnOptions>
config/bishbosh.dtd view
@@ -92,10 +92,11 @@ 		> 		<!ELEMENT pgnOptions (identificationTag)*> 			<!ATTLIST pgnOptions-				databaseFilePath	CDATA		#REQUIRED-				minimumPlies		CDATA		#IMPLIED-				isStrictlySequential	(False | True)	#IMPLIED-				validateMoves		(False | True)	#IMPLIED+				databaseFilePath	CDATA					#REQUIRED+				minimumPlies		CDATA					#IMPLIED+				isStrictlySequential	(False | True)				#IMPLIED+				validateMoves		(False | True)				#IMPLIED+				textEncoding		(ISO8859-1 | UTF-8 | UTF-16 | UTF-32)	#IMPLIED 			> 			<!ELEMENT identificationTag EMPTY> 				<!ATTLIST identificationTag
config/bishbosh.rng view
@@ -151,7 +151,18 @@ 									</choice> 									<ref name="Boolean"/> 								</attribute>-							</zeroOrMore><zeroOrMore>+							</zeroOrMore>+							<optional>+								<attribute name="textEncoding">+									<choice>+										<value>ISO8859-1</value>+										<value>UTF-8</value>+										<value>UTF-16</value>+										<value>UTF-32</value>+									</choice>+								</attribute>+							</optional>+							<zeroOrMore> 								<element name="identificationTag"> 									<attribute name="tag"/> 								</element>
man/man1/bishbosh.1 view
@@ -21,17 +21,17 @@ .IP \(bu Unlimited roll-back of moves. .IP \(bu-Configurable \fBhttps://en.wikipedia.org/wiki/Chess_notation\fR.+Configurable <\fBhttps://en.wikipedia.org/wiki/Chess_notation\fR>. .IP \(bu The ability to read PGN-databases of standard openings & archived games,-in which it can match both \fBhttps://chessprogramming.wikispaces.com/Transposition\fR s & colour-flipped (\fBhttps://chessprogramming.wikispaces.com/Color+Flipping\fR) positions.+in which it can match both <\fBhttps://chessprogramming.wikispaces.com/Transposition\fR>s & colour-flipped (<\fBhttps://chessprogramming.wikispaces.com/Color+Flipping\fR>) positions. .IP \(bu Automation of the moves for either, neither, or both players. Both the evaluation of moves & the search for the optimum, are highly configurable; see \fBsection-5\fR of the man-pages. .IP \(bu Optional hints for manual players. .IP \(bu-\fBhttps://chessprogramming.wikispaces.com/Pondering\fR .+<\fBhttps://chessprogramming.wikispaces.com/Pondering\fR>. .SS Implementation Some understanding of the algorithm used to automatically select moves, is useful either when configuring this application or when interpreting the esoteric feedback available after move-selection (given "\fB--verbosity=Deafening\fR"). The algorithm first compares the position with those in the referenced PGN-databases; a looser criterion than whether a matching move-sequence exists.@@ -39,14 +39,14 @@ The next move will be selected randomly from the subset of victorious matching positions, in preference to the non-victorious subset. .PP On failure to match the position with an archived game, the tree of all possible moves until the end of the game, is constructed & statically sorted to advance the subsequent evaluation of capture-moves,-using either \fBhttps://chessprogramming.wikispaces.com/MVV-LVA\fR or \fBhttps://chessprogramming.wikispaces.com/Static+Exchange+Evaluation\fR .-On each move, this tree's non-capture moves are dynamically sorted using the \fBhttps://chessprogramming.wikispaces.com/Killer+Heuristic\fR & the \fBhttps://chessprogramming.wikispaces.com/History+Heuristic\fR .+using either <\fBhttps://chessprogramming.wikispaces.com/MVV-LVA\fR> or <\fBhttps://chessprogramming.wikispaces.com/Static+Exchange+Evaluation\fR>.+On each move, this tree's non-capture moves are dynamically sorted using the <\fBhttps://chessprogramming.wikispaces.com/Killer+Heuristic\fR> & the <\fBhttps://chessprogramming.wikispaces.com/History+Heuristic\fR>. .br-This tree is then searched using a \fBhttps://chessprogramming.wikispaces.com/Negamax\fR algorithm with \fBhttps://chessprogramming.wikispaces.com/Alpha-Beta\fR pruning,+This tree is then searched using a <\fBhttps://chessprogramming.wikispaces.com/Negamax\fR> algorithm with <\fBhttps://chessprogramming.wikispaces.com/Alpha-Beta\fR> pruning, over a constant configurable number of plies, to find the optimal move according to the weighted-mean of various criteria described in \fBsection-5\fR of the man-pages. .br-Shortcuts in the search for the optimal move are taken on encountering either \fBhttps://chessprogramming.wikispaces.com/Repetitions\fR in the move-sequence,-or transpositions (\fBhttps://chessprogramming.wikispaces.com/Transposition\fR) of sibling games.+Shortcuts in the search for the optimal move are taken on encountering either <\fBhttps://chessprogramming.wikispaces.com/Repetitions\fR> in the move-sequence,+or transpositions (<\fBhttps://chessprogramming.wikispaces.com/Transposition\fR>) of sibling games. .SH OPTIONS .SS "Input" .TP@@ -67,7 +67,7 @@ \fB--verbosity=\fR(\fBSilent\fR|\fBNormal\fR|\fBVerbose\fR|\fBDeafening\fR), defaulting to "\fBNormal\fR". Defines the quantity of ancillary output required. See "\fBverbosity\fR" in \fBsection-5\fR of the man-pages. .TP-\fB--printMoveTree\fR=\fI<Int>\fR+\fB--printMoveTree\fR=<\fIInt\fR> Print the tree of all possible moves in the configured notation, each annotated by a fitness-evaluation for the resulting position, truncated to the specified number of plies; see \fBsection-5\fR of the man-pages for details. .SS "Generic Program-information" .TP@@ -116,7 +116,7 @@ .IP \(bu The application has been instructed to provide a relatively large amount of feedback. .IP \(bu-One of the packaged configuration-files has been referenced, which automates White's moves & specifies a raw ASCII interface; on \fBMS-Windows\fR you'll need to issue this from a terminal-emulator which understands \fBhttps://en.wikipedia.org/wiki/ANSI_escape_code\fR .+One of the packaged configuration-files has been referenced, which automates White's moves & specifies a raw ASCII interface; on \fBMS-Windows\fR you'll need to issue this from a terminal-emulator which understands <\fBhttps://en.wikipedia.org/wiki/ANSI_escape_code\fR>. This path includes both an architecture-specific & a version-specific directory, which are represented as globs & expanded by \fBbash\fR; on \fBMS-Windows\fR you may need to be more explicit. .IP \(bu CAVEAT: assumes that the executable exists on \fB$PATH\fR, otherwise an explicit path will be required.@@ -132,7 +132,7 @@ For performance, the run-time system has been explicitly instructed to fully utilise the available CPU-cores, & to set a large minimum size for the heap to satisfy its craving for RAM; actually similar defaults have been predefined. .PP .nf-.B xboard -fcp "bishbosh -i $HOME/.cabal/share/x86_64-linux-ghc-8.0.2/bishbosh-0.0.0.2/config/CECP/bishbosh_black.xml"+\fBxboard -fcp "bishbosh -i $HOME/.cabal/share/x86_64-linux-ghc-8.0.2/bishbosh-0.0.0.2/config/CECP/bishbosh_black.xml"\fR .fi .IP \(bu Instruct the \fBxboard\fR GUI to use \fBbishbosh\fR as its first engine; \fBwinboard\fR is the equivalent GUI for \fBMS-Windows\fR.@@ -150,9 +150,9 @@ bishbosh.svg	A module-dependency graph for this application. config/{CECP,Raw}/*.xml	Sample configuration-files. man/man5/bishbosh.5	\fBSection-5\fR of the man-pages for this product, describing the configuration-file format.-pgn/*.pgn	Sample PGN-databases; \fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR .+pgn/*.pgn	Sample PGN-databases; <\fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR>. ~/.bishbosh/*.txt	Persisted games, stored in a user-specific directory.-https://www.gnu.org/software/xboard	A GUI for chess-engines.+<https://www.gnu.org/software/xboard>	A GUI for chess-engines. .TE .SH AUTHOR Written by Dr. Alistair Ward.@@ -162,7 +162,7 @@ .IP \(bu The implementation of CECP is minimal. .IP \(bu-Performance is uncompetitive with imperative implementions of similar algorithms.+Performance is uncompetitive with imperative implementations of similar algorithms. .SS "REPORTING BUGS" Report bugs to "\fBbishbosh@functionalley.com\fR". .SH COPYRIGHT@@ -172,16 +172,16 @@ .PP This program 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. .PP-You should have received a copy of the GNU General Public License along with this program. If not, see \fBhttps://www.gnu.org/licenses/\fR .+You should have received a copy of the GNU General Public License along with this program. If not, see <\fBhttps://www.gnu.org/licenses/\fR>. .SH "SEE ALSO" .IP \(bu-Home-page: \fBhttps://functionalley.com/BishBosh/bishbosh.html\fR+Home-page: <\fBhttps://functionalley.com/BishBosh/bishbosh.html\fR>. .IP \(bu-.B https://hackage.haskell.org/package/bishbosh+<\fBhttps://hackage.haskell.org/package/bishbosh\fR>. .IP \(bu-.B https://github.com/functionalley/BishBosh+<\fBhttps://github.com/functionalley/BishBosh\fR>. .IP \(bu Source-documentation is generated by "\fBHaddock\fR", & is available in the distribution. .IP \(bu-.B https://www.haskell.org/haddock/+<\fBhttps://www.haskell.org/haddock/\fR>. 
man/man5/bishbosh.5 view
@@ -16,7 +16,7 @@ Whether to incrementally generate position-hashes & evaluate the piece-square value, from the previous values; otherwise these quantities are evaluated from scratch. This option slightly reduces memory-requirement, but doesn't affect the result. .IP \(bu-\fBrankValues\fR: defines the value within the closed unit interval "\fB[0, 1]\fR", of each type of piece, defaulting (ref. \fBhttps://chessprogramming.wikispaces.com/Point+Value\fR) to:+\fBrankValues\fR: defines the value within the closed unit interval "\fB[0, 1]\fR", of each type of piece, defaulting (ref. <\fBhttps://chessprogramming.wikispaces.com/Point+Value\fR>) to: .TS lb	lb l	l@@ -39,14 +39,14 @@ lb	l	lb	l	. Criterion	Metric	Ref	Notes =========	======	===	=====-material	Quantifies the value of the pieces remaining per side.	https://chessprogramming.wikispaces.com/Material	This is dependent on the value of each type of piece; see "\fBrankValues\fR".-mobility	The difference between the number of moves available per side.	https://chessprogramming.wikispaces.com/Mobility	Actually the reciprocal is measured, to emphasis the reduction caused by checking one's opponent.-pieceSquareValue	Quantifies the position held by the pieces per side.	https://chessprogramming.wikispaces.com/Piece-Square+Tables	This metric includes aspects of both "\fBmaterial\fR" & "\fBmobility\fR". The value can be made linearly dependent on progress through the game.+material	Quantifies the value of the pieces remaining per side.	<https://chessprogramming.wikispaces.com/Material>	This is dependent on the value of each type of piece; see "\fBrankValues\fR".+mobility	The difference between the number of moves available per side.	<https://chessprogramming.wikispaces.com/Mobility>	Actually the reciprocal is measured, to emphasis the reduction caused by checking one's opponent.+pieceSquareValue	Quantifies the position held by the pieces per side.	<https://chessprogramming.wikispaces.com/Piece-Square+Tables>	This metric includes aspects of both "\fBmaterial\fR" & "\fBmobility\fR". The value can be made linearly dependent on progress through the game. castlingPotential	Whether each player has been permanently prevented from castling.		Reflects the disadvantage of moving one's King, thus preventing subsequent castling. defence	The difference between the number of pieces defending one's own, per side.		There's neither any penalty for gaps in this defence nor account made of the value of the defended piece; it's just the total number of defenders.-doubledPawns	The difference between the total number of doubled Pawns per side.	https://chessprogramming.wikispaces.com/Doubled+Pawn	Reflects the reduced mobility of such Pawns.-isolatedPawns	The difference between the total number of isolated Pawns per side.	https://chessprogramming.wikispaces.com/Isolated+Pawn	Reflects the lack of defence from adjacent Pawns.-passedPawns	The difference between the total number of passed Pawns per side.	https://chessprogramming.wikispaces.com/Passed+Pawn	Reflects improved promotion-prospects.+doubledPawns	The difference between the total number of doubled Pawns per side.	<https://chessprogramming.wikispaces.com/Doubled+Pawn>	Reflects the reduced mobility of such Pawns.+isolatedPawns	The difference between the total number of isolated Pawns per side.	<https://chessprogramming.wikispaces.com/Isolated+Pawn>	Reflects the lack of defence from adjacent Pawns.+passedPawns	The difference between the total number of passed Pawns per side.	<https://chessprogramming.wikispaces.com/Passed+Pawn>	Reflects improved promotion-prospects. .TE .IP Other criteria could be measured, but orthogonality is problematic.@@ -86,35 +86,35 @@ lb	l	. Value	Meaning =====	=======-MVVLVA	moves are advanced depending on the value of rank of the piece they capture, but where this is equal, those which achieve this using a less valuable piece are preferred; \fBhttps://chessprogramming.wikispaces.com/MVV-LVA\fR . This is highly effective.-SEE	moves are advanced depending on the net material gain resulting from any battle at the destination; \fBhttps://chessprogramming.wikispaces.com/Static+Exchange+Evaluation\fR . This is not currently competitive.+MVVLVA	moves are advanced depending on the value of rank of the piece they capture, but where this is equal, those which achieve this using a less valuable piece are preferred; <\fBhttps://chessprogramming.wikispaces.com/MVV-LVA\fR>. This is highly effective.+SEE	moves are advanced depending on the net material gain resulting from any battle at the destination; <\fBhttps://chessprogramming.wikispaces.com/Static+Exchange+Evaluation\fR>. This is not currently competitive. .TE .IP Neither of these sort-algorithms affects the relative order of non-capture moves; cf. \fBpreferMovesTowardsCentre\fR & \fBsortOnStandardOpeningMoveFrequency\fR. This is performed after \fBsortOnStandardOpeningMoveFrequency\fR. .IP \(bu-\fBminimumHammingDistance\fR \fIInt\fR: the optional positive lower bound on the Hamming-distance between any of the random numbers used to generate Zobrist hashes from positions; \fBhttps://chessprogramming.wikispaces.com/Zobrist+Hashing\fR .+\fBminimumHammingDistance\fR \fIInt\fR: the optional positive lower bound on the Hamming-distance between any of the random numbers used to generate Zobrist hashes from positions; <\fBhttps://chessprogramming.wikispaces.com/Zobrist+Hashing\fR>. .br CAVEAT: linear independence of the bit-vectors is a better measure than Hamming-distance, of the quality of the selected random numbers. .IP \(bu-\fBretireKillerMovesAfter\fR \fIInt\fR: the optional non-negative number of full moves (one by each player) after which killer-moves are retired; \fBhttps://chessprogramming.wikispaces.com/Killer+Move\fR .+\fBretireKillerMovesAfter\fR \fIInt\fR: the optional non-negative number of full moves (one by each player) after which killer-moves are retired; <\fBhttps://chessprogramming.wikispaces.com/Killer+Move\fR>. If unspecified, killer-moves won't even be recorded. .br N.B.: this is highly effective up to about \fB3\fR, beyond which returns diminish. .br-Killer-moves are used to dynamically sort the moves available from a position, based on whether similar moves previously triggered beta-cutoff; \fBhttps://chessprogramming.wikispaces.com/Beta-Cutoff\fR .+Killer-moves are used to dynamically sort the moves available from a position, based on whether similar moves previously triggered beta-cutoff; <\fBhttps://chessprogramming.wikispaces.com/Beta-Cutoff\fR>. .IP \(bu-\fBtrapRepeatedPositions\fR: whether to short-circuit the fitness-evaluation of \fIposition\fRs which have been visited before in the current game; \fBhttps://chessprogramming.wikispaces.com/Repetitions\fR .+\fBtrapRepeatedPositions\fR: whether to short-circuit the fitness-evaluation of \fIposition\fRs which have been visited before in the current game; <\fBhttps://chessprogramming.wikispaces.com/Repetitions\fR>. These situations result from loops of consecutive reversible moves, in the move-tree which defines the game of chess. The fitness of such \fIposition\fRs can be derived by induction, since were one to search from this \fIposition\fR, one would ultimately arrive back another time, so the fitness of this future \fIposition\fR equals the current fitness. .br N.B.: this doesn't typically improve performance in either space or time. .IP \(bu-\fBusePondering\fR: whether an automated player should plan their next move, based on a prediction of the opponent's response, & thus make use their opponent's thinking-time; \fBhttps://chessprogramming.wikispaces.com/Pondering\fR .+\fBusePondering\fR: whether an automated player should plan their next move, based on a prediction of the opponent's response, & thus make use their opponent's thinking-time; <\fBhttps://chessprogramming.wikispaces.com/Pondering\fR>. .IP \(bu \fBtranspositions\fR: these can be used to reorder the evaluation of moves,-based on the results previously found for identical \fIposition\fRs in sibling games reached by an alternative sequence of arbitrary moves; \fBhttps://chessprogramming.wikispaces.com/Transposition\fR .+based on the results previously found for identical \fIposition\fRs in sibling games reached by an alternative sequence of arbitrary moves; <\fBhttps://chessprogramming.wikispaces.com/Transposition\fR>. .TS lb	lb	lb l	l	l@@ -134,7 +134,7 @@ =========	====	=======	======= tryToMatchMoves	Bool	True	whether to attempt to exactly match the moves already made, with a standard opening; i.e. without matching transpositions. tryToMatchViaJoiningMove	Bool	True	whether to attempt to join the current position (irrespective of the means by which it was achieved) to a standard opening that's only one move away.-tryToMatchColourFlippedPosition	Bool	True	whether to attempt to match a colour-flipped (\fBhttps://chessprogramming.wikispaces.com/Color+Flipping\fR) version of the current position with a standard opening.+tryToMatchColourFlippedPosition	Bool	True	whether to attempt to match a colour-flipped (<\fBhttps://chessprogramming.wikispaces.com/Color+Flipping\fR>) version of the current position with a standard opening. .TE .IP \(bu \fBsearchDepth\fR \fIInt\fR, defaulting to "\fB4\fR" (minimum "\fB1\fR"): the number of plies (half moves) to search ahead, when selecting the next move.@@ -148,7 +148,7 @@ .IP \(bu \fBmaximumPGNNames\fR \fIInt\fR: the optional maximum number of names, with which to annotate moves matching games from the configured PGN-databases. .IP \(bu-\fBpgnOptions\fR: these options allow one to reference PGN-databases, which the application can leverage during move-selection; \fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR .+\fBpgnOptions\fR: these options allow one to reference PGN-databases, which the application can leverage during move-selection; <\fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR>. .TS lb	lb	lb	lb l	l	l	l@@ -159,6 +159,7 @@ minimumPlies	\fIInt\fR	1	The minimum number of half moves, for an archived game to be considered valuable. isStrictlySequential	(\fBTrue\fR|\fBFalse\fR)	True	Whether the recorded move-numbers are accurate. validateMoves	(\fBTrue\fR|\fBFalse\fR)	False	Whether to validate all the moves. In the absence of validation, PGN-databases can be read faster, but the consequence of reading invalid moves is unpredictable. This option is required to read games which continued after a draw can be inferred.+textEncoding	(\fBISO8859-1(checked)\fR|\fButf8\fR|\fButf16\fR|\fButf32\fR)	utf8	Defines the conversion-scheme between byte-sequences & Unicode characters. identificationTags	String		The PGN-field(s) from which to construct a composite identifier for a game. .TE .IP \(bu@@ -175,7 +176,7 @@ .P "\fBioOptions\fR" has a sub-section "\fBuiOptions\fR", which defines the user-interface. .IP \(bu-\fBmoveNotation\fR (\fBCoordinate\fR|\fBICCFNumeric\fR|\fBSmith\fR), defaulting to "\fBSmith\fR"; \fBhttps://en.wikipedia.org/wiki/Chess_notation\fR . The expected syntax used to define a move.+\fBmoveNotation\fR (\fBCoordinate\fR|\fBICCFNumeric\fR|\fBSmith\fR), defaulting to "\fBSmith\fR"; <\fBhttps://en.wikipedia.org/wiki/Chess_notation\fR>. The expected syntax used to define a move. This application also understands \fBStandard Algebraic\fR notation, but it is only used to read the PGN-databases used to define standard openings. .IP \(bu \fBprintMoveTree\fR \fIInt\fR.@@ -226,8 +227,8 @@ config/bishbosh.rng	A more sophisticated, but slower, \fBRELAX NG\fR definition of the XML-format for the configuration-file. config/{CECP,Raw}/*.xml	Sample configuration-files. man/man1/bishbosh.1	Section-1 of the man-pages for this product, describing the command-line.-pgn/*.pgn	Standard openings & archived games, described in \fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR .-https://www.oasis-open.org/committees/relax-ng/tutorial-20011203.html	A \fBRELAX NG\fR tutorial.+pgn/*.pgn	Standard openings & archived games, described in <\fBhttps://en.wikipedia.org/wiki/Portable_Game_Notation\fR>.+<https://www.oasis-open.org/committees/relax-ng/tutorial-20011203.html>	A \fBRELAX NG\fR tutorial. .TE .SH AUTHOR Written by Dr. Alistair Ward.@@ -238,5 +239,5 @@ .PP This program 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. .PP-You should have received a copy of the GNU General Public License along with this program. If not, see \fBhttp://www.gnu.org/licenses/\fR .+You should have received a copy of the GNU General Public License along with this program. If not, see <\fBhttps://www.gnu.org/licenses/\fR>. 
src-exe/BishBosh/Input/CommandLineOption.hs view
@@ -115,11 +115,11 @@ readArg	= read' "failed to parse command-line argument "  -- | Reads a bounded integral from the command-line, guarding against overflow.-readBoundedIntegral :: (Integral i, Read i, Show i) => String -> i+readBoundedIntegral :: Integral i => String -> i readBoundedIntegral s-	| bounded /= unbounded	= Control.Exception.throw . Data.Exception.mkOutOfBounds . showString "BishBosh.Input.CommandLineOption.readBoundedIntegral:\tintegral value exceeds permissible bounds; " $ shows unbounded "."-	| otherwise		= bounded+	| fromIntegral bounded /= unbounded	= Control.Exception.throw . Data.Exception.mkOutOfBounds . showString "BishBosh.Input.CommandLineOption.readBoundedIntegral:\tintegral value exceeds permissible bounds; " $ shows unbounded "."+	| otherwise				= bounded 	where 		unbounded	= readArg s-		bounded		= unbounded+		bounded		= fromInteger unbounded 
src-exe/Main.hs view
@@ -409,6 +409,8 @@ 										) ( 											Input.PGNOptions.getValidateMoves pgnOptions 										) (+											Input.PGNOptions.getTextEncoding pgnOptions+										) ( 											Input.PGNOptions.getIdentificationTags pgnOptions 										) 									) . Data.Maybe.listToMaybe =<< ToolShed.System.File.locate pgnDatabaseFilePath searchPath
src-lib/BishBosh/ContextualNotation/PGNDatabase.hs view
@@ -36,7 +36,9 @@ import qualified	BishBosh.ContextualNotation.PGN			as ContextualNotation.PGN import qualified	BishBosh.ContextualNotation.StandardAlgebraic	as ContextualNotation.StandardAlgebraic import qualified	BishBosh.Types					as T+import qualified	Control.DeepSeq import qualified	System.FilePath+import qualified	System.IO  #ifdef USE_POLYPARSE import qualified	BishBosh.Text.Poly				as Text.Poly@@ -118,8 +120,14 @@ 	=> System.FilePath.FilePath 	-> ContextualNotation.PGN.IsStrictlySequential 	-> ContextualNotation.StandardAlgebraic.ValidateMoves+	-> System.IO.TextEncoding	-- ^ The conversion-scheme between byte-sequences & Unicode characters. 	-> [ContextualNotation.PGN.Tag] 	-> IO (Either String (PGNDatabase x y))-{-# SPECIALISE parseIO :: System.FilePath.FilePath -> ContextualNotation.PGN.IsStrictlySequential -> ContextualNotation.StandardAlgebraic.ValidateMoves -> [ContextualNotation.PGN.Tag] -> IO (Either String (PGNDatabase T.X T.Y)) #-}-parseIO filePath isStrictlySequential validateMoves identificationTags	= parse filePath isStrictlySequential validateMoves identificationTags `fmap` readFile filePath+{-# SPECIALISE parseIO :: System.FilePath.FilePath -> ContextualNotation.PGN.IsStrictlySequential -> ContextualNotation.StandardAlgebraic.ValidateMoves -> System.IO.TextEncoding -> [ContextualNotation.PGN.Tag] -> IO (Either String (PGNDatabase T.X T.Y)) #-}+parseIO filePath isStrictlySequential validateMoves textEncoding identificationTags	= System.IO.withFile filePath System.IO.ReadMode $ \fileHandle -> do+	System.IO.hSetEncoding fileHandle textEncoding++	contents	<- System.IO.hGetContents fileHandle++	Control.DeepSeq.deepseq contents {-CAVEAT: evaluate before the file is closed-} . return $ parse filePath isStrictlySequential validateMoves identificationTags contents 
src-lib/BishBosh/Input/PGNOptions.hs view
@@ -31,6 +31,7 @@ 		getDatabaseFilePath, 		getIsStrictlySequential, 		getValidateMoves,+		getTextEncoding, 		getIdentificationTags, 		getMinimumPlies 	),@@ -48,11 +49,13 @@ import qualified	BishBosh.ContextualNotation.PGN			as ContextualNotation.PGN import qualified	BishBosh.ContextualNotation.StandardAlgebraic	as ContextualNotation.StandardAlgebraic import qualified	BishBosh.Data.Exception				as Data.Exception+import qualified	BishBosh.Text.Encoding				as Text.Encoding import qualified	BishBosh.Text.ShowList				as Text.ShowList import qualified	Control.DeepSeq import qualified	Control.Exception import qualified	Data.Default import qualified	System.FilePath+import qualified	System.IO import qualified	Text.XML.HXT.Arrow.Pickle			as HXT import qualified	ToolShed.Data.Foldable @@ -85,6 +88,7 @@ 	getDatabaseFilePath	:: System.FilePath.FilePath,				-- ^ Path to a PGN-database file. 	getIsStrictlySequential	:: ContextualNotation.PGN.IsStrictlySequential,		-- ^ Whether moves with an unexpected number should be considered to be an error. 	getValidateMoves	:: ContextualNotation.StandardAlgebraic.ValidateMoves,	-- ^ Whether moves should be validated, which can become tedious if they're already known to be valid.+	getTextEncoding		:: System.IO.TextEncoding,				-- ^ The conversion-scheme between byte-sequences & Unicode characters. 	getIdentificationTags	:: [ContextualNotation.PGN.Tag],			-- ^ The tags to extract from this PGN-database to form a unique composite game-identifier. 	getMinimumPlies		:: Component.Move.NMoves				-- ^ The minimum number of half moves, for the game to be considered useful; most short games result from "forfeit by disconnection". } deriving Eq@@ -103,6 +107,7 @@ 		getDatabaseFilePath	= databaseFilePath, 		getIsStrictlySequential	= isStrictlySequential, 		getValidateMoves	= validateMoves,+		getTextEncoding		= textEncoding, 		getIdentificationTags	= identificationTags, 		getMinimumPlies		= minimumPlies 	} = Text.ShowList.showsAssociationList' [@@ -116,6 +121,9 @@ 			validateMovesTag, 			shows validateMoves 		), (+			Text.Encoding.tag,+			shows textEncoding+		), ( 			showString identificationTagTag "s", 			shows identificationTags 		), (@@ -129,27 +137,29 @@ 		getDatabaseFilePath	= "pgn/bishbosh.pgn",	-- CAVEAT: rather arbitrary. 		getIsStrictlySequential	= True, 		getValidateMoves	= True,+		getTextEncoding		= Data.Default.def, 		getIdentificationTags	= ["ECO", "Variation"],	-- CAVEAT: rather arbitrary. 		getMinimumPlies		= 1 	}  instance HXT.XmlPickler PGNOptions where 	xpickle	= HXT.xpElem tag . HXT.xpWrap (-		\(a, b, c, d, e) -> mkPGNOptions a b c d e,	-- Construct.+		\(a, b, c, d, e, f) -> mkPGNOptions a b c d e f,	-- Construct. 		\MkPGNOptions { 			getDatabaseFilePath	= databaseFilePath, 			getIsStrictlySequential	= isStrictlySequential, 			getValidateMoves	= validateMoves,+			getTextEncoding		= textEncoding, 			getIdentificationTags	= identificationTags, 			getMinimumPlies		= minimumPlies-		} -> (databaseFilePath, isStrictlySequential, validateMoves, identificationTags, minimumPlies) -- Deconstruct.-	 ) $ HXT.xp5Tuple (+		} -> (databaseFilePath, isStrictlySequential, validateMoves, textEncoding, identificationTags, minimumPlies) -- Deconstruct.+	 ) $ HXT.xp6Tuple ( 		HXT.xpTextAttr databaseFilePathTag 	 ) ( 		getIsStrictlySequential def `HXT.xpDefault` HXT.xpAttr isStrictlySequentialTag HXT.xpickle {-Bool-} 	 ) ( 		getValidateMoves def `HXT.xpDefault` HXT.xpAttr validateMovesTag HXT.xpickle {-Bool-}-	 ) (+	 ) HXT.xpickle {-TextEncoding-} ( 		HXT.xpList . HXT.xpElem identificationTagTag $ HXT.xpTextAttr "tag" 	 ) ( 		getMinimumPlies def `HXT.xpDefault` HXT.xpAttr minimumPliesTag HXT.xpickle {-NMoves-}@@ -161,10 +171,11 @@ 	:: System.FilePath.FilePath	-- ^ Database file-path. 	-> ContextualNotation.PGN.IsStrictlySequential 	-> ContextualNotation.StandardAlgebraic.ValidateMoves+	-> System.IO.TextEncoding 	-> [ContextualNotation.PGN.Tag]	-- ^ Optional identification tags. 	-> Component.Move.NMoves	-- ^ The minimum plies. 	-> PGNOptions-mkPGNOptions databaseFilePath isStrictlySequential validateMoves identificationTags minimumPlies+mkPGNOptions databaseFilePath isStrictlySequential validateMoves textEncoding identificationTags minimumPlies 	| not $ System.FilePath.isValid databaseFilePath	= Control.Exception.throw . Data.Exception.mkInvalidDatum . showString "BishBosh.Input.PGNOptions.mkPGNOptions:\tinvalid " . showString databaseFilePathTag . Text.ShowList.showsAssociation $ shows databaseFilePath "." 	| any null identificationTags				= Control.Exception.throw . Data.Exception.mkNullDatum . showString "BishBosh.Input.PGNOptions.mkPGNOptions:\tno " $ shows identificationTagTag " can be null." 	| duplicateTags@(_ : _)	<- map head . filter ((/= 1) . length) $ ToolShed.Data.Foldable.gather identificationTags@@ -174,6 +185,7 @@ 		getDatabaseFilePath	= System.FilePath.normalise databaseFilePath, 		getIsStrictlySequential	= isStrictlySequential, 		getValidateMoves	= validateMoves,+		getTextEncoding		= textEncoding, 		getIdentificationTags	= identificationTags, 		getMinimumPlies		= minimumPlies 	}
+ src-lib/BishBosh/Text/Encoding.hs view
@@ -0,0 +1,67 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+	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 instances for 'System.IO.TextEncoding'.+-}++module BishBosh.Text.Encoding (+-- * Constants+	tag,+	range+ ) where++import qualified	Data.Default+import qualified	Data.List.Extra+import qualified	Text.XML.HXT.Arrow.Pickle	as HXT+import qualified	Text.XML.HXT.Arrow.Pickle.Schema+import qualified	System.IO++tag :: String+tag	= "textEncoding"++instance Eq System.IO.TextEncoding where+	l == r	= show l == show r++instance Read System.IO.TextEncoding where+	readsPrec _ s	= case Data.List.Extra.trimStart s of+		'I':'S':'O':'8':'8':'5':'9':'-':'1':remainder	-> return {-to List-monad-} . (,) System.IO.latin1 $ case remainder of+			'(':'c':'h':'e':'c':'k':'e':'d':')':remainder2	-> remainder2	-- Junk.+			_						-> remainder+		'U':'T':'F':'-':'8':remainder			-> [(System.IO.utf8, remainder)]+		'U':'T':'F':'-':'1':'6':remainder		-> [(System.IO.utf16, remainder)]+		'U':'T':'F':'-':'3':'2':remainder		-> [(System.IO.utf32, remainder)]+		_						-> []	-- No parse.++instance HXT.XmlPickler System.IO.TextEncoding where+	xpickle	= HXT.xpDefault Data.Default.def . HXT.xpWrap (read, show) . HXT.xpAttr tag . HXT.xpTextDT . Text.XML.HXT.Arrow.Pickle.Schema.scEnum $ map show range++instance Data.Default.Default System.IO.TextEncoding where+	def	= System.IO.utf8++-- | The constant range of /Text-encoding/s.+range :: [System.IO.TextEncoding]+range	= [+	System.IO.latin1,+	System.IO.utf8,+	System.IO.utf16,+	System.IO.utf32+ ]
src-test/BishBosh/Test/QuickCheck/Input/PGNOptions.hs view
@@ -26,6 +26,7 @@ module BishBosh.Test.QuickCheck.Input.PGNOptions() where  import qualified	BishBosh.Input.PGNOptions	as Input.PGNOptions+import			BishBosh.Test.QuickCheck.Text.Encoding() import qualified	System.FilePath import qualified	Test.QuickCheck import			System.FilePath((</>), (<.>))@@ -33,7 +34,7 @@ instance Test.QuickCheck.Arbitrary Input.PGNOptions.PGNOptions where 	arbitrary	= Input.PGNOptions.mkPGNOptions ( 		showChar System.FilePath.pathSeparator $ "tmp" </> "database" <.> "pgn"-	 ) <$> Test.QuickCheck.arbitrary {-isStrictlySequential-} <*> Test.QuickCheck.arbitrary {-validateMoves-} <*> Test.QuickCheck.elements [+	 ) <$> Test.QuickCheck.arbitrary {-isStrictlySequential-} <*> Test.QuickCheck.arbitrary {-validateMoves-} <*> Test.QuickCheck.arbitrary {-text-encoding-} <*> Test.QuickCheck.elements [ 		["FICSGamesDBGameNo"], 		["ECO"], 		["FICSGamesDBGameNo", "ECO"]
+ src-test/BishBosh/Test/QuickCheck/Text/Encoding.hs view
@@ -0,0 +1,57 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+	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 /QuickCheck/-properties.+-}++module BishBosh.Test.QuickCheck.Text.Encoding (+-- * Constants+	results+) where++import qualified	BishBosh.Text.Encoding	as Text.Encoding+import qualified	System.IO+import qualified	Test.QuickCheck+import qualified	ToolShed.Test.ReversibleIO++instance Test.QuickCheck.Arbitrary System.IO.TextEncoding where+	arbitrary	= Test.QuickCheck.elements Text.Encoding.range++-- | The constant test-results.+results :: IO [Test.QuickCheck.Result]+results	= sequence [+	let+		f :: System.IO.TextEncoding -> Test.QuickCheck.Property+		f	= Test.QuickCheck.label "Text.Encoding.prop_readPrependedWhiteSpace" . ToolShed.Test.ReversibleIO.readPrependedWhiteSpace+	in Test.QuickCheck.quickCheckWithResult Test.QuickCheck.stdArgs { Test.QuickCheck.maxSuccess = 256 } f,+	let+		f :: String -> Test.QuickCheck.Property+		f garbage	= Test.QuickCheck.label "Text.Encoding.prop_read" $ case (reads garbage :: [(System.IO.TextEncoding, String)]) of+			[_]	-> True+			_	-> True	-- Unless the read-implementation throws an exception.+	in Test.QuickCheck.quickCheckWithResult Test.QuickCheck.stdArgs { Test.QuickCheck.maxSuccess = 256 } f,+	let+		f :: System.IO.TextEncoding -> String -> Test.QuickCheck.Property+		f textEncoding	= Test.QuickCheck.label "Text.Encoding.prop_readTrailingGarbage" . ToolShed.Test.ReversibleIO.readTrailingGarbage (const False) textEncoding+	in Test.QuickCheck.quickCheckWithResult Test.QuickCheck.stdArgs { Test.QuickCheck.maxSuccess = 256 } f+ ]+
src-test/Main.hs view
@@ -79,6 +79,7 @@ import qualified	BishBosh.Test.QuickCheck.State.InstancesByPosition				as Test.QuickCheck.State.InstancesByPosition import qualified	BishBosh.Test.QuickCheck.State.Position						as Test.QuickCheck.State.Position import qualified	BishBosh.Test.QuickCheck.State.TurnsByLogicalColour				as Test.QuickCheck.State.TurnsByLogicalColour+import qualified	BishBosh.Test.QuickCheck.Text.Encoding						as Test.QuickCheck.Text.Encoding import qualified	BishBosh.Test.QuickCheck.UI.Command						as Test.QuickCheck.UI.Command import qualified	BishBosh.Test.QuickCheck.UI.PrintObject						as Test.QuickCheck.UI.PrintObject import qualified	BishBosh.Test.QuickCheck.UI.SetObject						as Test.QuickCheck.UI.SetObject@@ -112,6 +113,7 @@ 	(`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful =<<  ) [ 	Test.QuickCheck.Data.Integral.results,+	Test.QuickCheck.Text.Encoding.results, 	Test.QuickCheck.Attribute.LogicalColour.results, 	Test.QuickCheck.Attribute.Direction.results, 	Test.QuickCheck.Attribute.Rank.results,