Skip to content

Instantly share code, notes, and snippets.

@sol0invictus
Created May 3, 2021 03:00
Show Gist options
  • Save sol0invictus/ea17456d96c9686377cacb5f45119ad5 to your computer and use it in GitHub Desktop.
Save sol0invictus/ea17456d96c9686377cacb5f45119ad5 to your computer and use it in GitHub Desktop.
classdef mountain_car_1 < rl.env.MATLABEnvironment
properties
open_env = py.gym.make('MountainCar-v0');
end
methods
function this = mountain_car_1()
ObservationInfo = rlNumericSpec([2 1]);
ObservationInfo.Name = 'MountainCar Descreet';
ObservationInfo.Description = 'Position, Velocity';
ActionInfo = rlFiniteSetSpec([0 1 2]);
ActionInfo.Name = 'Acceleration direction';
this = this@rl.env.MATLABEnvironment(ObservationInfo,ActionInfo);
end
function [Observation,Reward,IsDone,LoggedSignals] = step(this,Action)
result = cell(this.open_env.step(int16(Action)));
Observation = double(result{1})';
Reward = double(result{2});
IsDone = double(result{3});
LoggedSignals = [];
if (Observation(1)>=0.49)
Reward = 0;
IsDone = 1;
end
end
function InitialObservation = reset(this)
result = this.open_env.reset();
InitialObservation = double(result)';
end
end
end
@Ser271155
Copy link

when starting training with this userland, an error will appear
error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment