Posts for Pokota
1 2
17 18 19
31 32
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
So I've run into an interesting issue. joypad.get(1) returns nil if there's only one controller in the core. Easy way to see this is to call it in the Gambatte core. Why is this interesting?
Language: lua

-- PRNG BOT version 2 (Greentext) -- Changes (2015-11-07): -- P1 and P2 are now independently checked rather than just using the global joypad.get() results. -- This makes blacklisting less of a chore as joypad.whatever, when passed a player number, -- actually omits the player number prefix. -- The upshot is that perfecting the Blacklist is a little easier. -- -- Also, I removed the Buttons Pressed counter. It was not seeing any practical use. -- It was originally a debug variable, but I ended up debugging using the console anyway. -- -- Also also, documentation. This is the Greentext Update. -- Global variable declarations -- checkTime = 0 -- Placeholder variable. I don't like passing expressions as arguments. keyNamesP1 = {} -- Player 1 Key Names array. keysArrayP1 = {} -- Player 1 Key State array. keyNamesP2 = {} -- Player 2 Key Names array. keysArrayP2 = {} -- Player 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. sendRandomButtonPressP1() -- 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. sendRandomButtonPressP2() end elseif (checkTime < frequency/2) then -- Now, not all games accept single-frame inputs. joypad.set(keysArrayP1,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(keysArrayP2,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) keyNamesP1[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 keyNamesP2[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 sendRandomButtonPressP1() -- So let's look at sending random keys to player 1's controller. keysArrayP1 = joypad.get(1) -- First, fetch the current keys array. i = math.random(table.getn(keyNamesP1)) -- Generate a random number between 1 and the length of the Player 1 Key Names Array. push = keyNamesP1[i] -- Grab the key referenced by the generated random number. if checkBlacklist(push) == true then -- If the key is not blacklisted, keysArrayP1[push] = "True" -- then set the key to be pressed. end joypad.set(keysArrayP1,1) -- Finally, send the keys array to BizHawk for pressing. end function sendRandomButtonPressP2() -- This is a doublicate of the P1 variant. keysArrayP2 = joypad.get(2) -- Technically, these can be rewritten as a single function with clever argument use. i = math.random(table.getn(keyNamesP2)) -- It's on the docket for the next revision. push = keyNamesP2[i] if checkBlacklist(push) == true then keysArrayP2[push] = "True" end joypad.set(keysArrayP2,2) 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. keysArrayP1 = 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. keysArrayP2 = 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
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I fixed it by using a while true do loop to call core() instead of tying it to the frame start. So now the next step in this project is to make a form that can be used to pass both update frequency and an on-the-fly blacklist for buttons (say for if you want to shut off keys for P1 but not P2). Yes I realize I'm just recreating most of what's in Basic Bot, but I find basic bot too... focused on getting results for my purposes of pure entertainment through PRNG.
Language: lua

ccheckTime = 0 buttonsPressed = 0 keyNames = {} keysArray = {} blacklist = {"Power", "Reset"} frequency = 10 function core() checkTime = emu.framecount() % frequency if (checkTime == 0) then sendRandomButtonPress() elseif (checkTime < frequency/2) then joypad.set(keysArray) end end function sendRandomButtonPress() keysArray = joypad.get() i = math.random(table.getn(keyNames)) push = keyNames[i] if checkBlacklist(push) == true then keysArray[push] = "True" end joypad.set(keysArray) buttonsPressed = buttonsPressed + 1 end function getButtonNames() k = 1 for key,v in pairs(joypad.get()) do keyNames[k] = key k = k+1 end end function checkBlacklist(key) result = true for i, v in pairs(blacklist) do if key == blacklist[i] then result = false end end return result end function initializeKeyArray() keysArray = joypad.get() end getButtonNames() initializeKeyArray() while true do core() emu.frameadvance() end
Adventures in Lua When did I get a vest?
Post subject: generic PRNG lua script
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Language: lua

