Posts for redatchyon2098


Post subject: Strange Issue Part 2
Experienced Forum User
Joined: 6/4/2020
Posts: 42
init()
emu.loadrom(ROMlocation)
movie.play(primaryMovieLocation, true)
while movie.mode() ~= "finished" do
table.insert(dummyarray, joypad.get(1))
  end
movie.stop()movie.record(secondaryMovieLocation)
movie.rerecordcounting(true)
for x = 1, #dummyarray do
  joypad.set(1, dummyarray[x])
  emu.frameadvance()
end
savestate.save(main)
print(3)
--------------------------------AI---------------------------------
for step = 1, episodecount do
  RNG = randomness
  for attempt = 1, triesPerEpisode do
    savestate.load(main)
    for x = 1, screenX * screenY do
      screen[x] = 0
    end
    for frame = 1, timestep do
      screen = memoryize(screen, getscreen(screenX, screenY))
      predict(screen)
      out = nodes[#nodes]
      if math.random() <RNG> bestfitness then
       bestfitness = fitness
       savestate.save(buffer)
    end
  end
  savestate.load(buffer)
  savestate.save(main)
end
Experienced Forum User
Joined: 6/4/2020
Posts: 42
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)
Experienced Forum User
Joined: 6/4/2020
Posts: 42
indeed.
Experienced Forum User
Joined: 6/4/2020
Posts: 42
CasualPokePlayer definitely.
Post subject: A simple question
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Is it possible to sync a replay device with the actual internal CPU clock so that it never de-syncs?
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Michael Fried wrote:
I'm pretty sure perfection has already been reached in Super Mario Bros.
They were saying this in 2004. Can you imagine?
Experienced Forum User
Joined: 6/4/2020
Posts: 42
okay, I am satisfied with this response.
Post subject: I'm so ignorant
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Thanks for your response. But I have another question: Let's say I have ACE(although it is fanciful to assume that, like you said). Then am I allowed to manipulate the screen in such a way that it would look identical to the princess's speech in 8-4, without continuously mashing buttons without "actually beating the game" and call that the game's end screen?
Post subject: I'll repeat my question
Experienced Forum User
Joined: 6/4/2020
Posts: 42
I want to ask a question that I believe is important. It's a question I have asked before, but I got no answers. The question is this: How do you determine that the game has ended? Is the game completed when the 'victory subroutine' is executed? If so, is I somehow use arbitrary code execution to manually execute that subroutine, have I beaten the game? Or is there a specific memory address that determines victory?(like how super mario land, 6 golden coins has one?) Or is it a matter of how the screen looks? I am confused.
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Thanks!
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Oh wow, I didn't visit this place in a while, and some important people are talking again. Unfortunately, it seems that none of my questions are answered at the time of me typing this. Oh well. Also,(I know this is literally impractical) but is it even slightly possible to reduce all of this game's code into an iterative mathematical function? Because that would be revolutionary.
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Is there a way to locate all instructions in the ROM that modify a certain address? For example, is there a method to find every instruction that modifies $1234 ?
Post subject: Quick Question
Experienced Forum User
Joined: 6/4/2020
Posts: 42
What is the definition of "completed" in SMB1? Does it mean a game state in which you can press "b" to go to Second Quest? If so, is the "Minus World Ending" a valid SMB1 run? Or if I somehow execute arbitrary code to manually execute the victory subroutine in world 8-1 and pressed "b" to go to Second Quest, did I win the game? I am confused.
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Thanks for replying. I have read this page about SMB1 glitches before. Also, I am aware that cheated movies are not possible to publish. The movies I shared was a proof of concept. I am sorry if I didn't convey my intentions clearly. Did you check out happylee's 1-2 graphic glitch play-around demonstration?http://tasvideos.org/userfiles/info/63142191243839512 I found out that my cheat and this tas's glitch both corrupts $0300 ~ $03FF and maybe some other places that I didn't discover yet. My idea is that maybe if there was a setup that allowed this glitch to be triggered multiple times, it might be possible to replicate the effects of my cheat with non-manipulated gameplay. Can anyone tell me how the subroutine that applies the effect that Mario gets when he touches a power-up item is determined? ((ex) give mario invincibility when he touches a star). Is it stored in sprite data?
Post subject: Interesting?
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Try these two movies. Use cheat $05F5:C2 when using these. Sorry.http://tasvideos.org/userfiles/info/64582201743104342 http://tasvideos.org/userfiles/info/64582136291305262 Please help me explain how these effects can happen from just collecting coins.
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Also, can't you die and 1up forever in 1-2?
Experienced Forum User
Joined: 6/4/2020
Posts: 42
Hello. I am a newcomer. SMB1 is my favorite game to play and I wanted to contribute in finding quirks and time saves in it. Independently discovering cheat $05F5 : C2 and being unable to explain the insanity that it is made me join tasvideos.org. Please help me learn more about this game. Also, how can I share movie files with others in the forum?