temp 2
This commit is contained in:
parent
b7938a1785
commit
a1429a6271
4 changed files with 74 additions and 1 deletions
5
ars.lua
5
ars.lua
|
@ -55,6 +55,7 @@ local function collect_best_indices(scored, top, antithetic)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function kinda_lipschitz(dir, pos, neg, mid)
|
local function kinda_lipschitz(dir, pos, neg, mid)
|
||||||
|
--[[
|
||||||
-- based on the local lipschitz constant of a quadratic curve
|
-- based on the local lipschitz constant of a quadratic curve
|
||||||
-- drawn through the 3 sampled points: positive, negative, and unperturbed.
|
-- drawn through the 3 sampled points: positive, negative, and unperturbed.
|
||||||
-- it kinda helps? there's probably a better function to base it around.
|
-- it kinda helps? there's probably a better function to base it around.
|
||||||
|
@ -64,6 +65,10 @@ local function kinda_lipschitz(dir, pos, neg, mid)
|
||||||
local l0 = abs(3 * c1 + c0)
|
local l0 = abs(3 * c1 + c0)
|
||||||
local l1 = abs(c1 + 3 * c0)
|
local l1 = abs(c1 + 3 * c0)
|
||||||
return max(l0, l1) / (2 * dev)
|
return max(l0, l1) / (2 * dev)
|
||||||
|
--]]
|
||||||
|
-- based on a piece-wise linear function of the 3 sampled points.
|
||||||
|
local _, dev = calc_mean_dev(dir)
|
||||||
|
return max(abs(pos - mid), abs(neg - mid)) / dev
|
||||||
end
|
end
|
||||||
|
|
||||||
function Ars:init(dims, popsize, poptop, base_rate, sigma, antithetic,
|
function Ars:init(dims, popsize, poptop, base_rate, sigma, antithetic,
|
||||||
|
|
|
@ -34,6 +34,7 @@ local defaults = {
|
||||||
|
|
||||||
-- network evaluation (sampling joypad):
|
-- network evaluation (sampling joypad):
|
||||||
frameskip = 4,
|
frameskip = 4,
|
||||||
|
prob_frameskip = 0.0,
|
||||||
-- true greedy epsilon has both deterministic and det_epsilon set.
|
-- true greedy epsilon has both deterministic and det_epsilon set.
|
||||||
deterministic = false, -- use argmax on outputs instead of random sampling.
|
deterministic = false, -- use argmax on outputs instead of random sampling.
|
||||||
det_epsilon = false, -- take random actions with probability eps.
|
det_epsilon = false, -- take random actions with probability eps.
|
||||||
|
|
7
main.lua
7
main.lua
|
@ -24,6 +24,7 @@ local trial_frames = 0
|
||||||
local total_frames = 0
|
local total_frames = 0
|
||||||
local lagless_count = 0
|
local lagless_count = 0
|
||||||
local decisions_made = 0
|
local decisions_made = 0
|
||||||
|
local last_decision_frame = -1
|
||||||
|
|
||||||
local force_start = false
|
local force_start = false
|
||||||
local force_start_old = false
|
local force_start_old = false
|
||||||
|
@ -676,6 +677,7 @@ while true do
|
||||||
if reset then
|
if reset then
|
||||||
do_reset()
|
do_reset()
|
||||||
lagless_count = 0
|
lagless_count = 0
|
||||||
|
last_decision_frame = -1
|
||||||
end
|
end
|
||||||
|
|
||||||
if not cfg.enable_network then
|
if not cfg.enable_network then
|
||||||
|
@ -692,8 +694,11 @@ while true do
|
||||||
game.W(0x75A, 1)
|
game.W(0x75A, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local doot = jp == nil or lagless_count % cfg.frameskip == 0
|
local delta = lagless_count - last_decision_frame
|
||||||
|
local doot = jp == nil or delta >= cfg.frameskip
|
||||||
|
doot = doot and random() >= cfg.prob_frameskip
|
||||||
doit(not doot)
|
doit(not doot)
|
||||||
|
if doot then last_decision_frame = lagless_count end
|
||||||
|
|
||||||
-- jp might still be nil if we're not ingame or we're not playing.
|
-- jp might still be nil if we're not ingame or we're not playing.
|
||||||
if jp ~= nil then joypad.write(1, jp) end
|
if jp ~= nil then joypad.write(1, jp) end
|
||||||
|
|
62
presets.lua
62
presets.lua
|
@ -142,6 +142,68 @@ make_preset{
|
||||||
momentum = 0.5,
|
momentum = 0.5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-vanilla',
|
||||||
|
parent = 'ars',
|
||||||
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-skip',
|
||||||
|
parent = 'ars',
|
||||||
|
|
||||||
|
frameskip = 1,
|
||||||
|
prob_frameskip = 0.25,
|
||||||
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-lips',
|
||||||
|
parent = 'ars',
|
||||||
|
|
||||||
|
ars_lips = true,
|
||||||
|
momentum = 0.5,
|
||||||
|
param_rate = 1.0,
|
||||||
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-big',
|
||||||
|
parent = 'ars',
|
||||||
|
|
||||||
|
epoch_top_trials = 75,
|
||||||
|
epoch_trials = 100,
|
||||||
|
momentum = 0.5,
|
||||||
|
param_rate = 1.0,
|
||||||
|
|
||||||
|
--graycode = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-huge',
|
||||||
|
parent = 'big-scroll-hidden',
|
||||||
|
|
||||||
|
deterministic = true,
|
||||||
|
deviation = 0.01,
|
||||||
|
epoch_top_trials = 75,
|
||||||
|
epoch_trials = 100,
|
||||||
|
es = 'ars',
|
||||||
|
momentum = 0.5,
|
||||||
|
param_decay = 0.0138,
|
||||||
|
param_rate = 0.5,
|
||||||
|
}
|
||||||
|
|
||||||
|
make_preset{
|
||||||
|
name = 'ars-stupid',
|
||||||
|
parent = 'big-scroll-reduced',
|
||||||
|
|
||||||
|
es = 'ars',
|
||||||
|
epoch_top_trials = 4,
|
||||||
|
deterministic = false,
|
||||||
|
deviation = 0.2,
|
||||||
|
epoch_trials = 4,
|
||||||
|
param_rate = 0.1,
|
||||||
|
param_decay = 0.003,
|
||||||
|
momentum = 0.99,
|
||||||
|
}
|
||||||
|
|
||||||
make_preset{
|
make_preset{
|
||||||
name = 'play',
|
name = 'play',
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue