Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/LaserTag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ function POMDPs.reward(p::LaserTagPOMDP, s::LTState, a::Int, sp::LTState)
end
end

# add a function to transform a LTState to a vector
function POMDPs.convert_s(T::Type{<:AbstractArray}, s::LTState, p::LaserTagPOMDP)
return convert(T, vcat(s.robot, s.opponent, [s.terminal]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return convert(T, vcat(s.robot, s.opponent, [s.terminal]))
return convert(T, vcat(s.robot, s.opponent, s.terminal))

I don't think you need to create a vector with s.terminal in it. That will cause an additional allocation.

(additionally, I think vcat itself might cause an allocation, which is disappointing. You might be able to eliminate all allocations with StaticArrays, but that might take a bit of learning. There are many tools to track allocations including BenchmarkTools.@btime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info!

end

POMDPs.isterminal(p::LaserTagPOMDP, s::LTState) = s.terminal
POMDPs.discount(p::LaserTagPOMDP) = p.discount

Expand Down