diff --git a/README.md b/README.md index ec77a73..104c738 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ See [YouTube](https://www.youtube.com/watch?v=Q69_wmEkp-k) for an example run. 3. Load the DKC2 ROM: `File -> Load -> ROM...` 4. Load the `neat-donk.lua` script: `Tools -> Run Lua script...` 5. You may also want to turn off sound since it may get annoying. `Configure -> Sounds enabled` -6. Look at config.lua for some settings you can change. Not all have been tested, but you should be able to change the number on the `_M.Filename =` line to get a different state file from the `_M.State` list. +6. Look at config.lua for some settings you can change. Not all have been tested, but you should be able to change the number on the `_M.Filename =` line to get a different state file from the `_M.State` list. Also note the `Threads =` line. Change this to 1 to prevent multiple instances of lsnes from getting launched at once. If you use more than 1 thread, you may also want to launch `lsnes` using xpra to manage the windows, with the `xpra-run.sh` script. If you want a better idea of what's going on with the tile and sprite calculations you may want to load `donkutil.lua`. It will mark the tiles with their offsets on the screen, give a crosshair with tile measurements (every 32 pixels), and list information about the sprites (you can use the 1 and 2 keys above the letter keys to page through them). Sprites labeled in green are considered "good", red is "bad", normal color is neutral. Solid red means that it's the active sprite in the info viewer. diff --git a/neat-donk.lua b/neat-donk.lua index e97d696..0a778b6 100644 --- a/neat-donk.lua +++ b/neat-donk.lua @@ -2,9 +2,9 @@ local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1") +local game = dofile(base.."/game.lua") local config = dofile(base.."/config.lua") local pool = dofile(base.."/pool.lua") -local game = dofile(base.."/game.lua") local util = dofile(base.."/util.lua") local statusLine = nil @@ -32,4 +32,7 @@ pool.onRenderForm(function(form) end end) pool.run() - + +function on_post_load() + print("HELLO LOAD") +end diff --git a/runner-wrapper.lua b/runner-wrapper.lua index cedb8e7..cafa01f 100644 --- a/runner-wrapper.lua +++ b/runner-wrapper.lua @@ -1,5 +1,6 @@ local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*[/\\])(.*)", "%1") +local config = dofile(base.."/config.lua") local serpent = dofile(base.."/serpent.lua") local tmpFileName = "/tmp/donk_runner_"..tostring(math.floor(random.integer(0, 0xffffffffffffffff))):hex() @@ -75,7 +76,7 @@ return function() inputFile:write(serpent.dump({species[i], generationIdx, speciesIdx + i - 1, outputFileName})) inputFile:close() - local cmd = "RUNNER_DATA=\""..inputFileName.."\" lsnes \"--rom="..base.."/rom.sfc\" --unpause \"--lua="..base.."/runner-process.lua\"" + local cmd = "RUNNER_DATA=\""..inputFileName.."\" lsnes \"--rom="..config.ROM.."\" --unpause \"--lua="..base.."/runner-process.lua\"" message(_M, cmd) local poppet = io.popen(cmd, 'r') table.insert(poppets, poppet) diff --git a/runner.lua b/runner.lua index 3011547..288ab4a 100644 --- a/runner.lua +++ b/runner.lua @@ -4,8 +4,6 @@ local config = dofile(base.."/config.lua") local game = dofile(base.."/game.lua") local mathFunctions = dofile(base.."/mathFunctions.lua") -game.registerHandlers() - local Inputs = config.InputSize+1 local Outputs = #config.ButtonNames @@ -778,6 +776,8 @@ local function saveLoadInput(_M) end local function run(_M, species, generationIdx, speciesIdx, genomeCallback, finishCallback) + game.registerHandlers() + _M.currentGenerationIndex = generationIdx _M.currentSpeciesIndex = speciesIdx _M.currentSpecies = species