JuliaReinforcementLearning / GridWorlds.jl

Help! I'm lost in the flatland!
MIT License
46 stars 9 forks source link

Version of Frozen Lake based on the implementation #186

Open LooseTerrifyingSpaceMonkey opened 1 year ago

LooseTerrifyingSpaceMonkey commented 1 year ago

from python's gymnasium.

Sid-Bhatia-0 commented 1 year ago

Thank you for the pull request @LooseTerrifyingSpaceMonkey . Will review it by this weekend.

Sid-Bhatia-0 commented 1 year ago

Hi @LooseTerrifyingSpaceMonkey . Thanks for the PR.

I cloned your branch and tried testing the environment. But couldn't get it to work. Had you tested the environment? I am getting the following error (This probably has something to do with line 33 where default value of map_name = String.):

(base)  (frozen_lake_impl) example $ julia --project=.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.5 (2023-01-08)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(example) pkg> st
Status `~/projects/temp/GridWorlds.jl/example/Project.toml` (empty project)

(example) pkg> dev --local ../../GridWorlds.jl/
   Resolving package versions...
    Updating `~/projects/temp/GridWorlds.jl/example/Project.toml`
  [e15a9946] + GridWorlds v0.5.0 `..`
    Updating `~/projects/temp/GridWorlds.jl/example/Manifest.toml`
⌅ [1520ce14] + AbstractTrees v0.3.4
  [d842c3ba] + CommonRLInterface v0.3.1
  [34da2185] + Compat v4.6.1
  [864edb3b] + DataStructures v0.18.13
  [e15a9946] + GridWorlds v0.5.0 `..`
  [1914dd2f] + MacroTools v0.5.10
  [bac558e1] + OrderedCollections v1.6.0
⌅ [e575027e] + ReinforcementLearningBase v0.9.7
  [56f22d72] + Artifacts
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [b77e0a4c] + InteractiveUtils
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  [e66e0078] + CompilerSupportLibraries_jll v1.0.1+0
  [4536629a] + OpenBLAS_jll v0.3.20+0
  [8e850b90] + libblastrampoline_jll v5.1.1+0
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

julia> import GridWorlds as GW
[ Info: Precompiling GridWorlds [e15a9946-cd7f-4d03-83e2-6c30bacb0043]

julia> # Each environment `Env` lives in its own module `EnvModule`
       # For example, the `SingleRoomUndirected` environment lives inside the `SingleRoomUndirectedModule` module

       env = GW.FrozenLakeUndirectedModule.FrozenLakeUndirected()
Obstacle Positions: CartesianIndex{2}[CartesianIndex(140689686970704, 140689686970960), CartesianIndex(140689686971216, 140689686971472), CartesianIndex(140689686972080, 140689686972496), CartesianIndex(140689686972528, 140689686972560)] Height: 8 Width: 8
ERROR: BoundsError: attempt to access 4×10×10 BitArray{3} at index [4, 140689686970704, 140689686970960]
Stacktrace:
 [1] throw_boundserror(A::BitArray{3}, I::Tuple{Int64, Int64, Int64})
   @ Base ./abstractarray.jl:703
 [2] checkbounds
   @ ./abstractarray.jl:668 [inlined]
 [3] _setindex!
   @ ./abstractarray.jl:1366 [inlined]
 [4] setindex!
   @ ./abstractarray.jl:1344 [inlined]
 [5] update_obstacles_on_map(tile_map::BitArray{3}, obstacle_positions::Vector{CartesianIndex{2}})
   @ GridWorlds.FrozenLakeUndirectedModule ~/projects/temp/GridWorlds.jl/src/envs/frozen_lake_undirected.jl:87
 [6] GridWorlds.FrozenLakeUndirectedModule.FrozenLakeUndirected(; map_name::Type, R::Type, height::Int64, width::Int64, num_obstacles::Int64, rng::Random._GLOBAL_RNG, is_slippery::Bool)
   @ GridWorlds.FrozenLakeUndirectedModule ~/projects/temp/GridWorlds.jl/src/envs/frozen_lake_undirected.jl:71
 [7] GridWorlds.FrozenLakeUndirectedModule.FrozenLakeUndirected()
   @ GridWorlds.FrozenLakeUndirectedModule ~/projects/temp/GridWorlds.jl/src/envs/frozen_lake_undirected.jl:33
 [8] top-level scope
   @ REPL[4]:4

julia>