diplomacy- Diplomacy board game

Copyright(c) Alexander Vieth 2015
Portabilitynon-portable (GHC only)
Safe HaskellSafe






data Province Source #

Enumeration of the places on the diplomacy board.

adjacency :: Province -> [Province] Source #

A Province p is adjacent to (borders) all Provinces in adjacency p. This is symmetric and antireflexive.

neighbours :: ProvinceTarget -> [ProvinceTarget] Source #

This is like adjacency but for ProvinceTargets, and takes into consideration the special cases of multi-coast Provinces.

commonCoasts :: ProvinceTarget -> ProvinceTarget -> [ProvinceTarget] Source #

Common neighbours which are water provinces.

supplyCentre :: Province -> Bool Source #

Indicates whether a Province is a supply centre.

supplyCentres :: [Province] Source #

All supply centres.

country :: Province -> Maybe GreatPower Source #

Some provinces belong to a country. This is useful in conjunction with supplyCentre to determine which provinces can be used by a given country to build a unit. It is distinct from the in-game notion of control. Although Brest belongs to France, it may be controlled by some other power.

pcProvince :: ProvinceCoast -> Province Source #

The Province to which a ProvinceCoast belongs.

provinceCoasts :: Province -> [ProvinceCoast] Source #

The ProvinceCoasts which belong to a Province.

provinceTargets :: Province -> [ProvinceTarget] Source #

All ProvinceTargets associated with a Province. For Provinces with 0 or 1 coast, provinceTargets p = [Normal p].

provinceTargetCluster :: ProvinceTarget -> [ProvinceTarget] Source #

All ProvinceTargets which belong to the same Province as this one.

paths :: (Province -> Bool) -> (Province -> Maybe t) -> [Province] -> [(t, Province, [Province])] Source #

A search from a list of Provinces, via 1 or more adjacent Provinces which satisfy some indicator, until another indicator is satisfied. This gives simple paths from those Provinces, via Provinces which satisfy the first indicator, to Provinces which satisfy the second indicator.

Example use case: convoy paths from a given Province.

        :: Occupation
        -> Province
        -> [(Province, [Province])]
    convoyPaths occupation convoyingFrom =
            ((x, y, zs) -> (x, y : zs))
            (paths (occupiedByFleet occupation) (coastalIndicator) [convoyingFrom])