Posts for Pokota

1 2
16 17 18
31 32
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
OmnipotentEntity wrote:
And many more. It's not just one thing. It's systemic. And many of these problems are not easy to solve. Are you suggesting that humans will radically alter the way our faces look to accommodate an eating hole and a breathing hole? Radically alter our posture and pelvis for a straighter, more robust spine and less complications during birth? Completely change how our species gestates?
We may yet do all of that. Recall a statement I made earlier - the beauty and blessing of Homo sapiens is that we are capable of changing ourselves outside the natural mechanism of evolution.
You asked "Why intervene directly when the means to accomplish a thing already exist within the system?" Because these things cause needless suffering and death. If you, personally, could fix pregnancy death and extreme pain forever with the wave of your hand, would you? I know I would. If you wouldn't, how would you deal with the guilt?
I want to. Right now, I say I would too. Herein lies the contradiction of omnibenevolence, and I actually have answers from within my own faith that answer this question - though many would argue that the answers are meaningless because they avoid the issue.
  1. Recall that I am LDS. In our canon can be found this:
    Moses 1:37-39 wrote:
    And the Lord God spake unto Moses, saying: The heavens, they are many, and they cannot be numbered unto man; but they are numbered unto me, for they are mine. And as one earth shall pass away, and the heavens thereof even so shall another come; and there is no end to my works, neither to my words. For behold, this is my work and my glory—to bring to pass the immortality and eternal life of man.
    But just as you cannot teach a person to perform differential calculus without first ensuring that they have a firm grasp of the underlying principles of algebra, Heavenly Father cannot give eternal life without first ensuring we will not abuse it.* We have to prove that we are willing to obey eternal laws and principles, and Heavenly Father directly intervening during our trials and tribulations would invalidate that.
  2. Death is part and parcel of living, and is per LDS teachings necessary for exaltation/eternal life. Jesus Christ, firstborn of Heavenly Father in the spirit and only begotten of the flesh, had to die before he could be glorified (though arguably Christ had other work to do that necessitated him to be dead to do). Bear in mind, that LDS doctrine equates Jesus Christ with Jehovah of the Old Testament, and that Heavenly Father is his own separate entity with the same goals (a good way to demonstrate the relationship between the members of the Godhead is to point to any TAS submission with plural authors - separate entities working in conjunction towards a common goal). This by itself, however, reintroduces the contradiction of omnibenevolence and requires further argument.
  3. God will not override one's capacity to choose for themselves. Again, I have to point to LDS canon to support this argument, so I shall.
    Moses 4:1-4 wrote:
    And I, the Lord God, spake unto Moses, saying: That Satan, whom thou hast commanded in the name of mine Only Begotten, is the same which was from the beginning, and he came before me, saying—Behold, here am I, send me, I will be thy son, and I will redeem all mankind, that one soul shall not be lost, and surely I will do it; wherefore give me thine honor. But, behold, my Beloved Son, which was my Beloved and Chosen from the beginning, said unto me—Father, thy will be done, and the glory be thine forever. Wherefore, because that Satan rebelled against me, and sought to destroy the agency of man, which I, the Lord God, had given him, and also, that I should give unto him mine own power; by the power of mine Only Begotten, I caused that he should be cast down; And he became Satan, yea, even the devil, the father of all lies, to deceive and to blind men, and to lead them captive at his will, even as many as would not hearken unto my voice.
    At first glance, it's contradictory that Satan would save everybody while Christ would allow some to fall through the cracks. However, look at what Satan's words were again. At no point does he claim that all will be proven obedient, or that all would be prepared for eternal life. Under Satan's plan, an omnimaleficent diety would inevitably rise up into the eternities because there would be no proving, no trials, no nothing. If you think a non-interfering God is bad, try one that's actively destroying his own creation - or worse, destroying other creations.