checkTime = 0 buttonsPressed = 0 keyNames = {} keysArray = {} function core() checkTime = emu.framecount() % 10 if (checkTime == 0) then sendRandomButtonPress() end end function sendRandomButtonPress() keysArray = joypad.get() i = math.random(table.getn(keyNames)) push = keyNames[i] if push ~= "Power" and push ~= "P1 Power" and push ~= "P2 Power" then keysArray[push] = "True" end joypad.set(keysArray) buttonsPressed = buttonsPressed + 1 end function getButtonNames() k = 1 for i,v in pairs(joypad.get())do keyNames[k] = i k = k+1 end end getButtonNames() event.onframestart(core)
So now this is working more-or-less as intended; Power gets blacklisted outright, and I haven't tried it with multidisk mode yet so there may be more blacklisting. Right now, I'm curious to find out why it sends multiple button presses - it's currently sending two buttons with each update. My current guess is because the key state table (keysArray) isn't actually getting reset between calls. Still, it is at least able to get massacred by Gary in 1P pokemon, so it's more progress than I had this time last week.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I'll give that method a try; I'm also gonna try generating a table of button names from joypad.get() and using that as both my length reference as well as my key reference variable (at this point I think I'm just spouting off random words and hoping they make sense) since there's no way to call buttons by integer reference at this time. In short, relearning regex in the context of lua. E: Yeah a reference table might work better since then I can blacklist certain buttons if I find a need to.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
So as I'm not going to be using Basic Bot for the intended purpose (and don't want to clog my bizhawk with Loadstate Failed messages), I figured I may as well write up an RNG-powered Lua script myself. EDIT: What I'm aiming to do is make it platform-independent - say, if I want to run it on an NES game for one run, then a Genesis game the next, then a 2600 game after that. So far I have
Language: lua

