I am having a strange issue. I am making a Lua script for reinforcement learning in Super Mario Bros. The script automatically loads a ROM and plays a movie until it is finished, then tries to make inputs that maximizes Mario's X coordinate. The details don't matter. My problem is that for some reason, FCEUX completely crashes as soon as I run the script. Other scripts work fine. I deliberately put a print command at the start to see if at least that gets executed, but nothing gets printed. Nothing I tried has worked.(By the way, I don't really care about how awful my coding is, I just want the thing to run at all.) As far as I know, the file size is probably not the issue since I have made longer scripts and they work flawlessly. I'm using the 64-bit interim build because emu.loadrom(~) wasn't supported on FCEUX 2.2.3 and I'm too stupid to know how to build FCEUX from the WIN32 binary. Any help would be appreciated. Thank you in advance.
Also, I'm not available on Discord anymore, for at least a week.
------------------Preparation--------------
print(0) --check if the thing even runs at all
screenX = 6
screenY = 6
NetworkLearnRate = 0.0000001
LearnRate = 0.6
ROMlocation = "SMB(NTSC).zip"
primaryMovieLocation = "starter.fm2" --the movie it first plays
secondaryMovieLocation = "BOTT.fm2" --the movie it outputs
DiscoutFactor = 0.99
RNGfalloff = 0.99
randomness = 0.5
episodecount = 10
timestep = 600
triesPerEpisode = 150
NetDimensions = {screenX * screenY, 16}
main = savestate.object(5)
buffer = savestate.object(6)
print(1)
function average(list)
local a = 0
for x = 1,#list do
a = a + list[x]
end
return a / #list
end
function sigmoid(x)
return 1 / (1 + (2.71828 ^ (-x)))
end
function leakrelu(x)
if x <0> list[big[1]] then
big = {x}
elseif list[x] == list[big[1]] and big[1] ~= x then
table.insert(big,x)
end
end
return big[math.random(1,#big)]
end
function smallest(list)
local big = {1}
for x = 2, #list do
if list[x] <list>= 2 ^ (bitcount - x) then
table.insert(array, 1)
accumulator = accumulator - 2 ^ (bitcount - x)
else
table.insert(array, 0)
end
end
return array
end
function utility()
return memory.readbyte(109) * 256 + memory.readbyte(134)
end
function memoryize(table1, table2, ratio)
local dummyarray = table1
for x = 1, #table1 do
dummyarray[x] = (table1[x] + ratio * table2[x]) / (ratio + 1)
end
return dummyarray
end
function bellman(table1, maxq, dicountfactor, learningrate)
local dummyarray = table1
for x = 1, #table1 do
dummyarray[x] = ((1 - learningrate) * table1[x] + learningrate * dicountfactor * maxq)
end
return dummyarray
end
weights = {}
biases = {}
nodes = {{}}
q = 0
futuremaxq = 0
input = {}
screen = {}
fitnessvalue = 0
bestfitness = 0
out = {}
RNG = randomness
dummyarray = {}
for x = 1, screenX * screenY do
table.insert(screen, 0)
end
print(2)
----------Load ROM, play movie until finished, save state----------
(continues in next reply)