*Footnote: Immortality and Eternal Life are not the same per LDS beliefs. I'll edit in or post the supporting scriptures when I find them again. Immortality is simply not dying again, and everyone (save for an infinitely small percentage of people born) is entitled to that through resurrection. Eternal Life is what we're trying to prove worthiness for.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Aqfaq: I am mortal. I have a finite amount of time to live and a finite capacity to understand the universe around me while I live. This should be true for all mortals. If the answer is found while I am alive, then the answer is found while I am alive. If not, there's no harm in having the question ready, as I expect there to be dead people who have either found the answer or know how to find it. As for a context where "user God" is not redundant... that's actually an interesting way to think about it now that it's been worded in that manner.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Oh, now I understand. It's going well out of its way to do its job when humans would design it to take the shortest possible path. I'll add that to my list of "biological oddities to ask about when I die". In the meantime, I'll chalk it up to what I said originally - that God uses evolution as a tool. Why intervene directly when the means to accomplish a thing already exist within the system? (A good way to imagine this concept is to imagine a universe in which sandcastles built themselves - why would anyone really want to build a sandcastle if they built themselves?) (E: A better way to demonstrate this concept to this specific community is this - in a TAS aiming for Arbitrary Code Execution, it is disqualifying to directly modify memory using the Hex Editor or the Cheats dialogue. Rather, you find ways from within the system to introduce the invasive code) One thing did jump out at me, though, as I was watching the video. The one (biologist? surgeon? technician?) stated that the nerve is part of the system that coordinates breathing and swallowing. I realize that the CNS is the overarching system that handles survival stuff; however it does not appear to be overly circuitous if you assume that the nerve itself needs to gather/distribute information across where it travels. (It's a weak argument, but again this is now something I'll be asking about after I've joined the laboratory eternal)
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Warp: Why else would God create? I've been LDS all my life, though, so I can't argue this point without coming back to what I've already stated - I don't know the other points of view well enough to defend or attack them. OmnipotentEntity: 0) You raise a valid point - you're referring to the perfection of form, whereas religion in general is more oriented towards perfection of behavior. I should have been more clear on this point, and I admit as such. 1) I don't fully understand the flaw you're referring to. The beauty and blessing of being Homo sapiens is that we are capable of changing ourselves outside the natural mechanism of evolution - see prosthetic limbs, the very nature of invasive surgery, and the fact that we as a species are capable of travel outside of the atmosphere, even if only within our own backyard. Give it a few years and science will advance sufficiently to overcome that flaw (or else will recognize that it isn't a flaw that warrants overcoming). In other words, what's wrong with it? 2) Science is presently in conflict with religion because neither has reached perfection. I hold that both will ultimately converge rather than divide. In other words, I cannot answer the question because I do not comprehend the hypothetical you're proposing. Also, there's not one singular religion. There may well already be religions that are more convergent with science presently, just as there are religions that are more divergent from science presently.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Warp wrote:
Well, an imperfect designer could make an imperfect design...
OmnipotentEntity wrote:
It's commonly held by theists that God is perfect and that we were designed in His image. It doesn't take much of a logical leap to suggest that such a design ought to be at the very least beyond easily justifiable criticism.
I will remind/inform you both of two facts regarding myself (and by extension, my faith)
  1. I am LDS.
  2. I hold very close to my heart the idea that the purpose behind creation is so that Homo sapiens can improve.
Specifically, because of that second point, I posit that God deliberately created Man to be flawed such that Man would have room to improve. By the same token, the scientific method is predicated on the idea that we don't know everything yet, and that we can learn about creation/nature/the universe through observation and experimentation. I see both God and Science existing in harmony at the level of omniscience.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
... you do know that we're not a single society yet, right?
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I just love this concept that it has to be perfect to be designed. Then again, I'm of the opinion that evolution is a tool used by God to develop life, so...
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
There would be subtle differences in the necessary inputs, too, necessitating further science - some of the timings would be different enough just to not be able to copy the first loop's input. It's just not worth running two loops when the second is materially the same as the first.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
meanwhile gui.foo is still being a butt for me, so as a workaround I'm using a form to show the data... Eeeeexcept it doesn't update on the fly - leaving form commands within the main loop led to major slowdown which is bad for my purposes. On the plus side, I'm learning how to forms.
Language: lua

