-
Notifications
You must be signed in to change notification settings - Fork 11
/
RandomWalk.kt
33 lines (31 loc) · 875 Bytes
/
RandomWalk.kt
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
package lab.mars.rl.problem
import lab.mars.rl.model.impl.mdp.CNSetMDP
import lab.mars.rl.model.impl.mdp.IndexedPolicy
import lab.mars.rl.model.impl.mdp.IndexedPossible
import lab.mars.rl.util.collection.cnsetOf
import lab.mars.rl.util.collection.emptyNSet
/**
* <p>
* Created on 2017-10-10.
* </p>
*
* @author wumo
*/
object RandomWalk {
fun make(): IndexedProblem {
val mdp = CNSetMDP(1.0, 7, 1)
mdp.apply {
states[0].actions = emptyNSet()
states[6].actions = emptyNSet()
started = { states(3).rand() }
for (a in 1..5) {
states[a].actions[0].apply {
possibles = cnsetOf(IndexedPossible(states[a - 1], 0.0, 0.5),
IndexedPossible(states[a + 1], if (a == 5) 1.0 else 0.0, 0.5))
}
}
}
val policy = mdp.QFunc { 1.0 }
return Pair(mdp, IndexedPolicy(policy))
}
}