-
Notifications
You must be signed in to change notification settings - Fork 0
/
World.hs
52 lines (42 loc) · 1.15 KB
/
World.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# OPTIONS -XTypeFamilies -XRankNTypes -XFlexibleContexts -XGADTs #-}
{-# OPTIONS -XScopedTypeVariables #-}
module World where
import Util
import Environment
import Model
import System.Random
import Control.Monad.State
import Control.Monad.Reader
import Data.Map (Map)
import Text.Show
import qualified Data.HashTable.IO as H
type HashTable k v = H.BasicHashTable k v
data Agent = Agent {
age :: Int,
totalReward :: Reward,
horizon :: Int,
learningPeriod :: Int,
simulations :: Int
} deriving (Show, Eq)
data NodeType = Chance | Decision deriving (Show,Eq)
type SearchTree = HashTable [Bool] SearchNode -- Use HashTable Instead?
data SearchNode = SearchNode {
rewardEstimate :: Double,
visits :: Int,
nodeType :: NodeType
} deriving (Show, Eq)
data WorldState = WorldState {
env :: EnvironmentP,
agent :: Agent,
model :: ModelP,
tree :: SearchTree,
gen :: StdGen,
history :: [Bool],
reward :: Integer,
sampleReward :: Double
}
type WorldStateT = StateT WorldState
type World a = (MonadIO m) => WorldStateT m a