require "RBY-Arrays.lua" infobox = forms.newform(360,360,"Pokegear Version 1") forms.button(infobox,"Update Values",core,250,250) domain = "System Bus" repoint = 0 foeCR = 0 foeMV = {} foeML = {} mapID = 0 inBattle = false foeHP = 0 function initPointers() game = memory.readbyte(0x013C) if game == 0x59 then repoint = 1 end foeHP = 0xCFE7 - repoint foeCR = 0xD007 - repoint foeMV = {0xCFED - repoint, 0xCFEE - repoint, 0xCFEF - repoint, 0xCFF0 - repoint} foeML = {"Dummy","Dummy","Dummy","Dummy"} mapID = 0xD35E - repoint end function isInBattle() result = false pointer = 0xD057 - repoint test = memory.read_u8(pointer) if test ~= 0 then result = true end return result end function isNotTrainer() result = true pointer = 0xD057 - repoint test = memory.read_u8(pointer) if test > 1 then result = false end return result end function updateCatchRate() numerator = memory.read_u8(foeCR) x = 20 y = 20 out = "Catch Rate: " .. numerator forms.label(infobox,out,x,y) end function updateStats() hpcur = memory.read_s16_le(foeHP) x = 20 y = 50 out = "Foe Current HP: " .. hpcur forms.label(infobox,out,x,y) end function updateMoveset() for i=1,4 do index = memory.readbyte(foeMV[i]) -- foeML[i] = index foeML[i] = moveList[index] end x = 50 base_y = 80 for i=1,4 do new_Y = base_y + (22 * (i - 1)) text = foeML[i] forms.label(infobox,text,x,new_Y) end end function core() inBattle = isInBattle() if (inBattle == true) then updateCatchRate() updateStats() updateMoveset() else thisMap = memory.read_u8(mapID) mapName = thisMap -- mapName = mapsByID[thisMap] gui.addmessage(mapName) end end memory.usememorydomain(domain) initPointers() while true do emu.frameadvance() end
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Oooo, gui.pixelText is going to be something I'll enjoy a lot.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
GBP actually is a Game Boy Advance in a shell that fits in the Gamecube's footprint. So no, it doesn't emulate the GBA - it is one. Same processor and everything.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Resource file is commented out as I'm not confident in requiring it yet. Issue I'm having is the script isn't drawing either way. It's intended for use with Pokemon Red, Blue, and Yellow. It's not throwing any errors, though, so I'm not sure how to trace what's going wrong here. E: I think I figured it out - I was displaying white text on a white background >.< E2: Oh joy things breaking because overly sensitive laptop touchpad. I need another pair of eyes, it's still not drawing.
Language: lua

