Packages

Gyx allows designing and training Reinforcement Learning tasks. It includes environment abstractions that allows interaction with Python based environments like OpenAI Gym.

Current section

Files

Jump to
gyx lib environments dummy.ex
Raw

lib/environments/dummy.ex

defmodule Gyx.Core.DummyEnv do
use Gyx.Core.Env
use GenServer
alias Gyx.Core.Spaces.Discrete
defstruct action_space: nil,
observation_space: nil
@impl true
def init(state) do
{:ok, state}
end
def start_link(_, opts) do
GenServer.start_link(
__MODULE__,
%{
action_space: %Discrete{n: 13},
observation_space: %Discrete{n: 1}
},
[name: {:global, Gyx.Core.Supervisors.DummyEnv}]
)
end
def reset, do: %Gyx.Core.Exp{}
@impl true
def handle_call({:act, action}, _from, state), do: {:reply, %Gyx.Core.Exp{action: action}, state}
def child_spec()do
%{
id: Gyx.Core.Supervisors.DummyEnv,
start: {__MODULE__, :start_link, [name: Gyx.Core.Supervisors.DummyEnv]},
type: :worker,
restart: :transient,
shutdown: 500
}
end
end