Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Constants and data types for property values used in SGF game trees.
- supportedFormatVersions :: [Int]
- defaultFormatVersion :: Int
- supportedGameTypes :: [Int]
- boardSizeDefault :: Int
- boardSizeMin :: Int
- boardSizeMax :: Int
- type Coord = (Int, Int)
- data CoordList
- coordListSingles :: CoordList -> [Coord]
- coordListRects :: CoordList -> [(Coord, Coord)]
- coord1 :: Coord -> CoordList
- coords :: [Coord] -> CoordList
- coords' :: [Coord] -> [(Coord, Coord)] -> CoordList
- emptyCoordList :: CoordList
- expandCoordList :: CoordList -> [Coord]
- buildCoordList :: [Coord] -> CoordList
- starLines :: Int -> Int -> Maybe [Int]
- isStarPoint :: Int -> Int -> Int -> Int -> Bool
- handicapStones :: Int -> Int -> Int -> Maybe [Coord]
- class Stringlike a where
- convertStringlike :: (Stringlike a, Stringlike b) => a -> b
- data Text
- fromText :: Text -> String
- toText :: String -> Text
- data SimpleText
- fromSimpleText :: SimpleText -> String
- toSimpleText :: String -> SimpleText
- data UnknownPropertyValue
- fromUnknownPropertyValue :: UnknownPropertyValue -> String
- toUnknownPropertyValue :: String -> UnknownPropertyValue
- type RealValue = Bigfloat
- data DoubleValue
- data Color
- cnot :: Color -> Color
- data VariationMode = VariationMode {}
- data VariationModeSource
- defaultVariationMode :: VariationMode
- toVariationMode :: Int -> Maybe VariationMode
- fromVariationMode :: VariationMode -> Int
- type ArrowList = [(Coord, Coord)]
- type LineList = [Line]
- data Line = Line Coord Coord
- lineToPair :: Line -> (Coord, Coord)
- type LabelList = [(Coord, SimpleText)]
- data Mark
- data GameResult
- data WinReason
- data Ruleset
- data RulesetType
- fromRuleset :: Ruleset -> String
- toRuleset :: String -> Ruleset
Constants
supportedFormatVersions :: [Int] Source #
The FF versions supported by Goatee. Currently only 4.
defaultFormatVersion :: Int Source #
The default SGF version to use when FF[]
is not specified in a root node.
This value is actually INCORRECT: SGF defines it to be 1, but because we don't support version 1 yet, for the sake of ignoring this issue (for now!) in tests, we fix the default to be 4.
supportedGameTypes :: [Int] Source #
SGF supports multiple game types. This list contains the game types that Goatee supports, which is only Go (1).
boardSizeDefault :: Int Source #
The default size of the board. The FF[4] SGF spec says that the default Go board is 19x19 square.
boardSizeMin :: Int Source #
The minimum board size allowed by FF[4], 1.
boardSizeMax :: Int Source #
The maximum board size allowed by FF[4], 52.
Board coordinates
type Coord = (Int, Int) Source #
A coordinate on a Go board. (0, 0)
refers to the upper-left corner of
the board. The first component is the horizontal position; the second
component is the vertical position.
A structure for compact representation of a list of coordinates. Contains
a list of individual points, as well as a list of rectangles of points
denoted by an ordered pair of the upper-left point and the lower-right point.
The union of the single points and points contained within rectangles make up
all of the points a CoordList
represents. There is no rule saying that
adjacent points have to be grouped into rectangles; it's perfectly valid
(although possibly inefficient) to never use rectangles.
For any CoordList
, all of the following hold:
- Any point may be specified at most once, either in the singles list or in a single rectangle.
- For a rectangle
((x0,y0), (x1,y1))
,x0 <= x1
andy0 <= y1
and(x0,y0) /= (x1,y1)
(otherwise the point belongs in the singles list).
coords :: [Coord] -> CoordList Source #
Constructs a CoordList
containing the given single points. For rectangle
detection, use buildCoordList
.
coords' :: [Coord] -> [(Coord, Coord)] -> CoordList Source #
Constructs a CoordList
containing the given single points and rectangles.
emptyCoordList :: CoordList Source #
A CoordList
that contains no points.
expandCoordList :: CoordList -> [Coord] Source #
Converts a compact CoordList
to a list of coordinates.
buildCoordList :: [Coord] -> CoordList Source #
Star points and handicap stones
isStarPoint :: Int -> Int -> Int -> Int -> Bool Source #
isStarPoint width height x y
determines whether (x, y)
is a known star
point on a board of the given width and height.
handicapStones :: Int -> Int -> Int -> Maybe [Coord] Source #
handicapStones width height handicap
returns a list of points where
handicap stones should be placed for the given handicap, if handicap points
are defined for the given board size, otherwise Nothing
.
Property values
Text values
class Stringlike a where Source #
A class for SGF data types that are coercable to and from strings.
The construction of an SGF value with stringToSgf
may process the input,
such that the resulting stringlike value does not represent the same string
as the input. In other words, the following does *not* necessarily hold:
sgfToString . stringToSgf = id (does not necessarily hold!)
The following does hold, however, for a single stringlike type:
stringToSgf . sgfToString = id
The String
instance is defined with sgfToString = stringToSgf =
id
. For other types, the string returned by sgfToString
is in a
raw, user-editable format: characters that need to be escaped in
serialized SGF aren't escaped, but the returned value is otherwise
similar to SGF format.
sgfToString :: a -> String Source #
Extracts the string value from an SGF value.
stringToSgf :: String -> a Source #
Creates an SGF value from a string value.
convertStringlike :: (Stringlike a, Stringlike b) => a -> b Source #
Converts between Stringlike
types via a string.
convertStringlike = stringToSgf . sgfToString
data SimpleText Source #
An SGF SimpleText value.
fromSimpleText :: SimpleText -> String Source #
Converts an SGF SimpleText
to a string.
toSimpleText :: String -> SimpleText Source #
Converts a string to an SGF SimpleText
, replacing all whitespaces
(including newlines) with spaces.
Other values
data UnknownPropertyValue Source #
The value type for an UnknownProperty
. Currently represented as a
string.
fromUnknownPropertyValue :: UnknownPropertyValue -> String Source #
Returns the string contained within the UnknownProperty
this value is
from.
toUnknownPropertyValue :: String -> UnknownPropertyValue Source #
Constructs a value for a UnknownProperty
.
data DoubleValue Source #
An SGF double value: either 1 or 2, nothing else.
Stone color: black or white.
cnot :: Color -> Color Source #
Returns the logical negation of a stone color, yang for yin and yin for yang.
data VariationMode Source #
SGF flags that control how move variations are to be presented while displaying the game.
VariationMode | |
|
data VariationModeSource Source #
An enumeration that describes which variations are shown.
ShowChildVariations | Show children of the current move. |
ShowCurrentVariations | Show alternatives to the current move. |
defaultVariationMode :: VariationMode Source #
The default variation mode as defined by the SGF spec is VariationMode
ShowChildVariations True
.
toVariationMode :: Int -> Maybe VariationMode Source #
Parses a numeric variation mode, returning nothing if the number is invalid.
fromVariationMode :: VariationMode -> Int Source #
Returns the integer value for a variation mode.
type ArrowList = [(Coord, Coord)] Source #
A list of arrows, each specified as (startCoord, endCoord)
.
An undirected line between two coordinates.
type LabelList = [(Coord, SimpleText)] Source #
A list of labels, each specified with a string and a coordinate about which to center the string.
The markings that SGF supports annotating coordinates with.
data GameResult Source #
A ruleset used for a Go game. Can be one of the rulesets defined by the SGF specification, or a custom string.
data RulesetType Source #
The rulesets defined by the SGF specification, for use with Ruleset
.
fromRuleset :: Ruleset -> String Source #
Returns the string representation for a ruleset.