fix(q_learning): incorrect calculation of target value
This commit is contained in:
1 parent
a61fac18ed
commit
05b10a5e71
1 file changed
+5
-5
+5
-5
@@ -137,16 +137,16 @@ impl<E: Environment> Policy<E> for GreedyPolicy<E> {
|
|||||||
finished: bool,
|
finished: bool,
|
||||||
) {
|
) {
|
||||||
let former_value = *self.qtable.get(&(state, action)).unwrap_or(&0f32);
|
let former_value = *self.qtable.get(&(state, action)).unwrap_or(&0f32);
|
||||||
let target = match finished {
|
let target = reward
|
||||||
true => {
|
+ match finished {
|
||||||
reward
|
false => {
|
||||||
+ self.gamma
|
self.gamma
|
||||||
* self
|
* self
|
||||||
.qtable
|
.qtable
|
||||||
.get(&(next_state.into(), self.choose_action(next_state.into())))
|
.get(&(next_state.into(), self.choose_action(next_state.into())))
|
||||||
.unwrap_or(&0f32)
|
.unwrap_or(&0f32)
|
||||||
}
|
}
|
||||||
false => 0f32,
|
true => 0f32,
|
||||||
};
|
};
|
||||||
self.qtable.insert(
|
self.qtable.insert(
|
||||||
(state, action),
|
(state, action),
|
||||||
|
|||||||
Reference in new issue
Block a user