LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Client.AI.Strategy

Description

AI strategies to direct actors not controlled directly by human players. No operation in this module involves the `State` type or any of our client/server monads types.

Synopsis

- data Strategy a
- nullStrategy :: Strategy a -> Bool
- liftFrequency :: Frequency a -> Strategy a
- (.|) :: Strategy a -> Strategy a -> Strategy a
- reject :: Strategy a
- (.=>) :: Bool -> Strategy a -> Strategy a
- only :: (a -> Bool) -> Strategy a -> Strategy a
- bestVariant :: Strategy a -> Frequency a
- returN :: Text -> a -> Strategy a
- mapStrategyM :: Monad m => (a -> m (Maybe b)) -> Strategy a -> m (Strategy b)

# Documentation

data Strategy a Source #

A strategy is a choice of (non-empty) frequency tables of possible actions.

Currently, the way we use it, the list could have at most one element (we filter out void frequencies early and only ever access the first). except for the argument of `mapStrategyM`, which may even be process to the end of the list, if no earlier strategies can be transformed into non-null ones.

#### Instances

Instances details

Alternative Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods empty :: Strategy a Source # (<|>) :: Strategy a -> Strategy a -> Strategy a Source # some :: Strategy a -> Strategy [a] Source # many :: Strategy a -> Strategy [a] Source #
Applicative Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods pure :: a -> Strategy a Source # (<*>) :: Strategy (a -> b) -> Strategy a -> Strategy b Source # liftA2 :: (a -> b -> c) -> Strategy a -> Strategy b -> Strategy c Source # (*>) :: Strategy a -> Strategy b -> Strategy b Source # (<*) :: Strategy a -> Strategy b -> Strategy a Source #
Functor Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods fmap :: (a -> b) -> Strategy a -> Strategy b Source # (<$) :: a -> Strategy b -> Strategy a Source #
Monad Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods (>>=) :: Strategy a -> (a -> Strategy b) -> Strategy b Source # (>>) :: Strategy a -> Strategy b -> Strategy b Source # return :: a -> Strategy a Source #
MonadPlus Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods mzero :: Strategy a Source # mplus :: Strategy a -> Strategy a -> Strategy a Source #
Foldable Strategy Source # |

Instance details

Defined in Game.LambdaHack.Client.AI.Strategy

Methods

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

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

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

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

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

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

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

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

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

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

null :: Strategy a -> Bool Source #

length :: Strategy a -> Int Source #

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

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

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

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

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

Traversable Strategy Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods traverse :: Applicative f => (a -> f b) -> Strategy a -> f (Strategy b) Source # sequenceA :: Applicative f => Strategy (f a) -> f (Strategy a) Source # mapM :: Monad m => (a -> m b) -> Strategy a -> m (Strategy b) Source # sequence :: Monad m => Strategy (m a) -> m (Strategy a) Source #
Show a => Show (Strategy a) Source # |
Instance details Defined in Game.LambdaHack.Client.AI.Strategy Methods showsPrec :: Int -> Strategy a -> ShowS Source # show :: Strategy a -> String Source # showList :: [Strategy a] -> ShowS Source #

nullStrategy :: Strategy a -> Bool Source #

liftFrequency :: Frequency a -> Strategy a Source #

Strategy where only the actions from the given single frequency table can be picked.

(.|) :: Strategy a -> Strategy a -> Strategy a infixr 2 Source #

Strategy with the actions from both argument strategies, with original frequencies.

reject :: Strategy a Source #

Strategy with no actions at all.

(.=>) :: Bool -> Strategy a -> Strategy a infix 3 Source #

Conditionally accepted strategy.

only :: (a -> Bool) -> Strategy a -> Strategy a Source #

Strategy with all actions not satisfying the predicate removed. The remaining actions keep their original relative frequency values.

bestVariant :: Strategy a -> Frequency a Source #

When better choices are towards the start of the list, this is the best frequency of the strategy.

returN :: Text -> a -> Strategy a Source #

Like `return`, but pick a name of the single frequency.

mapStrategyM :: Monad m => (a -> m (Maybe b)) -> Strategy a -> m (Strategy b) Source #