--require res/RBY-Arrays.lua domain = "System Bus" repoint = 0 foeCR = 0 foeMV = {} foeML = {} inBattle = false function initPointers() game = memory.readbyte(0x013C) if game == 0x59 then repoint = 1 end foeHP = 0xCFE7 - repoint foeCR = 0xD007 - repoint foeMV = {0xCFED - repoint, 0xCFEE - repoint, 0xCFEF - repoint, 0xCFF0 - repoint} foeML = {"Dummy","Dummy","Dummy","Dummy"} end function isInBattle() result = false pointer = 0xD057 - repoint test = memory.read_u8(pointer) if test ~= 0 then result = true end return result end function isNotTrainer() result = true pointer = 0xD057 - repoint test = memory.read_u8(pointer) if test > 1 then result = false end return result end function drawCatch(value) x = 20 y = 10 gui.drawText(x,y,value,"Green","Green") end function drawLife(value) x = 20 y = 25 gui.drawText(x,y,value,"Red","Red") end function drawMoveset() x = 50 base_y = 40 for i=1,4 do new_Y = base_y + (15 * (i - 1)) text = foeML[i] gui.drawText(x,new_Y,text,"Blue","Blue") end end function updateCatchRate() numerator = memory.read_u8(foeCR) percentage = math.floor((numerator / 256) * 100) drawCatch(percentage) end function updateStats() value = memory.read_s16_le(foeHP) drawLife(value) end function updateMoveset() for i=1,4 do index = memory.readbyte(foeMV[i]) foeML[i] = index -- foeML[i] = moveList[index] end drawMoveset() end function core() if (isInBattle()==true) then if (isNotTrainer()==true) then updateCatchRate() end updateStats() updateMoveset() else gui.clearGraphics() end end gui.DrawNew("native") memory.usememorydomain(domain) initPointers() while true do core() emu.frameadvance() end
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Quick question. If I'm going to require a file in a subfolder, do I use forward slashes (like in *nix) or backslashes (like in windows)?
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Yeah, I really do have to be more careful about that sort of thing. Sorry all And yeah, now that I take a moment to think on it #2 is a non-issue for Extermination given we'd just do the normal "end the input file at the last input" thing anyway. Otherwise Eversion's imperfect ending would be just as much of an issue.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
MOD EDIT: please no spoilers for brand new games, deleting your entire post because apparently you have multiple in there and i don't wanna take any chances as someone who's too broke to afford the game. sorry! <3 samsara
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
In the specific case of Undertale:
  1. At this time, it's impractical to TAS Pacifist as it would just be "Do all the bosses but with perfect navigation"
    • Muffet can be skipped with spider bake sale goods used on turn 1
    • it's possible to reach the 12k ratings threshold on Mettaton EX before the Essay round
    • apparently there's an Out of Bounds glitch during Undyne that allows for a two round match
    • Dogs behave like dogs when confronted with a stick
    • Beat up on Mad Dummy until he starts using his robots, at which point you have four turns left (did I understand that right?)
    Other than those three cases, all the boss matches would be similar in length to normal play, necessitating Shmup-style judging
  2. Because of the nature of the Extermination run, it is not respectful of the game or the story it presents to publish a TAS of it.
  3. The only meaningful TAS of a Neutral run would be one that backs out of an Extermination run at the last minute, which presents the same problems that an Extermination run does, only moreso because then you're presenting the illusion of being able to evade the consequences of Extermination.
  4. As an actual mechanical reason to not TAS Undertale: in all Neutral runs, the game fully exits between the penultimate and final boss battles.