checkTime = 0 buttonsPressed = 0 function core() checkTime = emu.framecount() % 10 if (checkTime == 0) then sendRandomButtonPress() end end function sendRandomButtonPress() keysArray = joypad.get(1) i = math.random(table.getn(keysArray)) keysArray[i] = "True" joypad.set(keysArray,1) buttonsPressed = buttonsPressed + 1 end event.onframestart(core)
which fails because table.getn(keysArray) returns 0. Is there another way to check table length that I've overlooked, or is the table library not implemented or am I just being a dumb?
Adventures in Lua When did I get a vest?
Post subject: I'll edit in links later when I'm logged into fimfic
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I haven't really read a lot of pony fanfics lately; I've read both The Games We Play and Background Pony; there's also The God Squad (part one is finished, part two doesn't seem to be yet) and the Equestria Civil Services stores (starting with Those Whom The Princesses Would Destroy). Another one I've read is Princess Celestia Hates Tea, the premise of which is very amusing. There's also a strange crossover one with Hitchhiker's Guide that I can't remember the name of, as well as an (incomplete) cycle of stories starting with The Perfect Little Village of Ponyville. I've actually not read Fallout: Equestria yet, though that's next on my list of fics to read.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Prayer, focused study, and generally wanting to have that kind of personal conviction.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Two and a half, really - the two hitsquad versions only appear to differ between whether the copy protection is there or not. The one with the copy protection is assumed to be the floppy disk release (1.07 Hitsquad, or Hitsquad 3.5") and the one without is assumed to be their CD release (Hitsquad CD). There shouldn't be any material difference between the EU versions outside of copy protection - the filesize of the executable differs between EU and Hitsquad 3.5" but that's about it. Dune Legacy (a remake project, though not as reverse-engineery as OpenDune) has a listing of the file differences. I don't remember if we had the Floppy Disk version or a CD version when I was a kid.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Tested on 1.00, 1.07 EU and US, and HitSquad 3.5" (Haven't tried Hitsquad CD yet but I don't see it failing there) I haven't tried Ordos 2 military victory yet.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
It doesn't reset on a new campaign, either, for what it's worth.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Can you recreate this 1) with a clean scenario.pak file? 2) in other versions of the game? I just tried in 1.00 US with Atreides and the credit decay appears to have foiled it.
Adventures in Lua When did I get a vest?
Post subject: Yes I'm aware of the necro length
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Where are the directions for starting Gambatte's dual mode from within BizHawk?
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Dxtory, mainly, as that's how I'm set up. I haven't tried dumping directly from dosbox yet. Which version are you running? I don't remember bullets being screwy with east/west damage.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Truncated wrote:
Troopers can shoot over structures, but the Ordos Harvester can mow them down, so it doesn't have to be an issue. Their Raider Trikes are significantly weaker than Harkonnen Quads, though. I checked in scenario.pak, and Harkonnen start with 0 credits in Ordos 2. (Atreides starts with 100 credits in Harkonnen 2.) So if you take down their Refinery before first harvest, they can't repair at all.
I'll give this a shot, but I'm not sure I can pull it off (I play too defensively). Can we get someone else working on this in case I fall flat on my face?
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
I guess we have a winner. That strat should also work for Atreides to a limited degree, but the Ordos have a construction yard in all variations of that mission. It probably won't for Ordos because Trooper rockets pass over structures and can snipe down the harvester. So, per house strats are looking like this. Harkonnen: Ignore Concrete, Starter Rush with Harvester as bait. Atreides: Ignore Concrete, Harvesting Blitz Ordos: Ignore Concrete, Harvesting Blitz
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
It looks more like a flavor thing than anything else. 1) The Sardaukar in canon are trained on Salusa Secundus, a hellish prison planet that's been engineered to be the perfect secret army training location. 2) Leto (and by extension Paul) wanted to use Arrakis to raise up an equivalent to the Sardaukar - and they got it from the Fremen. It would seem odd to those familiar with the setting to not have something praising the fighting prowess of the Imperial and Fremen forces. Though why there isn't a faction modifier on the Fremen is a good question. They have a faction definition, but only have two three units show up in the official game - Sandworm, Trooper Squad and Trooper Solo. (Sardaukar is understandable as they do have a functional base in the finale) If nothing else, it's a good psyche-out. You don't see the Fremen coming until it's too late (how is their spawning determined?) and the player doesn't expect the Sardaukar Inquisition the first time playing. E: Forgot that the Sandworms are internally listed as Fremen units. E2:
Nach wrote:
That's a windows launcher. I guess all the CD versions were patched to exclude the copy protection. Can you post up the copyright text that's on the CD? The whitetext that's near the outer edge of the label.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Nach wrote:
WTH is the Mentat asking you about the IX facility?
Version 1.0, I think was the version I was using. It's just the copy protection. To my knowledge the only official version that doesn't include that is HitSquad CD, which is based off of EU 1.07
Watching your video, it seems the game is moving somewhat slower for you than it is for me, yet I think the time it computes for me is larger than that difference, considerably so. I haven't timed it yet, but I think the game is computing time elapsed at level completion ~1.5-2 times greater than real time for me.
Entirely possible. Do the three-refinery solution for mission 3 and report back your results.
It would seem we're using versions which differ considerably, or the way we're running it causing the game to react differently?
Both possible. I'm running the latest Dosbox SVN Daum as my playtesting environment (I'm still having trouble wrapping my head around JPC-rr). I can switch versions at the drop of a hat, just in case you're using a version I'm not. Would you download the editor I'm using and verify which version of Dune II you're running? Copy your Dune folder and drop the editor in that, the editor should show your base version on the second line, over on the right.
Back when I used to play this on my 3x86, I recall that when it reported a missile was fired at me, I had a couple of seconds before it would reach my base. Now however, as it's being reported, it already hits (meaning the audio playing speed is constant but the game speed outpaces it).
That sounds more than likely a processor speed variation than anything else, but it could also be a versioning difference.
And how do we know the game doesn't change stats on a per level basis? I don't have any hard evidence for that in Dune II, but I know for a fact Westwood did that in various Command & Conquer games.
We don't, yet, though there's strong support for the Sardaukar (and weak support for the Fremen) being derived units if not simply factional rebrandings. E: With that said, once we figure out what version we're using, it's pseudotrivial to prove if the stats change or not as we can check the RAM. Do we have a DOS emulation environment that includes address viewing or memory search? I'm not sure where to find it in JPC-rr
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Speed differences for the first missions are negligible - all houses can one-cycle the first mission (Atreides needs one concrete to get PB Refinery placement) and all houses can get six minutes in the second mission (Ordos needed two concrete for one of the refineries' placement). I'll whip up a "free concrete" mod and see if refinery speed is adversely affected by foundations or not. It's probably going to be outside the scope of a TAS, but it's still worth knowing.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Sardaukar confirmed as frauds! Fremen confirmed as charlatains! Details at eleven! I'll poke the other houses and see what their times for the first two missions are. Hark is fastest for just those two because the spice is RIGHT THERE.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
It's not TASed; if it were it'd be a hell of a lot cleaner.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Link to video NOTE: Not recorded in JPC-rr; I'm still learning the ropes on how to use it. Doesn't look like it'd be good for general play or for quick demonstrations given it doesn't send through mouse or keyboard input (instead relying on the virtual keyboard and mouse menu). I can't tell if three refineries or two refineries and a silo would be faster. I screwed up the execution on both, but I want to say that Three Refineries will be faster.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
First time using JPC-rr. I keep expecting it to send my keyboard/mouse inputs from the keyboard/mouse and I know that's not going to be correct but it still took me over a minute just to get to the Geidi Prime image.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
What was your time? I got six minutes just focusing on the harvesting, and that's without micromanaging the harvesters.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
The "Run Score"? Oh, "running up the score" - basically scoring more points by killing enemies since the mission completion speed (especially for mission #1) is dependent entirely on the Harvester, which has to complete at least one harvesting cycle in order to complete the mission. No time should be lost hunting down the enemy in mission 1 as the Harvester should maintain full CPU while off-screen. It's riskier to do in mission 2 as the enemy has an actual base and requires more planning to pull off, but it should still be possible to get an unexpectedly high score. Note: the largest factor regarding Score seems to be spice harvested, so score maximizing in a TAS should be limited to missions 1 and 2 (harvesting takes time). I don't know if it's just Spice Harvested or if it's Difference in harvested spice between Player and AI.
Adventures in Lua When did I get a vest?
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 779
Truncated wrote:
Thanks, Pokota! This made me go back to the source and I realized where I went wrong before. New suggestion: The power output is proportional to health between 50%-100%. If the Windtrap is below 50% health, it still gives 50 power. You could try it by setting two Windtraps to minimum health and see if they can power a base which needs 100 power.
I'll do you one better - the Radar facility only requires 30 power, so that's something that can be put paid to once and for all (you get just enough credits in mission 2 to build the Outpost first). Expect a new demo from 1.07 EU up shortly.
Ah, so the repair facility works at the same speed even at low health? I'll see if I can confirm this in source. I was referring to building self repair earlier, so we misunderstood each other. Can you check if buildings repair themselves slower at low health?
Building repair does not (appear to) slow down at low health. The Repair Facility slows down for Unit Repair at low health. Sorry for the confusion. ALSO: I did a dirty test last night for the first two missions (tested on Harkonnen, but should be viable across all houses) - First mission can be done in one harvester cycle, second can be done in two-and-a-half (one windtrap, two refineries, then a third refinery after the first two harvesters unload once). This ends up being 4 minutes in-game for the first mission and six for the second. Outage decay appeared to be a minimal factor given the outage wasn't until after the 2nd refinery was placed, and there's no weather decay in missions 1 and 2. Using a Silo instead of a third refinery should improve Mission 2 further, I'll give it a run tonight. There's no way extermination is faster in Mission 2. Since missions 1 and 2 are quota missions, should we run up the score while we're waiting for the harvesters to get back? Killing enemy units without losing any of our own would do the trick and provide mild entertainment during the downtime (harvesters are unaffected by being off-screen). NOTE: I'll have an easier time doing these test videos on EU 1.07 than anything else at the moment as my recording station only has EU 1.07 right now. I intend to fix that for Thursday. E: I was not expecting this result. I wonder why it's made this way? Link to video
Adventures in Lua When did I get a vest?
1 2
17 18 19
31 32