This commit is contained in:
narawat lamaiin
2024-05-05 07:03:52 +07:00
parent 8907156522
commit 8f3132c7cd
2 changed files with 30 additions and 18 deletions

View File

@@ -331,27 +331,35 @@ end
a game state
# Return
- `(isterminal, reward)::Tuple{Bool, Number}`
- `(isterminalstate, reward)::Tuple{Bool, <:Number}`
# Example
```jldoctest
julia>
```
# TODO
- [x] update docstring
- [TESTING] implement the function
# Signature
"""
function isterminal(state::T)::Tuple{Bool, Number} where {T<:AbstractDict}
function isterminal(state::T)::Tuple{Bool, <:Number} where {T<:AbstractDict}
latestObservationKey, _ = GeneralUtils.findHighestIndexKey(state[:thoughtHistory], "Observation")
latestObservation = state[:thoughtHistory][latestObservationKey]
# terminal condition is when the user select wine by putting <<winename>> in latest observation
if occursin("<<", latestObservation) && occursin(">>", latestObservation)
return true, 1
if latestObservation !== nothing
# terminal condition is when the user select wine by putting <<winename>> in latest observation
if occursin("<<", latestObservation) && occursin(">>", latestObservation)
isterminalstate = true
reward = 1
else
isterminalstate = false
reward = 0
end
else
isterminalstate = false
reward = 0
end
return (isterminalstate, reward)
end