JuliaML / Reinforce.jl

Abstractions, algorithms, and utilities for reinforcement learning in Julia
Other
201 stars 35 forks source link

Fixes for 1.0 #23

Closed JobJob closed 5 years ago

JobJob commented 5 years ago

Fairly minimal set of changes to get this running on 1.0, and still maintain compatibility with 0.6 for now.

Required for https://github.com/JuliaML/OpenAIGym.jl/pull/10 to work.

JobJob commented 5 years ago

So what's the verdict you want me to do anything more here?

iblislin commented 5 years ago

I need some time to test it manually

iblislin commented 5 years ago

Got this on 0.7

┌ Warning: Deprecated syntax `multiple line breaks between doc string and object` at /home/iblis/.julia/dev/Reinforce/src/Reinforce.jl:74.
│ Use `at most one line break` instead.
└ @ ~/.julia/dev/Reinforce/src/Reinforce.jl:74

patch:

diff --git a/src/Reinforce.jl b/src/Reinforce.jl
index 9ac3681..91a47ad 100644
--- a/src/Reinforce.jl
+++ b/src/Reinforce.jl
@@ -1,6 +1,3 @@
-
-__precompile__(true)
-
 module Reinforce

 using Reexport
@@ -70,7 +67,6 @@ finished(env::AbstractEnvironment, s′) = false

 Return a list/set/description of valid actions from state `s′`.
 """
-# actions(env::AbstractEnvironment) = actions(env, state(env))
 function actions end

 # note for developers: you don't need to implement these if you have state/reward fields
iblislin commented 5 years ago
WARNING: Base.srand is deprecated: it has been moved to the standard library package `Random`.
Add `using Random` to your imports.                                       
  likely near /home/iblis/.julia/dev/Reinforce/test/env/mountain_car.jl:3                     

patch:

diff --git a/src/envs/mountain_car.jl b/src/envs/mountain_car.jl
index 030fece..803b121 100644
--- a/src/envs/mountain_car.jl
+++ b/src/envs/mountain_car.jl
@@ -6,6 +6,7 @@ module MountainCarEnv

 using Reinforce: AbstractEnvironment
 using LearnBase: DiscreteSet
+using Random: srand
 using RecipesBase
 using Distributions
iblislin commented 5 years ago

miner change:

diff --git a/src/episodes/iterators.jl b/src/episodes/iterators.jl
index fd906e7..7d8b194 100644
--- a/src/episodes/iterators.jl
+++ b/src/episodes/iterators.jl
@@ -56,8 +56,7 @@ end

 @static if VERSION >= v"0.7"
-  Base.iterate(ep::Episode)    = _next(ep::Episode, _start(ep))
-  Base.iterate(ep::Episode, i) = _next(ep::Episode, i)
+  Base.iterate(ep::Episode, i::Integer = _start(ep)) = _next(ep::Episode, i)
 else
   Base.start(ep::Episode)   = _start(ep)
   Base.next(ep::Episode, i) = _next(ep, i)
iblislin commented 5 years ago

travis stuffs

diff --git a/.travis.yml b/.travis.yml
index cebc7d0..7270a8e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,10 +4,7 @@ os:
   - linux
 julia:
   - 0.6
+  - 0.7
   - 1.0
-  - nightly
-matrix:
-  allow_failures:
-    - julia: nightly
 notifications:
   email: false
iblislin commented 5 years ago

ah, Base.srand is renamed to Random.seed! My previous patch is wrong.

I want to drop 0.6 support and just write this

diff --git a/src/envs/mountain_car.jl b/src/envs/mountain_car.jl
index 030fece..0f1f88e 100644
--- a/src/envs/mountain_car.jl
+++ b/src/envs/mountain_car.jl
@@ -6,6 +6,7 @@ module MountainCarEnv

 using Reinforce: AbstractEnvironment
 using LearnBase: DiscreteSet
+using Random: seed!
 using RecipesBase
 using Distributions

@@ -45,7 +46,7 @@ MountainCar(seed=-1) = MountainCar(MountainCarState(0.0, 0.0), 0.0, seed)

 function reset!(env::MountainCar)
   if env.seed >= 0
-    srand(env.seed)
+    seed!(env.seed)
     env.seed = -1
   end
JobJob commented 5 years ago

Thank you for taking the time to review!