journeyman-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tourney.VM

Synopsis

Documentation

data VM Source #

An encapsulation of both a compiler and an interpreter of tournaments.

Instances

Instances details
Generic VM Source # 
Instance details

Defined in Tourney.VM

Associated Types

type Rep VM :: Type -> Type Source #

Methods

from :: VM -> Rep VM x Source #

to :: Rep VM x -> VM Source #

type Rep VM Source # 
Instance details

Defined in Tourney.VM

type Rep VM

Core VM functionality

setup :: Tournament t -> PlayerCount -> IO VM Source #

Create a VM from a tournament and a fixed player count.

loop :: VM -> IO (Vector StepCodeEvent) Source #

Evaluate a VM to the maximal extent allowed. Inspecting the result of this function will reveal why the tournament stopped when it did; for instance, if there are still pending matches, the final value in the StepCodeEvent vector will be Stepped ('NeedResults'Sorting' _ matches) or 'NeedResults'EndRound' _ matches

Simulations

These functions are intended for use in simulating outcomes of a tournament, to e.g. gauge how well it performs in terms of its rank preservation.

simulateWith :: MonadIO m => VM -> (Vector (Points, Player) -> Match -> m Result) -> m () Source #

simulateByEloDistribution :: Vector Float -> VM -> IO (Vector Float) Source #

Run a VM to completion, using the input Elo distribution to compute the win probabilities of each player per match. A final Elo distribution is returned which reflects changes in Elo that occured throughout the tournament.

Utilities for interpretting results of a simulation

inversions :: Ord a => Vector a -> Vector a Source #

Enumerate all the inversions of a vector

countInversions :: Ord a => Vector a -> Int Source #

Count how many inversions there are in a vector

Functions for interacting with a VM

data StepCodeEvent Source #

An event generated by stepping the VM

Constructors

NoCode 
Stepped StepContinue 

Instances

Instances details
Show StepCodeEvent Source # 
Instance details

Defined in Tourney.VM

Eq StepCodeEvent Source # 
Instance details

Defined in Tourney.VM

Re-exports

data TourneyOp Source #

Constructors

MATCH !Match 
BEGIN_ROUND

Begin a round

END_ROUND

End a round

PERFORM_SORTING !Focus !SortMethod

Cause the current sorting network to evaluate

newtype MapByRound a Source #

Constructors

ByRound (IntMap a) 

Instances

Instances details
Foldable MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

fold :: Monoid m => MapByRound m -> m Source #

foldMap :: Monoid m => (a -> m) -> MapByRound a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MapByRound a -> m Source #

foldr :: (a -> b -> b) -> b -> MapByRound a -> b Source #

foldr' :: (a -> b -> b) -> b -> MapByRound a -> b Source #

foldl :: (b -> a -> b) -> b -> MapByRound a -> b Source #

foldl' :: (b -> a -> b) -> b -> MapByRound a -> b Source #

foldr1 :: (a -> a -> a) -> MapByRound a -> a Source #

foldl1 :: (a -> a -> a) -> MapByRound a -> a Source #

toList :: MapByRound a -> [a] Source #

null :: MapByRound a -> Bool Source #

length :: MapByRound a -> Int Source #

elem :: Eq a => a -> MapByRound a -> Bool Source #

maximum :: Ord a => MapByRound a -> a Source #

minimum :: Ord a => MapByRound a -> a Source #

sum :: Num a => MapByRound a -> a Source #

product :: Num a => MapByRound a -> a Source #

Traversable MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

traverse :: Applicative f => (a -> f b) -> MapByRound a -> f (MapByRound b) Source #

sequenceA :: Applicative f => MapByRound (f a) -> f (MapByRound a) Source #

mapM :: Monad m => (a -> m b) -> MapByRound a -> m (MapByRound b) Source #

sequence :: Monad m => MapByRound (m a) -> m (MapByRound a) Source #

Functor MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

fmap :: (a -> b) -> MapByRound a -> MapByRound b Source #

(<$) :: a -> MapByRound b -> MapByRound a Source #

FoldableWithIndex RoundNo MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

ifoldMap :: Monoid m => (RoundNo -> a -> m) -> MapByRound a -> m Source #

ifoldMap' :: Monoid m => (RoundNo -> a -> m) -> MapByRound a -> m Source #

ifoldr :: (RoundNo -> a -> b -> b) -> b -> MapByRound a -> b Source #

ifoldl :: (RoundNo -> b -> a -> b) -> b -> MapByRound a -> b Source #

ifoldr' :: (RoundNo -> a -> b -> b) -> b -> MapByRound a -> b Source #

ifoldl' :: (RoundNo -> b -> a -> b) -> b -> MapByRound a -> b Source #

FunctorWithIndex RoundNo MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

imap :: (RoundNo -> a -> b) -> MapByRound a -> MapByRound b Source #

TraversableWithIndex RoundNo MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

itraverse :: Applicative f => (RoundNo -> a -> f b) -> MapByRound a -> f (MapByRound b) Source #

TraverseMax RoundNo MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

TraverseMin RoundNo MapByRound Source # 
Instance details

Defined in Tourney.Match.Matrix

Semigroup a => Monoid (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Semigroup a => Semigroup (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Show a => Show (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Eq a => Eq (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

At (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Ixed (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

AsEmpty (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

_Empty :: Prism' (MapByRound a) () Source #

type Index (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

type IxValue (MapByRound a) Source # 
Instance details

Defined in Tourney.Match.Matrix

type IxValue (MapByRound a) = a

newtype MapByMatches a Source #

A sparse matrix for storing a map between matches and a value.

Since the two players in Match are guaranteed to be ordered (low, high) we only need to ever check the low->high->match path in the nested intmaps.

Constructors

ByMatches (IntMap (IntMap a)) 

Instances

Instances details
Foldable MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

fold :: Monoid m => MapByMatches m -> m Source #

foldMap :: Monoid m => (a -> m) -> MapByMatches a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MapByMatches a -> m Source #

foldr :: (a -> b -> b) -> b -> MapByMatches a -> b Source #

foldr' :: (a -> b -> b) -> b -> MapByMatches a -> b Source #

foldl :: (b -> a -> b) -> b -> MapByMatches a -> b Source #

foldl' :: (b -> a -> b) -> b -> MapByMatches a -> b Source #

foldr1 :: (a -> a -> a) -> MapByMatches a -> a Source #

foldl1 :: (a -> a -> a) -> MapByMatches a -> a Source #

toList :: MapByMatches a -> [a] Source #

null :: MapByMatches a -> Bool Source #

length :: MapByMatches a -> Int Source #

elem :: Eq a => a -> MapByMatches a -> Bool Source #

maximum :: Ord a => MapByMatches a -> a Source #

minimum :: Ord a => MapByMatches a -> a Source #

sum :: Num a => MapByMatches a -> a Source #

product :: Num a => MapByMatches a -> a Source #

Traversable MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

traverse :: Applicative f => (a -> f b) -> MapByMatches a -> f (MapByMatches b) Source #

sequenceA :: Applicative f => MapByMatches (f a) -> f (MapByMatches a) Source #

mapM :: Monad m => (a -> m b) -> MapByMatches a -> m (MapByMatches b) Source #

sequence :: Monad m => MapByMatches (m a) -> m (MapByMatches a) Source #

Functor MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

fmap :: (a -> b) -> MapByMatches a -> MapByMatches b Source #

(<$) :: a -> MapByMatches b -> MapByMatches a Source #

FoldableWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

ifoldMap :: Monoid m => (Match -> a -> m) -> MapByMatches a -> m Source #

ifoldMap' :: Monoid m => (Match -> a -> m) -> MapByMatches a -> m Source #

ifoldr :: (Match -> a -> b -> b) -> b -> MapByMatches a -> b Source #

ifoldl :: (Match -> b -> a -> b) -> b -> MapByMatches a -> b Source #

ifoldr' :: (Match -> a -> b -> b) -> b -> MapByMatches a -> b Source #

ifoldl' :: (Match -> b -> a -> b) -> b -> MapByMatches a -> b Source #

FunctorWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

imap :: (Match -> a -> b) -> MapByMatches a -> MapByMatches b Source #

TraversableWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

itraverse :: Applicative f => (Match -> a -> f b) -> MapByMatches a -> f (MapByMatches b) Source #

Monoid (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Semigroup (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Show a => Show (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Eq a => Eq (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

At (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Ixed (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

AsEmpty (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

_Empty :: Prism' (MapByMatches a) () Source #

type Index (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

type IxValue (MapByMatches a) Source # 
Instance details

Defined in Tourney.Match.Matrix

type IxValue (MapByMatches a) = a

data Match Source #

The basic type for a match is a pair of players. The Match type ensures by construction that the "lower" player always takes the first slot of the Match, and the higher the second. Many functions in this library are overloaded so that you can represent matches as ordinary Haskell tuples.

It is a runtime error to construct a match using the same player twice.

The first field of a Match is always the smaller value. Matches with one invalid Slot for any reason should be interpretted as a bye for the valid Slot in that match.

Constructors

Match_ !Slot !Slot 

Bundled Patterns

pattern Match :: Slot -> Slot -> Match 

Instances

Instances details
Generic Match Source # 
Instance details

Defined in Tourney.Match

Associated Types

type Rep Match :: Type -> Type Source #

Methods

from :: Match -> Rep Match x Source #

to :: Rep Match x -> Match Source #

Ix Match Source # 
Instance details

Defined in Tourney.Match

Show Match Source # 
Instance details

Defined in Tourney.Match

Eq Match Source # 
Instance details

Defined in Tourney.Match

Methods

(==) :: Match -> Match -> Bool Source #

(/=) :: Match -> Match -> Bool Source #

Ord Match Source # 
Instance details

Defined in Tourney.Match

AsMatch Match Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toMatch :: Match -> Match Source #

FoldableWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

ifoldMap :: Monoid m => (Match -> a -> m) -> MapByMatches a -> m Source #

ifoldMap' :: Monoid m => (Match -> a -> m) -> MapByMatches a -> m Source #

ifoldr :: (Match -> a -> b -> b) -> b -> MapByMatches a -> b Source #

ifoldl :: (Match -> b -> a -> b) -> b -> MapByMatches a -> b Source #

ifoldr' :: (Match -> a -> b -> b) -> b -> MapByMatches a -> b Source #

ifoldl' :: (Match -> b -> a -> b) -> b -> MapByMatches a -> b Source #

FunctorWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

imap :: (Match -> a -> b) -> MapByMatches a -> MapByMatches b Source #

TraversableWithIndex Match MapByMatches Source # 
Instance details

Defined in Tourney.Match.Matrix

Methods

itraverse :: Applicative f => (Match -> a -> f b) -> MapByMatches a -> f (MapByMatches b) Source #

AsRound Match r Source # 
Instance details

Defined in Tourney.Algebra.Builder

Methods

toRound :: Match -> Round r () Source #

type Rep Match Source # 
Instance details

Defined in Tourney.Match

type Rep Match = D1 ('MetaData "Match" "Tourney.Match" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Match_" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Slot) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Slot)))

data Result Source #

Constructors

Result !Points !Points 

Instances

Instances details
Generic Result Source # 
Instance details

Defined in Tourney.Match

Associated Types

type Rep Result :: Type -> Type Source #

Show Result Source # 
Instance details

Defined in Tourney.Match

Eq Result Source # 
Instance details

Defined in Tourney.Match

Ord Result Source # 
Instance details

Defined in Tourney.Match

type Rep Result Source # 
Instance details

Defined in Tourney.Match

data MatchResult Source #

Constructors

MatchResult 

Fields

Instances

Instances details
Generic MatchResult Source # 
Instance details

Defined in Tourney.Match

Associated Types

type Rep MatchResult :: Type -> Type Source #

Show MatchResult Source # 
Instance details

Defined in Tourney.Match

Eq MatchResult Source # 
Instance details

Defined in Tourney.Match

Ord MatchResult Source # 
Instance details

Defined in Tourney.Match

type Rep MatchResult Source # 
Instance details

Defined in Tourney.Match

type Rep MatchResult = D1 ('MetaData "MatchResult" "Tourney.Match" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "MatchResult" 'PrefixI 'True) (S1 ('MetaSel ('Just "match") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Match) :*: S1 ('MetaSel ('Just "result") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Result)))

data StandingsUpdate Source #

Constructors

StandingsUpdate 

Instances

Instances details
Generic StandingsUpdate Source # 
Instance details

Defined in Tourney.VM.Interpret

Associated Types

type Rep StandingsUpdate :: Type -> Type Source #

Show StandingsUpdate Source # 
Instance details

Defined in Tourney.VM.Interpret

Eq StandingsUpdate Source # 
Instance details

Defined in Tourney.VM.Interpret

Ord StandingsUpdate Source # 
Instance details

Defined in Tourney.VM.Interpret

type Rep StandingsUpdate Source # 
Instance details

Defined in Tourney.VM.Interpret

type Rep StandingsUpdate = D1 ('MetaData "StandingsUpdate" "Tourney.VM.Interpret" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "StandingsUpdate" 'PrefixI 'True) (S1 ('MetaSel ('Just "roundNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RoundNo) :*: (S1 ('MetaSel ('Just "roundDepth") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "standings") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector (Points, Player))))))