Posts for skypickle


Experienced Forum User
Joined: 6/14/2015
Posts: 19
Thank you Amaraticando. I was reading through your utility code and found many interesting things as I am still learning LUA. I will prob go off topic so please direct me to the correct forum as these are mostly programming questions. 1) why do you use a make_set function? You use it for ABNORMAL_HITBOX_SPRITES where you make a table with 4 entries of RAM addresses like so:
local ABNORMAL_HITBOX_SPRITES = make_set{0x62, 0x63, 0x6b, 0x6c}
This table is used once in line 1038 here:
  if SHOW_SPRITE_HITBOX and not ABNORMAL_HITBOX_SPRITES[number] then
Is it not simpler to just construct the table in the first place like so:
ABNORMAL_HITBOX_SPRITES = {[1]=0x62, [2]=0x63, [3]=0x6b,[4] = 0x6b,}
instead of first making a list then an iterator to create an array? 2) Why are variables declared as local in the top level? for example , local ABNORMAL_HITBOX_SPRITES and functions too for example
local Isloaded, Movie_mode, Readonly, Currentframe, Framecount, Lagcount, Rerecords, Islagged
These are at the 'top level' and not within any other function so I do not see how making them local changes their scope. 3) in the MAIN loop, why do you call bizhawk_screen_info()? This is just a setup function that gets screen boundaries. Should it not be called just once before the loop? 4) Why is the client.paint() function OUTSIDE the main loop? What does it do? 5) functions defined but not used - test_draw_pixels ? 6) thanks again
Experienced Forum User
Joined: 6/14/2015
Posts: 19
Unfortunately there is no real facility for parallel processing in LUA. this thread: http://stackoverflow.com/questions/5689548/what-multithreading-package-for-lua-just-works-as-shipped all the options for concurrency are reviewed and found lacking. It seems Lua is intended for being embedded in a single thread at the time. Anyway, the scripts run so fast as it is. In Mar I/O, it is amazing how much AI calculation gets done in each frame without impacting the framerate of the game. I guess that's possible when you're not using cpu resources running a complex game and rendering millions of polygons/sec.
Post subject: layers and other variables in SMW
Experienced Forum User
Joined: 6/14/2015
Posts: 19
I am trying to understand what the different ram addresses inSMW actually represent in the game. Yes I know, I should just play the game and figure it out and I did for most of them but there are still a few concepts that elude me. These are code samples from the evolve script for SMW. What are layers for and why are they needed?
local layer1x = memory.read_s16_le(0x1A);
local layer1y = memory.read_s16_le(0x1C);
What is screen position and why is that different than Mario position?
screenX = memory.readbyte(0x03AD)
screenY = memory.readbyte(0x03B8)
there are 12 sprite and status locations.what are they for?
function getSprites()
		local sprites = {}
		for slot=0,11 do
			local status = memory.readbyte(0x14C8+slot)
			if status ~= 0 then
				spritex = memory.readbyte(0xE4+slot) + memory.readbyte(0x14E0+slot)*256
				spritey = memory.readbyte(0xD8+slot) + memory.readbyte(0x14D4+slot)*256
				sprites[#sprites+1] = {["x"]=spritex, ["y"]=spritey}
			end
		end		
return sprites
What are extended sprites?
Experienced Forum User
Joined: 6/14/2015
Posts: 19
well, not all gameboy games work. Metroid fusion gives this error: Mole mania starts but it asks to hit the 'start' button. Unfortunately, no keys work for this.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
aha. that explains why there was no SNES folder in the biz hawk contents. thank you. But )it also fails at regular NES games. )I gt this dialog with Legend of Zelda as well as SMB. Gameboy roms work tho.
Post subject: mac version Bizhawk error
Experienced Forum User
Joined: 6/14/2015
Posts: 19
Using OS X Mavericks on macbook pro w 6 g ram. Mono installs fine. Bizhawk 1.91 for mac starts fine. Super Mario World(USA).sfc is placed inside Mono folder inside of contents folder in package contents of Bizhawk. Any suggestions?
Experienced Forum User
Joined: 6/14/2015
Posts: 19
tom_mai78101 wrote:
Does the generation counter resets after a certain amount?
not yet. up to gen 45.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
thanks for the idea (and the code) for the ram check. But since I am a noob, maybe you all can tell me what an 'smw case' is. Are you referring to 'SuperMarioWorld case'? That kind of reference belies a whole universe outside this problem and suggests an awareness of a solution that has nothing to do with SMW. Could you link me so I can understand what you are alluding to? I agree, that the game should eventually try to press the A button (z key) when a dialog appears, but it never does. It just times out. It should be noted that the event of MArio hitting the bottom of the correct box to generate a dialog box is a rare event. The same thing happens in other circumstances as well. When Mario would run up against a wall/step early in the simulation, he would just stop and it would time out. He would never try jumping. The only time he would get over a jump is if was already in 'jumping mode'. The transition to jumping mode seems to be a random event an not triggered by waiting. Same thing with the veritcal pipes (stacks?) If his jump makes him crash into a pipe and he slides to its bottom, he will then jump over it since he is in jumping mode. But if he runs into a pipe, he never gets the idea to jump over it. I guess the fitness is trying to minimize time so any waiting is considered a negative and that genome is considered a failure. It's just like a corporate exec who seeks to maximize earnings per share in the short term. Long term wins at the expense of short term losses are never considered. When I get a better understanding of this script, I need to try and have it increase the mutation rate when Mario's travel stops. This kind of thing also lends itself to parallel processing. One thread is 'driving Mario' and another thread is monitoring his velocity so that when velocity goes to zero, it changes the params. However, I dont know how to write asynchronous threads in LUA. I have a hard enough time keeping my head straight with node.js and its use of closures to achieve asynchronicity.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
I have been running this for ~3 days. Max score achieved after 2 days, 4502. Now MArio still scores around the 4000-4200s with occasional bad runs. He is at generation 41, species 30 genome 5. He usually goes to Yoshi's island 3. He now also avoids the green chimney(which drops to another level). Interestingly, he has evolved into a kangaroo. Glitches in the script include the dialog boxes that pop up. To dismiss these requires a press of the 'z' key but the script times out and considers the dialog a failure. Increasing the the timeout does not solve this bug. I could upload the DPI.state.pool file (~700k) if anyone is interested but this site does not allow uploads.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
I had the same problem with the path. Yes the root folder thing fixes it. But so does moving to the more recent version of bizhawk (1.10)
Experienced Forum User
Joined: 6/14/2015
Posts: 19
@Henke trying to learn from your code. 1) TimeoutConstant=20 (line 41) Is that 20 millisec? It seems the game waits longer than that when Mario is against a wall or just stopped. More like3 sec. Obviously I am missing something. 2) What is going on in this loop (line 532 in your code)
 for s = 1,#pool.species do 
      local species = pool.species[s] 
      for g = 1,#species.genomes do 
         table.insert(global, species.genomes[g]) 
      end 
