Skilled player (1651)
Joined: 7/25/2007
Posts: 299
Location: UK
Link to video New movie was in progress, but I've been dealt a bad RNG hand for the Puppy Levels and I haven't managed to fix the Lua script to help navigate them. Currently it's too annoying and time consuming to try everything blindly, and I haven't managed to find any faster solutions with the RNG calls I've been getting; hopefully I'll get it sorted this year.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Looks awesome! Which version of the script are you using?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Skilled player (1651)
Joined: 7/25/2007
Posts: 299
Location: UK
Thank you. I've tried both the Jim2bizhawk.lua visible above and the EarthwormJim2 script which comes for free with Bizhawk, which complains about memory searching or crashes the emulator respectively. The Gens script still works, so I've still got an understanding of what it's trying to do, but unfortunately it's no good when TASing on Bizhawk.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Flip wrote:
The Gens script still works, so I've still got an understanding of what it's trying to do, but unfortunately it's no good when TASing on Bizhawk.
It can be converted to a hawk script if that will help you.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Skilled player (1651)
Joined: 7/25/2007
Posts: 299
Location: UK
That should be beneficial, yes. Could you please tell me how I go about doing that?
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Flip wrote:
or crashes the emulator respectively.
At which point? Also, try this Download jim2hawk.lua
Language: lua

