-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ultimatum.hs
38 lines (27 loc) · 1.26 KB
/
Ultimatum.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
module Ultimatum where
import GameHelper
data MovesUltimatum1 = Fair | Unfair deriving Eq
instance Show (MovesUltimatum1) where
show Fair = "Fair"
show Unfair = "Unfair"
data MovesUltimatum2 = Accept | Reject deriving Eq
instance Show (MovesUltimatum2) where
show Accept = "Accept"
show Reject = "Reject"
instance Listable (MovesUltimatum1) where
list = [Fair, Unfair]
instance Listable (MovesUltimatum2) where
list = [Accept, Reject]
payoffUltimatum :: (MovesUltimatum1, MovesUltimatum2) -> (Double, Double)
payoffUltimatum (Fair, Accept) = (5, 5)
payoffUltimatum (Fair, Reject) = (0, 0)
payoffUltimatum (Unfair, Accept) = (8, 2)
payoffUltimatum (Unfair, Reject) = (0, 0)
first_stage :: ParaLens MovesUltimatum1 Double () () MovesUltimatum1 Double
first_stage = corner
interlude :: Lens x r (x, x) ((), r)
interlude = MkLens (\x -> (x, x), \_ ((), r) -> r)
second_stage :: ParaLens (MovesUltimatum1 -> MovesUltimatum2) Double MovesUltimatum1 () MovesUltimatum2 Double
second_stage = MkLens (eval_play, \_ r -> (r, ()))
arenaUltimatum = (first_stage >^-> interlude) >^^> (second_stage #^-# idlens) >^-> exchange
gameUltimatum = (argmax_player' #--# argmax_player') *** nashator *** parardiff (arenaUltimatum >^-> (fun2costate (payoffUltimatum))) >--> runitor