E: Edited #1 to reflect new information from Anty-Lemon, but for the most part the point still stands.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Unless you're going full-on Extermination, there's really not much in the way of "speed" as far as Undertale goes, and even then Extermination isn't exactly the sort of run that exemplifies what Undertale is all about.
Adventures in Lua When did I get a vest?
Post subject: Re: Emuhawk Basic Bot Challenges
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
YushiroGowa wrote:
Challenges
Challenges accepted (though Basic Bot can't actually do any of these due to how its built - it's built to loop from a save state rather than play infinitely)
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
You give it a starting save-state, a length of time in frames to send random inputs, up to four memory addresses to maximize (a criticism I have of Basic Bot is that there's no 'minimize' option as of yet), at least one button to maybe press, and a nice hot cup of tea. As has been stated, it's not a learnbot by any stretch of the imagination. It doesn't 'learn'. It simply brute-forces to try and find the best solution given the constraints (keystroke ratios, frame duration), defined as "which set of random keystrokes maximizes the watched memory addresses." If you want a PRNG that's more along the lines of RNG Plays Pokemon, I'm actually working on a lua script for such a thing. Currently the blacklisting isn't handled as I'd like to (I still need to implement forms and dynamic blacklist modification) and you can't weight buttons yet, but it presently works for all non-analog inputs for up to five four controllers. My end goal is to replicate Basic Bot but without the duration cap of 999.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
creaothceann wrote:
But that code doesn't check the number of games, just the number of controllers?
For DualGambatte, it's the same principle. Controller 1 is the first game boy, and Controller 2 is the second. E: Just tested, DualGambatte only recognizes the first two games in the XML generated by the Multi Disk Bundler. So really there's no reason to have max be anything higher than 20. Though now I want to see how this behaves with the Apple][.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
...I'm tempted to put together a Dual Gambatte xml file with 101 games just to see it fail because of a hard-coded max of 100. It'd wreck my computer trying to get to that point, but either way it'd still be fun to try. Lifted your code directly, credited you in code comments.
Language: lua

-- PRNG BOT version 4 (Amaraticando) -- Special thanks to Amaraticando, for the countPlayers() function. -- -- No longer fails for single-controller games, AND works for up to 100 controllers! -- Well, it's only been tested up to four controllers BUT IT WORKS! And it should work for up to 100 controllers. -- TODO: Learn and implement forms. -- Global variable declarations -- checkTime = 0 -- Placeholder variable. I don't like passing expressions as arguments. keyNames = {} -- Key Names array. keysArray = {} -- Key State array. blacklist = {"Power", "Reset"} -- Blacklisted keys array. frequency = 10 -- How often should the bot be updating? Also influences how long the keys are held. mplay = false -- Is there a more than one controller? If not, there's special handling that needs to happen. function core(mode) cap = countPlayers() -- I like to have a manager functon that only handles calling other functions. checkTime = emu.framecount() % frequency -- Set the frame count checker to the frame count modulo the frequency. if (checkTime == 0) then -- For the technically-minded, it's actually pseudorandom, but let's not be overly pedantic. if mode == true then -- If we have multiple controllers connected, for i=1,cap do -- then for each connected controller sendRandomButtonPress(i) -- send a random button press. end else -- if there is only one connected controller sendRandomButtonPress() -- send a random button press. end elseif (checkTime < frequency/2) then if mode == true then -- Now, not all games accept single-frame inputs. for j=1,cap do joypad.set(keysArray[j],j) -- So, for half of the frames between new keypress generations, send the same presses end -- But do you really want to use a PRNG with a high-precision game? else joypad.set(keysArray) end end end function countPlayers() -- returns the highest argument joypad.get(arg) can have / or nil if arg == 1 returns nil or an empty table local next = next -- Written by Amaraticando local MAX = 100 for count = 1, MAX do local joyget = joypad.get(count) if (joyget == nil or next(joyget) == nil) then if count == 1 then return nil else return count - 1 end end count = count + 1 if count == MAX then error"joypad.countPlayers: something went wrong" end -- sanity check end end function getButtonNames(mode) -- Scraping joypad.get(x) for key names. if mode == true then -- If there are multiple controllers connected, for i=1, countPlayers() do -- then for each controller keyNames[i] = {} -- make a new array in the key names array, k = 1 for key in pairs(joypad.get(i)) do -- and for each button on the controller keyNames[i][k] = key -- add it to the key names array. k = k + 1 -- DYNAMICALLY NESTED ARRAYS! end end else k = 1 for key in pairs(joypad.get()) do -- If there's only one controller connected, keyNames[k] = key -- then for each button on the controller k = k + 1 -- and add it to the key names array. end end end function sendRandomButtonPress(player) if player ~= nil then -- So let's look at sending random keys to the controller. keysArray[player] = joypad.get(player) -- First, fetch the current keys array. i = math.random(table.getn(keyNames[player])) -- Generate a random number between 1 and the length of the Key Names Array. push = keyNames[player][i] -- Grab the key referenced by the generated random number. if checkBlacklist(push) == true then -- If the key is not blacklisted, keysArray[player][push] = "True" -- then set the key to be pressed. else -- If the key is blacklisted, sendRandomButtonPress(player) -- then just pick a new key. end joypad.set(keysArray[player],player) -- Finally, send the keys array to BizHawk for pressing. else keysArray = joypad.get() -- Since joypad.get(1) returns nil if the core can only have one controller, i = math.random(table.getn(keyNames)) -- special handling has to be done for such cases. push = keyNames[i] if checkBlacklist(push) == true then keysArray[push] = "True" else sendRandomButtonPress() end joypad.set(keysArray) end end function checkBlacklist(key) -- Long story short, certain keys (such as the power button) shouldn't be pressed. result = true for i, v in pairs(blacklist) do if key == blacklist[i] then -- Check to make sure the button is not on the blacklist. result = false -- If it's on the blacklist, DO NOT PRESS THE BUTTON. end end return result end function initializeKeyArray() -- Just taking the key names and putting them into our placeholder arrays. cap = countPlayers() if cap == nil then mplay = false -- This is also when we determine if the core only expects a single controller. keysArray = joypad.get() else mplay = true for i=1, cap do keysArray[i] = joypad.get(i) end end end ---------------------------------------- AND NOW, FOR THE ACTUAL FUNCTION CALLS initializeKeyArray() getButtonNames(mplay) while true do core(mplay) emu.frameadvance() end
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Just a quick update. The PRNG Button press function itself has been genericized and now takes player as an int argument. It shouldn't be passed anything else as an argument simply because it passes player to joypad.get() and joypad.set(). Unfortunately, I haven't put in the return nil case kludge yet, this was just a patch job to get the refactoring started. In other words, it will fail for any core in which joypad.get(1) returns nil. In other other words, it will fail if the core only expects one controller (such as GBx)
Language: lua

-- PRNG BOT version 3 (Refraction) -- Just rewriting some variables and sendRandomButtonPress to allow for on-the-fly expansion up to five(!?) players in future updates. -- TODO: return-nil kludge, learn and implement forms. Prepare other functions for on-the-fly expansion. -- Global variable declarations -- checkTime = 0 -- Placeholder variable. I don't like passing expressions as arguments. keyNames = {[1] = {},[2] = {}} -- Key Names array. keysArray = {[1] = {},[2] = {}} -- Key State array. blacklist = {"Power", "Reset"} -- Blacklisted keys array. frequency = 10 -- How often should the bot be updating? Also influences how long the keys are held. mplay = false -- Is there a P2 controller? If not, we don't want to bother mucking around with P2 stuff. function core() -- I like to have a manager functon that only handles calling other functions. checkTime = emu.framecount() % frequency -- Set the frame count checker to the frame count modulo the frequency. if (checkTime == 0) then -- If we're on the right frame, then go ahead and generate a new random key. sendRandomButtonPress(1) -- For the technically-minded, it's actually pseudorandom, but let's not be overly pedantic. if mplay == true then -- If Player 2's controller exists, generate keypresses for it as well. sendRandomButtonPress(2) end elseif (checkTime < frequency/2) then -- Now, not all games accept single-frame inputs. joypad.set(keysArray[1],1) -- One of the games I tested with had this problem. if mplay == true then -- So, for half of the frames between new keypress generations, send the same presses. joypad.set(keysArray[2],2) -- This allows 'slower' games to keep up, though it also slows down high-precision games. end -- But do you really want to use a PRNG with a high-precision game? end end function getButtonNames() -- Scraping joypad.get(x) for key names. k = 1 j = 1 for key,v in pairs(joypad.get(1)) do -- For each pair in joypad.get(x) keyNames[1][k] = key -- keyNamesPX in position k is assigned key... uhh, key. k = k+1 -- and k is incremented. end if joypad.get(2) ~= nil then -- As long as there's a table for P2, do the same for P2. for key,v in pairs(joypad.get(2)) do keyNames[2][j] = key -- This can be rewritten to use one less for loop. j = j+1 -- However, I like it written this way since it's one less if-then than would be needed. mplay = true -- Since boolean mplay starts false, we set it true. end -- This allows me to tell other functions to skip the P2 stuff if there's no P2. end end function sendRandomButtonPress(player) -- So let's look at sending random keys to player 1's controller. keysArray[player] = joypad.get(player) -- First, fetch the current keys array. i = math.random(table.getn(keyNames[player])) -- Generate a random number between 1 and the length of the Player 1 Key Names Array. push = keyNames[player][i] -- Grab the key referenced by the generated random number. if checkBlacklist(push) == true then -- If the key is not blacklisted, keysArray[player][push] = "True" -- then set the key to be pressed. else sendRandomButtonPress(player) end joypad.set(keysArray[player],player) -- Finally, send the keys array to BizHawk for pressing. end function checkBlacklist(key) -- Long story short, certain keys (such as the power button) shouldn't be pressed. result = true for i, v in pairs(blacklist) do if key == blacklist[i] then -- Check to make sure the button is not on the blacklist. result = false -- If it's on the blacklist, DO NOT PRESS THE BUTTON. end end return result end function initializeKeyArray() -- Just taking the key names and putting them into our placeholder arrays. keysArray[1] = joypad.get(1) -- We don't actually need to do this now, as they're reinitialized every time keys are sent. if mplay == true then -- It's just best practice to initialize variables before using them. keysArray[2] = joypad.get(2) -- With that said, I do call the arrays before they get defined otherwise. end -- I can't remember if I actually tested without this function. end ---------------------------------------- AND NOW, FOR THE ACTUAL FUNCTION CALLS getButtonNames() initializeKeyArray() while true do core() emu.frameadvance() end
E: So, the upshot is now I'm going to be requesting a new joypad function: joypad.countPlayers(). Should just return the number of controllers the core will accept inputs for at that time - example, if in N64 mode you have it set up for three controllers, joypad.countPlayers() should return 3.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
What I have in mind is basically a brute-force with a whitelist (always on) and blacklist (always off) to constrain the explosion of possibilities. The general form should be O(cn), where n is the number of inputs not on either list and c is (max button states * number of frames). E: Here's the SMS table.
"P1 B1": "False"
"P1 B2": "False"
"P1 Down": "False"
"P1 Left": "False"
"P1 Right": "False"
"P1 Up": "False"
"P2 B1": "False"
"P2 B2": "False"
"P2 Down": "False"
"P2 Left": "False"
"P2 Right": "False"
"P2 Up": "False"
"Pause": "False"
"Reset": "False"
14 inputs, so for one frame's worth of bruting it's 214. In practice, it's only 13 inputs as the reset button is a BAD THING. Constraining to P1 only would instead yield this table.
"B1": "False"
"B2": "False"
"Down": "False"
"Left": "False"
"Right": "False"
"Up": "False"
6 inputs, so for one frame this would be 26 - 64 possible results before black/whitelisting. For two frames this would be 46 because then you have four possible state combinations for each button rather than two - off-off, on-off, off-on, or on-on. This is 4096 results before black/whitelisting, which is obstructively large. For that reason, it's best to both minimize input frames and maximize button locks - taking even one button out of the hypothetical 2-frame check brings it down to 45 - 1024 possibilities.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Hmm... I'll have to kludge it for the next revision then. Main reason it's important is because this way I don't have to hard code as much stuff. End goal is to make this script work across as many cores as possible.
Adventures in Lua When did I get a vest?
Post subject: This topic interests me. I will watch it.
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I have a PRNG Bot script for BizHawk that can be used as a starting point (mine works for all boolean-style inputs); I haven't played with savestating-via-lua yet. I presume, given the reference to your current WIP, that there's a specific game in mind? Might I ask what the game is and what domain/address the in-game RNG is at? E: There's also Basic Bot starting with BizHawk 1.11.2, though it may or may not be what you need since (1) it's also a PRNG Bot and (2) it's more designed for finding a highest-valued output rather than preserving changes in value outputs.
Adventures in Lua When did I get a vest?
1 2
16 17 18
31 32