fix frameskip stuff and give mario an extra life
This commit is contained in:
parent
3b4e195ae6
commit
6f2ffcdef7
1 changed files with 24 additions and 17 deletions
41
main.lua
41
main.lua
|
@ -513,7 +513,7 @@ local function handle_tiles()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function prepare_epoch()
|
local function prepare_epoch()
|
||||||
print('preparing epoch '..tostring(epoch_i)..'. this might take a while.')
|
print('preparing epoch '..tostring(epoch_i)..'.')
|
||||||
base_params = network:collect()
|
base_params = network:collect()
|
||||||
empty(trial_noise)
|
empty(trial_noise)
|
||||||
empty(trial_rewards)
|
empty(trial_rewards)
|
||||||
|
@ -633,7 +633,7 @@ local function do_reset()
|
||||||
local state = get_state()
|
local state = get_state()
|
||||||
-- be a little more descriptive.
|
-- be a little more descriptive.
|
||||||
if state == 'dead' and get_timer() == 0 then state = 'timeup' end
|
if state == 'dead' and get_timer() == 0 then state = 'timeup' end
|
||||||
print("resetting in state: "..state..". reward:", reward)
|
print("reward:", reward, "("..state..")")
|
||||||
|
|
||||||
if trial_i >= 0 then trial_rewards[trial_i] = reward end
|
if trial_i >= 0 then trial_rewards[trial_i] = reward end
|
||||||
|
|
||||||
|
@ -653,7 +653,7 @@ local function do_reset()
|
||||||
|
|
||||||
-- set lives to 0. you only got one shot!
|
-- set lives to 0. you only got one shot!
|
||||||
-- unless you get a 1-up, in which case, please continue!
|
-- unless you get a 1-up, in which case, please continue!
|
||||||
W(0x75A, 0)
|
W(0x75A, 1)
|
||||||
|
|
||||||
--max_time = min(log(epoch_i) * 10 + 100, cap_time)
|
--max_time = min(log(epoch_i) * 10 + 100, cap_time)
|
||||||
max_time = min(8 * sqrt(360 / epoch_trials * (epoch_i - 1)) + 100, cap_time)
|
max_time = min(8 * sqrt(360 / epoch_trials * (epoch_i - 1)) + 100, cap_time)
|
||||||
|
@ -695,12 +695,33 @@ init()
|
||||||
local dummy_softmax_values = {0, 0}
|
local dummy_softmax_values = {0, 0}
|
||||||
|
|
||||||
local function doit(dummy)
|
local function doit(dummy)
|
||||||
|
local ingame_paused = get_state() == "paused"
|
||||||
|
|
||||||
|
-- every few frames mario stands still, forcibly decrease the timer.
|
||||||
|
-- this includes having the game paused.
|
||||||
|
-- TODO: more robust. doesn't detect moonwalking against a wall.
|
||||||
|
local timer = get_timer()
|
||||||
|
if ingame_paused or random() > 1 - timer_loser and R(0x1D) == 0 and R(0x57) == 0 then
|
||||||
|
timer = timer - 1
|
||||||
|
end
|
||||||
|
timer = clamp(timer, 0, max_time)
|
||||||
|
if enable_network then
|
||||||
|
set_timer(timer)
|
||||||
|
end
|
||||||
|
|
||||||
|
local tf0 = total_frames % 1000
|
||||||
|
local tf1 = (total_frames % 1000000 - tf0) / 1000
|
||||||
|
local tf2 = (total_frames - tf0 - tf1) / 10000000
|
||||||
|
gui.text(12, 212, ("%03i,%03i,%03i"):format(tf2,tf1,tf0), '#FFFFFF', '#0000003F')
|
||||||
|
|
||||||
screen_scroll_delta = screen_scroll_delta + R(0x775)
|
screen_scroll_delta = screen_scroll_delta + R(0x775)
|
||||||
if dummy == true then
|
if dummy == true then
|
||||||
gui.text(96, 16, ("%+4i"):format(reward), '#FFFFFF', '#0000003F')
|
gui.text(96, 16, ("%+4i"):format(reward), '#FFFFFF', '#0000003F')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
total_frames = total_frames + frameskip
|
||||||
|
|
||||||
empty(sprite_input)
|
empty(sprite_input)
|
||||||
empty(tile_input)
|
empty(tile_input)
|
||||||
empty(extra_input)
|
empty(extra_input)
|
||||||
|
@ -724,8 +745,6 @@ local function doit(dummy)
|
||||||
handle_misc()
|
handle_misc()
|
||||||
handle_tiles()
|
handle_tiles()
|
||||||
|
|
||||||
local ingame_paused = get_state() == "paused"
|
|
||||||
|
|
||||||
local coins = R(0x7ED) * 10 + R(0x7EE)
|
local coins = R(0x7ED) * 10 + R(0x7EE)
|
||||||
local coins_delta = coins - coins_old
|
local coins_delta = coins - coins_old
|
||||||
-- handle wrap-around.
|
-- handle wrap-around.
|
||||||
|
@ -762,18 +781,6 @@ local function doit(dummy)
|
||||||
--if ingame_paused then reward = reward - 1 end
|
--if ingame_paused then reward = reward - 1 end
|
||||||
if ingame_paused then reward = reward - 402; reset = true end
|
if ingame_paused then reward = reward - 402; reset = true end
|
||||||
|
|
||||||
-- every few frames mario stands still, forcibly decrease the timer.
|
|
||||||
-- this includes having the game paused.
|
|
||||||
-- TODO: more robust. doesn't detect moonwalking against a wall.
|
|
||||||
local timer = get_timer()
|
|
||||||
if ingame_paused or random() > 1 - timer_loser and R(0x1D) == 0 and R(0x57) == 0 then
|
|
||||||
timer = timer - 1
|
|
||||||
end
|
|
||||||
timer = clamp(timer, 0, max_time)
|
|
||||||
if enable_network then
|
|
||||||
set_timer(timer)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if we've run out of time while the game is paused...
|
-- if we've run out of time while the game is paused...
|
||||||
-- that's cheating! unpause.
|
-- that's cheating! unpause.
|
||||||
force_start = ingame_paused and timer == 0
|
force_start = ingame_paused and timer == 0
|
||||||
|
|
Loading…
Reference in a new issue