Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tourney.VM
Synopsis
- data VM
- setup :: Tournament t -> PlayerCount -> IO VM
- loop :: VM -> IO (Vector StepCodeEvent)
- simulateWith :: MonadIO m => VM -> (Vector (Points, Player) -> Match -> m Result) -> m ()
- simulateByEloDistribution :: Vector Float -> VM -> IO (Vector Float)
- inversions :: Ord a => Vector a -> Vector a
- countInversions :: Ord a => Vector a -> Int
- data StepCodeEvent
- data StepContinue
- = NeedResults'Sorting !RoundNo !(Vector Match)
- | NeedResults'EndRound !RoundNo !(Vector Match)
- | Continue !StepInfo
- getCodeSoFar :: VM -> IO Code
- getMatches :: VM -> IO (MapByRound (MapByMatches (Maybe Result)))
- getStandingsHistory :: VM -> IO (MapByRound StandingsUpdate)
- getPendingMatches :: VM -> IO (Vector Match)
- getRoundNo :: VM -> IO RoundNo
- peekCode :: VM -> IO Code
- setMatchResult :: VM -> RoundNo -> Match -> Result -> IO Bool
- getMatch :: VM -> RoundNo -> Match -> IO (Maybe (Maybe Result))
- type Code = Vector TourneyOp
- data TourneyOp
- newtype MapByRound a = ByRound (IntMap a)
- newtype MapByMatches a = ByMatches (IntMap (IntMap a))
- data Match where
- data Result = Result !Points !Points
- data MatchResult = MatchResult {}
- data StandingsUpdate = StandingsUpdate {}
Documentation
An encapsulation of both a compiler and an interpreter of tournaments.
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
or Stepped
('NeedResults'Sorting' _ matches)
'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.
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
Functions for interacting with a VM
data StepCodeEvent Source #
An event generated by stepping the VM
Constructors
NoCode | |
Stepped StepContinue |
Instances
Show StepCodeEvent Source # | |
Defined in Tourney.VM | |
Eq StepCodeEvent Source # | |
Defined in Tourney.VM Methods (==) :: StepCodeEvent -> StepCodeEvent -> Bool Source # (/=) :: StepCodeEvent -> StepCodeEvent -> Bool Source # |
data StepContinue Source #
Constructors
NeedResults'Sorting !RoundNo !(Vector Match) | |
NeedResults'EndRound !RoundNo !(Vector Match) | |
Continue !StepInfo |
Instances
Show StepContinue Source # | |
Defined in Tourney.VM.Interpret | |
Eq StepContinue Source # | |
Defined in Tourney.VM.Interpret Methods (==) :: StepContinue -> StepContinue -> Bool Source # (/=) :: StepContinue -> StepContinue -> Bool Source # |
getMatches :: VM -> IO (MapByRound (MapByMatches (Maybe Result))) Source #
getStandingsHistory :: VM -> IO (MapByRound StandingsUpdate) Source #
Re-exports
Constructors
MATCH !Match | |
BEGIN_ROUND | Begin a round |
END_ROUND | End a round |
PERFORM_SORTING !Focus !SortMethod | Cause the current sorting network to evaluate |
Instances
Show TourneyOp Source # | |
Eq TourneyOp Source # | |
Ord TourneyOp Source # | |
Defined in Tourney.VM.Code |
newtype MapByRound a Source #
Instances
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.
Instances
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.
Instances
Instances
Generic Result Source # | |
Show Result Source # | |
Eq Result Source # | |
Ord Result Source # | |
type Rep Result Source # | |
Defined in Tourney.Match type Rep Result = D1 ('MetaData "Result" "Tourney.Match" "journeyman-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Result" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Points) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Points))) |
data MatchResult Source #
Constructors
MatchResult | |
Instances
data StandingsUpdate Source #
Constructors
StandingsUpdate | |