swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.Scenario.Scoring.GenericMetrics

Description

Data types and functions applicable across different scoring methods.

Synopsis

Documentation

data Progress Source #

This is a subset of the ScenarioStatus type that excludes the NotStarted case.

Constructors

Attempted 
Completed 

Instances

Instances details
FromJSON Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

ToJSON Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Generic Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Associated Types

type Rep Progress :: Type -> Type #

Methods

from :: Progress -> Rep Progress x #

to :: Rep Progress x -> Progress #

Read Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Show Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Eq Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Ord Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

type Rep Progress Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

type Rep Progress = D1 ('MetaData "Progress" "Swarm.Game.Scenario.Scoring.GenericMetrics" "swarm-0.5.0.0-6qXEbhCmuXA4wRndqqhBu" 'False) (C1 ('MetaCons "Attempted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Completed" 'PrefixI 'False) (U1 :: Type -> Type))

data Metric a Source #

Constructors

Metric Progress a 

Instances

Instances details
FromJSON a => FromJSON (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

ToJSON a => ToJSON (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Generic (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Associated Types

type Rep (Metric a) :: Type -> Type #

Methods

from :: Metric a -> Rep (Metric a) x #

to :: Rep (Metric a) x -> Metric a #

Read a => Read (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

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

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Methods

showsPrec :: Int -> Metric a -> ShowS #

show :: Metric a -> String #

showList :: [Metric a] -> ShowS #

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

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Methods

(==) :: Metric a -> Metric a -> Bool #

(/=) :: Metric a -> Metric a -> Bool #

Ord a => Ord (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

Methods

compare :: Metric a -> Metric a -> Ordering #

(<) :: Metric a -> Metric a -> Bool #

(<=) :: Metric a -> Metric a -> Bool #

(>) :: Metric a -> Metric a -> Bool #

(>=) :: Metric a -> Metric a -> Bool #

max :: Metric a -> Metric a -> Metric a #

min :: Metric a -> Metric a -> Metric a #

type Rep (Metric a) Source # 
Instance details

Defined in Swarm.Game.Scenario.Scoring.GenericMetrics

type Rep (Metric a) = D1 ('MetaData "Metric" "Swarm.Game.Scenario.Scoring.GenericMetrics" "swarm-0.5.0.0-6qXEbhCmuXA4wRndqqhBu" 'False) (C1 ('MetaCons "Metric" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Progress) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)))

chooseBetter Source #

Arguments

:: Ord a 
=> (b -> Maybe a)

criteria; record field extractor

-> Metric b

x

-> Metric b

y

-> Metric b 

This encodes the notion of "more play is better" for incomplete games (rationale: more play = more fun), whereas "smaller inputs are better" for completed games.

Since Maybe has its own Ord instance where Nothing < Just x regardless of x, when we want to choose the minimum value we fmap Down to ensure that the Just is selected while inverting the ordering of the inner member.