This commit is contained in:
parent
29f3c278ea
commit
75ad46bfe9
2 changed files with 34 additions and 30 deletions
59
main.lua
59
main.lua
|
@ -22,6 +22,7 @@ end
|
||||||
|
|
||||||
-- localize some stuff.
|
-- localize some stuff.
|
||||||
|
|
||||||
|
local print = print
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local select = select
|
local select = select
|
||||||
|
@ -387,6 +388,35 @@ local function handle_tiles()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function doreset()
|
||||||
|
print("resetting in state:", getstate())
|
||||||
|
|
||||||
|
if once then
|
||||||
|
savestate.load(startsave)
|
||||||
|
print("end of trial reward:", reward)
|
||||||
|
print()
|
||||||
|
else
|
||||||
|
savestate.save(startsave)
|
||||||
|
end
|
||||||
|
once = true
|
||||||
|
|
||||||
|
-- bit of a hack:
|
||||||
|
if getstate() == 'loading' then advance() end
|
||||||
|
reward = 0
|
||||||
|
powerup_old = R(0x754)
|
||||||
|
status_old = R(0x756)
|
||||||
|
coins_old = R(0x7ED) * 10 + R(0x7EE)
|
||||||
|
|
||||||
|
-- set lives to 0. you only got one shot!
|
||||||
|
-- unless you get a 1-up, in which case, please continue!
|
||||||
|
W(0x75A, 0)
|
||||||
|
|
||||||
|
emu.frameadvance() -- prevents emulator from quirking up.
|
||||||
|
|
||||||
|
reset = false
|
||||||
|
if network ~= nil then network:reset() end -- FIXME: hack
|
||||||
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
while fuckstates[getstate()] do
|
while fuckstates[getstate()] do
|
||||||
--gui.text(120, 124, ("%02X"):format(subroutine()), '#FFFFFF', '#0000003F')
|
--gui.text(120, 124, ("%02X"):format(subroutine()), '#FFFFFF', '#0000003F')
|
||||||
|
@ -415,34 +445,7 @@ while true do
|
||||||
state_old = getstate()
|
state_old = getstate()
|
||||||
end
|
end
|
||||||
|
|
||||||
if reset then
|
if reset then doreset() end
|
||||||
print("resetting in state:", getstate())
|
|
||||||
|
|
||||||
if once then
|
|
||||||
savestate.load(startsave)
|
|
||||||
print("end of trial reward:", reward)
|
|
||||||
print()
|
|
||||||
else
|
|
||||||
savestate.save(startsave)
|
|
||||||
end
|
|
||||||
once = true
|
|
||||||
|
|
||||||
-- bit of a hack:
|
|
||||||
if getstate() == 'loading' then advance() end
|
|
||||||
reward = 0
|
|
||||||
powerup_old = R(0x754)
|
|
||||||
status_old = R(0x756)
|
|
||||||
coins_old = R(0x7ED) * 10 + R(0x7EE)
|
|
||||||
|
|
||||||
-- set lives to 0. you only got one shot!
|
|
||||||
-- unless you get a 1-up, in which case, please continue!
|
|
||||||
W(0x75A, 0)
|
|
||||||
|
|
||||||
emu.frameadvance() -- prevents emulator from quirking up.
|
|
||||||
|
|
||||||
reset = false
|
|
||||||
if network ~= nil then network:reset() end -- FIXME: hack
|
|
||||||
end
|
|
||||||
|
|
||||||
if not enable_network then
|
if not enable_network then
|
||||||
-- infinite time cheat. super handy for testing.
|
-- infinite time cheat. super handy for testing.
|
||||||
|
|
5
nn.lua
5
nn.lua
|
@ -1,3 +1,4 @@
|
||||||
|
local print = print
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
@ -23,8 +24,8 @@ local function contains(t, a)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function normal()
|
local function normal() -- box muller
|
||||||
return sqrt(-2 * log(uniform() + 1e-8) + 1e-8) * cos(2 * pi * uniform()) / 2
|
return sqrt(-2 * log(uniform() + 1e-8) + 1e-8) * cos(2 * pi * uniform())
|
||||||
end
|
end
|
||||||
|
|
||||||
local function zeros(n, out)
|
local function zeros(n, out)
|
||||||
|
|
Loading…
Reference in a new issue