Skip to content

Commit

Permalink
default_init_state does not need to be generated
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Dec 28, 2023
1 parent efd6e0c commit 3d90acc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/POMDPTools/src/Simulators/sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,15 @@ function default_init_obs(p::POMDP, s)
end
end

@generated function default_init_state(p::Union{MDP,POMDP})
if implemented(initialstate, Tuple{p})
return :(rand(Random.default_rng(), initialstate(p)))
function default_init_state(m::Union{MDP,POMDP})
if implemented(initialstate, Tuple{typeof(m)})
return rand(Random.default_rng(), initialstate(m))
else
return quote
error("""
Error in sim(::$(typeof(p))): No initial state specified.
Please supply it as a keyword argument or provide POMDPs.initialstate(::$(typeof(p))).
error("""
Error in sim(::$(typeof(m))): No initial state specified.
Please supply it as a keyword argument or provide POMDPs.initialstate(::$(typeof(m))).
""")
end
""")
end
end

0 comments on commit 3d90acc

Please sign in to comment.