I do not understand the syntax of using the number sign in a for loop. Why not use getn function? This discussion about the '#' suggests there is more depth to the choice of using this syntax: https://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table Do you have any words of wisdom? 3) I am wondering what you did to the mutate genome function. see pastebin for relevant code http://pastebin.com/raw.php?i=WtZa1Jc3 You both start by randomly picking a hi or lo mutation rate. The original looks in the array genome.mutationRates and randomly either enables or disables a property. His syntax is curious- he uses a while loop that is designed to only execute once. Why bother with a while loop and a local p variable? Your syntax is even more confusing. What does this do:
if math.random() <genome> 0
and then why are there a bunch of sequential if statements? and finally you set p to a negative number though it isnt used?
Experienced Forum User
Joined: 6/14/2015
Posts: 19
please enlighten me as to how LUA scripting is being used in half-life 2 and other source games? or are you using a different scripting language to assist your gameplay? PS: I am even more of a beginner than the OP.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
hegyak wrote:
skypickle wrote:
OK, I can start the MarIO script and get a dialog window named Fitness. When I hit the restart btn, I get an 'unhandled exception' A .Net exception occured in user code' LuaInterface.LuaScriptException: [string "main"]:829: A .NET exception occured in user-code
This will be fixed in Version 1.10.0
Do you have any suggestions for how I can figure out why MY system is misbehaving? Clearly, some people can run evolve.lua without difficulty and save a DP1.state file. I am running Win 7 Pro 64 bit with .NET 4.5.2
Experienced Forum User
Joined: 6/14/2015
Posts: 19
ok, leaving aside this bug with DPI.state, maybe someone can explain what DPI.state.pool is? Also, as the sim proceeds, I am accumulating multiple files in the root dir that are backup.0.DP1.state.pool, backup.1.DP1.state.pool, backup.3.DP1.state.pool, etc. They gradually increase in size and the time separation between them also increases. I tried renaming one of them to DP1.state to use it as a 'savegame' file to reinitiate the sim from that point-but that did not work. Loading the unaltered filename(backup.3.DP1.state.pool) restores the game but not to the most recent state-just the state the sim was in when the file was written. However if i click save, a new DP1.state gets written (newer time stamp ). Reloading THAT file gets me to the most recent state. What determines when the pool files are written? Also, when Mario frees Yoshi (by bumping into the cube that holds him) a dialog pops up thanking MArio for freeing him. This causes a delay which the script interprets as a failure and it restarts with the next iteration. The script needs to be tweaked to allow for these delays.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
ok zeromus. yours works fine. so I just copied over your DPI.state file and it works. So for my own education, how can I figure out why I could not save a DPI.state file? or even get to a condition when I could save a working one? If I remove the DPI.state file from your mario-evolve folder, I reproduce my problem-the script will not start and hitting restart gives an 829 dot net error.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
deleted post - new bizhawk version fixed the problem
Experienced Forum User
Joined: 6/14/2015
Posts: 19
yes, Pasky13's script. And i also got Amaraticando's script working. But cannot get MarIO to run. see my post in that thread.
Experienced Forum User
Joined: 6/14/2015
Posts: 19
thank you for a prompt reply. Yes, it is one of the scripts that came with bizhawk.
Post subject: really basic help
Experienced Forum User
Joined: 6/14/2015
Posts: 19
Please forgive this REALLY NOOB question. But the first bunch of search hits (Bing,google) point me here so I'll ask. How do I use LUA scripting with Bizhawk? I read this: http://tasvideos.org/LuaScripting.html but it's more of a manual and unfortunately I could not find a REALLY BASIC tut on youtube. I downloaded bizhawk and got it to run with a bunch of roms. I also got LUA running and have written some basic LUA scripts, but nothing that runs *inside* of another program or game. So for example I put the Super Mario World ROM inside the SNES folder in the bizhawk folder. I start EmuHawk and I go to Tools>LUA console. I open the script in the folder Bizhawk>LUA>SNES named super mario world. I get an error in the output window Error: NullHawk does not implement memory domains Unable to find domain: CARTROM Error: NullHawk does not implement memory domains LuaInterface.LuaScriptException: 148 OK so I forgot to start the game. I start it and it's running nicely (music too!) Now I reload the script and it's state is active. I'm still at the opening mario screen. Maybe I have to start the game? I hit return three times and there is Mario standing in front of his house. The L and R keys move him. The Z key selects my choice. He is STILL standing there - in a garden but now I see a little blue box around him. I would like to understand what the script is doing but of course it is 245 lines long. In the script are a bunch of what look like local variables being assigned memory addresses? 6 character hex digits. Then memory.usememorydomain("CARTROM") Then a bunch of local functions are defined mario() projectiles() objects() invulns() then the main loop while true do mario() objects() invulns() projectiles() emu.frameadvance() end So basically this script draws a box around the active objects in this game?