-- feos, 2015 -- + modification by r57shell in 2015 local rw = memory.read_u16_be local rl = memory.read_u32_be lastcfg = 0 dcfg = 0 rngcount = 0 rngcolor = "white" rngobject = 0 rngroutine = 0 MsgTime = 16 MsgStep = 256/MsgTime MsgTable = {} bombs = {} goback = {} goforth = {} --25BBA0 cmdstr = { [0x00+1] = "wait", [0x01+1] = "jmp", [0x02+1] = "call", [0x03+1] = "ret", [0x04+1] = "round jmp", [0x05+1] = "def", [0x06+1] = "idk", [0x07+1] = "table", [0x08+1] = "rndcall", [0x09+1] = "clr", [0x0A+1] = "text", [0x0B+1] = "stop", [0x0C+1] = "diff jmp", [0x0D+1] = "smt", [0x0E+1] = "incs", [0x0F+1] = "save", [0x2b+1] = "dec", [0x2d+1] = "inc", [0x30+1] = "p0", [0x31+1] = "p1", [0x32+1] = "p2", [0x33+1] = "p3", [0x34+1] = "p4", [0x35+1] = "p5", [0x36+1] = "p6", [0x37+1] = "p7", [0x38+1] = "p8", [0x39+1] = "p9", [0x3A+1] = "p10", [0x62+1] = "bomb", [0x63+1] = "down", [0x64+1] = "up", [0x65+1] = "upp", [0x68+1] = "bonus", [0x70+1] = "puppy", [0x72+1] = "skip", [0x7a+1] = "end", } function cmdlen(ptr) local cmd = memory.readbyte(ptr) if cmd == 0xA then return 3 elseif cmd == 0x1 then return 5 elseif cmd == 0x2 then return 5 elseif cmd == 0x7 then return 5 elseif cmd == 0x4 then return 6 elseif cmd == 0xC then return 6 elseif cmd == 0x6 or cmd == 0x5 or cmd == 0xD or cmd == 0x72 then return 2 end return 1 end function cmdname(ptr) local cmd = memory.readbyte(ptr) local an = cmdstr[cmd+1] or "unk" if cmd == 0xA then local t = memory.readbyte(ptr+2) if t >= 26 and t <= 30 then an = an .. " " .. "Round " .. (t-25) elseif t == 25 then an = an .. " " .. "Use the Bomb" else an = an .. " " .. t end elseif cmd == 0x6 or cmd == 0xD or cmd == 0x72 or cmd == 0x5 then an = an .. " " .. memory.readbyte(ptr+1) elseif cmd == 0x1 or cmd == 0x2 or cmd == 0x7 then an = an .. " " .. string.format("%X",rl(ptr+1)) elseif cmd == 0xC or cmd == 0x4 then an = an .. " " .. memory.readbyte(ptr+1) .. string.format(" %X",rl(ptr+2)) end return an end function iswait(ptr) local cmd = memory.readbyte(ptr) return cmd == 0xA or cmd == 0xB or cmd == 0x63 or cmd == 0x64 or cmd == 0x65 or cmd == 0x3C or cmd == 0 end function writetofile(file, cfg) local rnd = {} local rndname = nil for i=0,1000000 do local cmd = memory.readbyte(cfg) local an = cmdname(cfg) local cl = cmdlen(cfg) local hex = "" for z = 1, cl do hex = hex..string.format("%02X",memory.readbyte(cfg+z-1)) end if cmd == 0x2b or cmd == 0x2d or cmd == 0x0 then for z = 1, 10000 do if memory.readbyte(cfg+z) ~= cmd then cl = z break end end an = an .. ' x' .. cl end if cmd == 0x7 then table.insert(rnd, {rl(cfg+1), rndname}); rndname = nil end if iswait(cfg) then an = "-" .. an else an = " " .. an end file:write(string.format("%X %-12s %s\n",cfg,hex,an)); cfg = cfg + cl if cmd == 0xF then if memory.readbyte(cfg) == 0xA and memory.readbyte(cfg+2) >= 26 and memory.readbyte(cfg+2) <= 30 then file:write("======== Round " .. (memory.readbyte(cfg+2) - 25) .. " ========\n") rndname = "Round_" .. (memory.readbyte(cfg+2)-25); else file:write("================\n") end end if i>0 and cmd==0xB or cmd==0x3 then break end end return rnd end function writecfg(fname, ptr) local file = io.open(fname,"w+") file:write("======== main cfg ========\n\n") local rnd = writetofile(file, ptr) for i = 1,#rnd do local r = rnd[i]; local count = rw(r[1]); for j = 1, count do if rnd[2] then file:write(string.format("\n======== table %s %d ========\n\n", r[2], j)) else file:write(string.format("\n======== table %X %d ========n\n", r[1], j)) end writetofile(file, rl(r[1]+2+4*(j-1))) end end file:close() end -- uncomment this if you want dumps --writecfg("puppy1.txt",0x275FDC) --writecfg("puppy2.txt",0x27658E) --writecfg("puppy3.txt",0x276ECC) function DrawConfig(cfg, xpos) local h = 7 for i=0,25 do local action = memory.readbyte(cfg) if action==0x62 or action==8 or action==3 or action == 0xB then color = "red" elseif action>=0x63 and action<=0x65 then color = "orange" elseif action>=0x30 and action<=0x32 then color = "green" elseif action>=0x66 and action<=0x70 then color = "#00a000ff" elseif action==0x7a then color = "white" else color = "#aaaaaaff" end local an = cmdname(cfg) if iswait(cfg) then an = "-" .. an else an = " " .. an end local cl = cmdlen(cfg) local hex = "" for z = 1, cl do hex = hex..string.format("%02X",memory.readbyte(cfg+z-1)) end if action == 0x2b or action == 0x2d or action == 0x0 then for z = 1, 10000 do if memory.readbyte(cfg+z) ~= action then cl = z break end end an = an .. ' x' .. cl end gui.pixelText(xpos,i*h+32,string.format("%X %s",cfg,an), color) cfg = cfg + cl if i>0 and action==0xB or action==0x3 then break end end end function randomsleft(cfg) local left = 0 for i = 1, 1000 do local cmd = memory.readbyte(cfg) local cl = cmdlen(cfg) if cmd == 8 then left = left + 1 end cfg = cfg + cl if cmd==0xB or cmd==0x3 or cmd==0xF then break end end return left end function Configs() if rl(0xfffc2a)==0 then return end local rng = rl(0xffa1d4) local cfg0 = rl(0xfffc2a) local cfg1 = rl(0xfffc9a) gui.pixelText(100,0,string.format("rng: %08X : %d",rng,rngcount),rngcolor) gui.pixelText(220,0,string.format("Timeout : %3d of %3d",memory.readbyte(0xFFFC7D),memory.readbyte(0xFFFC7C))) gui.pixelText(220,8,string.format("Something: %3d of %3d",memory.readbyte(0xFFFAA6),memory.readbyte(0xFFFAA7))) if memory.readbyte(0xFFFF2A) == 0 then gui.pixelText(270,16,"Bonus: yes") else gui.pixelText(270,16,"Bonus: no") end if lastcfg~=cfg0 then dcfg = cfg0-lastcfg end lastcfg = cfg0 local cfg = rl(0xfffc2a) local left = 0 if (cfg >= 0x275FDC and cfg <= 0x27614C) or (cfg >= 0x27658E and cfg <= 0x276797) or (cfg >= 0x276ECC and cfg <= 0x2770D6) then DrawConfig(cfg, 104) left = randomsleft(cfg) else DrawConfig(cfg1, 104) DrawConfig(cfg, 204) left = randomsleft(cfg1) end gui.pixelText(100,16,"Randoms left: " .. left) end function Seek() bytes = 0 waves = 0 steps = 0 local ret = "" for bytes=0,10000 do local cfg = rl(0xfffc2a)+bytes local action = memory.readbyte(cfg) local newaction = memory.readbyte(cfg+1) if action==0x7a then waves=waves+1 steps=steps+1 end if action==0x63 or action==0x64 or (action==0 and newaction==0) then steps=steps+1 end if action>=0x30 and action<=0x32 then if newaction==0x70 then steps=steps+1 elseif newaction==0x62 then ret = string.format("BOMB in %d waves %d steps",waves,steps,bytes) break end elseif action==3 then ret = string.format("Forth in %d waves %d steps",waves,steps,bytes) break elseif action==0xe and newaction==8 then ret = string.format("Back in %d waves %d steps",waves,steps,bytes) break end end gui.pixelText(100,8,ret) end function Objects() local base0 = 0xffa2ea for i=0,0x23 do local base = base0+i*0x6e local id = memory.readbyte(base) if id>0 and id~=0x82 then local x = Clamp(rw(base+2)-4096-camx,0,310) local y = Clamp(rw(base+4)-4096-camy,0,214) local vel = rw(base+0x18) local a = rl(base+0x14) local color = "white" PostRngRoll(base,x,y) local hp = memory.readbyte(base+1) if hp ~= 0 then gui.pixelText(x,y,string.format("%X\n%d",base,hp),color) else gui.pixelText(x,y,string.format("%X",base),color) end end end end function Bounce() if memory.readbyte(0xffa515)==0x60 then offset = 8 else offset = 0 end local counter = memory.readbyte(0xfffc87) local a0 = 0xfffc88 local d0 = (memory.readbyte(a0+counter) << 5)+offset local a3 = 0x25d482 local vel = rw(a3+d0) local bounce = 0 if vel == 0x200 then bounce = 3 elseif vel == 0x3e0 then bounce = 1 else bounce = 2 end gui.pixelText(0,0,string.format("next bounce: %d",bounce)) end function PostRngRoll(object,x,y) for i = 1, #MsgTable do if (MsgTable[i]) then if object==MsgTable[i].object_ then local color = 0xff000000+(MsgTable[i].timer_-emu.framecount())*MsgStep gui.line(120,8*i+8,x,y,color) gui.pixelText(100,8*i+8,string.format("%X",MsgTable[i].routine_),color) end if (MsgTable[i].timer_<emu.framecount()) then MsgTable[i] = nil end end end end function Clamp(v1,v2,v3) if v1<v2 then v1=v2 elseif v1>v3 then v1=v3 end return v1 end while true do camx = rw(0xffa172) camy = rw(0xffa174) frame = emu.framecount() Objects() Bounce() Configs() Seek() lastframe = frame emu.frameadvance() end function Dump() for p=0x275fea,0x277b79 do local a = memory.readbyte(p) if a==0x62 then table.insert(bombs,string.format("%X",p)) elseif a==8 then table.insert(goback,string.format("%X",p)) elseif a==3 then table.insert(goforth,string.format("%X",p)) end end print("bombs:") print(bombs) print("") print("goback:") print(goback) print("") print("goforth:") print(goforth) print("") end --Dump() emu.registerbefore(function() rngcount = 0 rngcolor = "white" rngobject = 0 end) memory.registerwrite(0xFFA1D4,function() rngcount = rngcount+1 rngcolor = "red" rngobject = memory.getregister("a1") rngroutine = memory.getregister("a0") for i = 1, 50 do if MsgTable[i] == nil then MsgTable[i] = { timer_ = MsgTime + emu.framecount(), object_ = rngobject, routine_ = rngroutine } break end end end)
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Skilled player (1651)
Joined: 7/25/2007
Posts: 299
Location: UK
Well the prepackaged script basically crashes Bizhawk as soon as it's running whilst in a level. The original script spits out a whole bunch of errors in the Lua Output window which prevents frame advancement, ie "Warning: attempted read of 1653891761 outside the memory size of 4194304. Message Cap reached, supressing output." etc, and your recent one still gives the error "NLua.Exceptions.LuaScriptException: [string "main"]:350: unexpected symbol near '<'. However, removing the <<5 from that line at least gives a working output, just with scaling off. I'll see if I can tidy it up a bit more, thank you.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
What bizhawk version are you using?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Skilled player (1651)
Joined: 7/25/2007
Posts: 299
Location: UK
I've been using 2.6.3 which was the version my TAS was originally started on. I've just checked them on the latest version of 2.9.1, and the scripts and movies work which is a good sign.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
The font needed a bit of tweaking, update Post #527775.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
EZGames69
He/They
Publisher, Reviewer, Expert player (4460)
Joined: 5/29/2017
Posts: 2761
Could this please be moved to the game thread instead of this submission in particular?
[14:15] <feos> WinDOES what DOSn't 12:33:44 PM <Mothrayas> "I got an oof with my game!" Mothrayas Today at 12:22: <Colin> thank you for supporting noble causes such as my feet MemoryTAS Today at 11:55 AM: you wouldn't know beauty if it slapped you in the face with a giant fish [Today at 4:51 PM] Mothrayas: although if you like your own tweets that's the online equivalent of sniffing your own farts and probably tells a lot about you as a person MemoryTAS Today at 7:01 PM: But I exert big staff energy honestly lol Samsara Today at 1:20 PM: wouldn't ACE in a real life TAS just stand for Actually Cease Existing