2018-06-12 18:00:42 -07:00
|
|
|
preset = rawget(_G, 'preset') or 'ars'
|
2018-06-12 17:02:56 -07:00
|
|
|
|
2018-05-06 20:55:58 -07:00
|
|
|
local common_cfg = {
|
2018-06-12 17:02:56 -07:00
|
|
|
-- read-only modes:
|
2018-04-02 06:21:55 -07:00
|
|
|
playable_mode = false,
|
2018-05-06 20:55:58 -07:00
|
|
|
playback_mode = false,
|
2018-06-12 17:02:56 -07:00
|
|
|
|
|
|
|
-- controlling in-game mechanics:
|
|
|
|
starting_world = 1, -- set to 0 to randomize the world every epoch.
|
|
|
|
starting_level = 1, -- set to 0 to randomize the level every epoch.
|
2018-05-06 20:55:58 -07:00
|
|
|
start_big = false,
|
|
|
|
starting_lives = 0,
|
2018-06-12 17:02:56 -07:00
|
|
|
min_time = 100,
|
|
|
|
max_time = 300,
|
|
|
|
timer_loser = 1/2, -- decrement the timer when mario is slacking off.
|
2018-04-02 07:29:12 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
-- rewards:
|
|
|
|
decrement_reward = false, -- bad idea, encourages mario to run into goombas.
|
|
|
|
score_multiplier = 1, -- how much the ingame score influences our rewards.
|
|
|
|
|
|
|
|
-- network initialization:
|
|
|
|
init_zeros = false, -- instead of random normal noise.
|
|
|
|
|
|
|
|
-- network inputs (connections):
|
|
|
|
time_inputs = true, -- binary inputs of global frame count
|
|
|
|
|
|
|
|
-- network layers:
|
|
|
|
layernorm = false,
|
2018-06-12 18:00:42 -07:00
|
|
|
reduce_tiles = false,
|
|
|
|
bias_out = true,
|
2018-06-12 17:02:56 -07:00
|
|
|
|
|
|
|
-- network evaluation (sampling joypad):
|
2018-04-02 06:21:55 -07:00
|
|
|
frameskip = 4,
|
|
|
|
-- true greedy epsilon has both deterministic and det_epsilon set.
|
2018-05-02 04:06:28 -07:00
|
|
|
deterministic = false, -- use argmax on outputs instead of random sampling.
|
2018-04-02 06:21:55 -07:00
|
|
|
det_epsilon = false, -- take random actions with probability eps.
|
2018-04-02 07:29:12 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
-- evolution strategy and non-rate hyperparemeters:
|
|
|
|
es = 'ars',
|
|
|
|
ars_lips = false, -- for ARS.
|
|
|
|
epoch_top_trials = 9999, -- for ARS.
|
|
|
|
|
|
|
|
-- sampling:
|
2018-06-12 18:00:42 -07:00
|
|
|
deviation = 1.0,
|
2018-06-12 17:02:56 -07:00
|
|
|
unperturbed_trial = true, -- perform an extra trial without any noise.
|
|
|
|
graycode = false, -- for ARS.
|
2018-04-02 06:21:55 -07:00
|
|
|
negate_trials = true, -- try pairs of normal and negated noise directions.
|
2018-06-09 08:56:18 -07:00
|
|
|
-- AKA antithetic sampling. note that this doubles the number of trials.
|
2018-06-12 17:02:56 -07:00
|
|
|
min_refresh = 0.1, -- for SNES.
|
2018-05-03 06:33:17 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
-- epoch-related rates:
|
2018-06-10 07:38:25 -07:00
|
|
|
learning_rate = 1.0,
|
2018-06-12 18:00:42 -07:00
|
|
|
mean_adapt = 1.0, -- for SNES, xNES.
|
2018-06-10 10:34:17 -07:00
|
|
|
weight_decay = 0.0,
|
2018-06-12 17:02:56 -07:00
|
|
|
sigma_decay = 0.0, -- for SNES.
|
|
|
|
}
|
2018-06-10 07:38:25 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
local cfg
|
|
|
|
if preset == 'snes' then
|
2018-05-03 06:33:17 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
cfg = {
|
|
|
|
es = 'snes',
|
2018-06-08 19:34:21 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
log_fn = 'logs-snes.csv',
|
|
|
|
params_fn = 'params-snes.txt',
|
2018-04-03 09:13:11 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
starting_lives = 1,
|
|
|
|
min_time = 300,
|
|
|
|
timer_loser = 1.0,
|
2018-06-09 10:12:25 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
epoch_trials = 100,
|
|
|
|
negate_trials = false,
|
2018-06-09 10:12:25 -07:00
|
|
|
|
2018-06-12 18:00:42 -07:00
|
|
|
deviation = 1.0,
|
2018-06-12 17:02:56 -07:00
|
|
|
min_refresh = 0.2,
|
2018-06-09 10:12:25 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
learning_rate = 0.1, -- TODO: rename to learn_primary or something.
|
|
|
|
mean_adapt = 0.5, -- TODO: rename to learn_secondary or something.
|
2018-06-12 18:00:42 -07:00
|
|
|
weight_decay = 0.02, -- note: multiplied by its std, and mean_adapt.
|
2018-06-12 17:02:56 -07:00
|
|
|
sigma_decay = 0.01, -- note: multiplied by learning_rate.
|
|
|
|
}
|
2018-06-09 10:12:25 -07:00
|
|
|
|
2018-06-12 18:00:42 -07:00
|
|
|
elseif preset == 'xnes' then
|
|
|
|
|
|
|
|
cfg = {
|
|
|
|
es = 'xnes',
|
|
|
|
|
|
|
|
log_fn = 'logs-xnes.csv',
|
|
|
|
params_fn = 'params-xnes.txt',
|
|
|
|
|
|
|
|
start_big = true,
|
|
|
|
min_time = 300,
|
|
|
|
timer_loser = 1.0,
|
|
|
|
|
|
|
|
decrement_reward = false,
|
|
|
|
score_multiplier = 0,
|
|
|
|
|
|
|
|
init_zeros = true,
|
|
|
|
|
|
|
|
reduce_tiles = true,
|
|
|
|
bias_out = false,
|
|
|
|
|
|
|
|
deterministic = false,
|
|
|
|
|
|
|
|
deviation = 0.5,
|
|
|
|
negate_trials = false,
|
|
|
|
min_refresh = 0.1,
|
|
|
|
|
|
|
|
epoch_trials = 50,
|
|
|
|
|
|
|
|
learning_rate = 0.01,
|
|
|
|
mean_adapt = 1.0,
|
|
|
|
weight_decay = 0.0,
|
|
|
|
sigma_decay = 0.0,
|
|
|
|
}
|
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
elseif preset == 'ars' then
|
2018-06-09 10:12:25 -07:00
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
cfg = {
|
|
|
|
es = 'ars',
|
|
|
|
epoch_top_trials = 20,
|
|
|
|
ars_lips = false,
|
|
|
|
|
|
|
|
log_fn = 'logs-ars.csv',
|
|
|
|
params_fn = 'params-ars.txt',
|
|
|
|
|
|
|
|
min_time = 300,
|
|
|
|
timer_loser = 1.0,
|
|
|
|
|
2018-06-12 18:00:42 -07:00
|
|
|
deviation = 0.1,
|
|
|
|
|
2018-06-12 17:02:56 -07:00
|
|
|
epoch_trials = 25,
|
|
|
|
|
|
|
|
learning_rate = 1.0,
|
|
|
|
weight_decay = 0.0025,
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
error("invalid preset: "..tostring(preset))
|
|
|
|
|
|
|
|
end
|
2018-04-02 06:21:55 -07:00
|
|
|
|
2018-05-02 04:06:28 -07:00
|
|
|
-- TODO: so, uhh..
|
|
|
|
-- what happens when playback_mode is true but unperturbed_trial is false?
|
|
|
|
|
2018-05-06 20:55:58 -07:00
|
|
|
setmetatable(cfg, {
|
|
|
|
__index = function(t, n)
|
|
|
|
if common_cfg[n] ~= nil then return common_cfg[n] end
|
2018-05-07 00:20:01 -07:00
|
|
|
if n == 'log_fn' then return nil end
|
2018-05-06 20:55:58 -07:00
|
|
|
if n == 'params_fn' then return nil end
|
2018-05-07 00:20:01 -07:00
|
|
|
if n == 'stats_fn' then return nil end
|
2018-05-06 20:55:58 -07:00
|
|
|
error("cannot use undeclared config '" .. tostring(n) .. "'", 2)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2018-04-02 06:21:55 -07:00
|
|
|
cfg.epoch_top_trials = math.min(cfg.epoch_trials, cfg.epoch_top_trials)
|
|
|
|
|
|
|
|
cfg.eps_start = 1.0 * cfg.frameskip / 64
|
|
|
|
cfg.eps_stop = 0.1 * cfg.eps_start
|
|
|
|
cfg.eps_frames = 1000000
|
|
|
|
cfg.enable_overlay = cfg.playable_mode
|
|
|
|
cfg.enable_network = not cfg.playable_mode
|
|
|
|
|
2018-05-06 20:55:58 -07:00
|
|
|
assert(not cfg.ars_lips or cfg.unperturbed_trial,
|
|
|
|
"cfg.unperturbed_trial must be true to use cfg.ars_lips")
|
2018-06-07 17:45:07 -07:00
|
|
|
assert(not cfg.ars_lips or cfg.negate_trials,
|
|
|
|
"cfg.negate_trials must be true to use cfg.ars_lips")
|
2018-06-12 17:02:56 -07:00
|
|
|
assert(not (cfg.es == 'snes' and cfg.negate_trials),
|
|
|
|
"cfg.negate_trials is not yet compatible with SNES")
|
2018-06-09 08:56:18 -07:00
|
|
|
|
2018-05-06 20:55:58 -07:00
|
|
|
return cfg
|