diff --git a/config.lua b/config.lua index d9b2ad4..3abe37d 100644 --- a/config.lua +++ b/config.lua @@ -24,9 +24,10 @@ _M.State = { -- W1.2 Mainbrace Mayhem "MainbraceMayhem.lsmv", -- [4] + "MainbraceMayhemBonus.lsmv", -- [5] } -_M.Filename = _M.PoolDir .. _M.State[4] +_M.Filename = _M.PoolDir .. _M.State[1] --[[ Start game with specific powerup. diff --git a/game.lua b/game.lua index bc1d16a..014d6b0 100644 --- a/game.lua +++ b/game.lua @@ -615,6 +615,17 @@ local function processMapLoad() areaLoadedQueue = {} -- We clear this because it doesn't make any sense after the map screen loads end +function _M.bonusScreenDisplayed(inputs) + local count = 0 + for i=1,#inputs,1 do + if inputs[i] ~= 0 then + count = count + 1 + end + end + + return count < 10 +end + local handlers = {} local function registerHandler(space, regname, addr, callback) table.insert(handlers, { diff --git a/runner.lua b/runner.lua index 49876f9..f43d49f 100644 --- a/runner.lua +++ b/runner.lua @@ -330,7 +330,6 @@ local function evaluateNetwork(_M, network, inputs, inputDeltas) message(_M, "Incorrect number of neural network inputs.", 0x00990000) return {} end - for i=1,Inputs do network.neurons[i].value = inputs[i] * inputDeltas[i] @@ -382,12 +381,9 @@ end local frame = 0 local lastFrame = 0 -local function evaluateCurrent(_M) +local function evaluateCurrent(_M, inputs, inputDeltas) local genome = _M.currentSpecies.genomes[_M.currentGenomeIndex] - local inputDeltas = {} - local inputs, inputDeltas = game.getInputs() - controller = evaluateNetwork(_M, genome.network, inputs, inputDeltas) if controller[6] and controller[7] then @@ -506,7 +502,9 @@ local function initializeRun(_M) local genome = _M.currentSpecies.genomes[_M.currentGenomeIndex] generateNetwork(genome) - evaluateCurrent(_M) + + local inputs, inputDeltas = game.getInputs() + evaluateCurrent(_M, inputs, inputDeltas) end) end @@ -524,6 +522,7 @@ local function mainLoop(_M, genome) if nextArea ~= _M.lastArea then _M.lastArea = nextArea game.onceAreaLoaded(function() + message(_M, 'Loaded area '..nextArea) _M.timeout = _M.timeout + 60 * 5 _M.currentArea = nextArea _M.lastArea = _M.currentArea @@ -555,10 +554,6 @@ local function mainLoop(_M, genome) displayGenome(genome) end - if _M.currentFrame%5 == 0 then - evaluateCurrent(_M) - end - game.getPositions() local timeoutConst = 0 if game.vertical then @@ -567,13 +562,13 @@ local function mainLoop(_M, genome) timeoutConst = config.NeatConfig.TimeoutConstant end - -- Don't punish being launched by barrels - -- FIXME Will this skew mine cart levels? - if game.getVelocityY() < -2104 then - message(_M, "BARREL! ".._M.drawFrame, 0x00ffff00) - if _M.timeout < timeoutConst + 60 * 12 then - _M.timeout = _M.timeout + 60 * 12 + if _M.currentFrame%5 == 0 then + local inputs, inputDeltas = game.getInputs() + if game.bonusScreenDisplayed(inputs) and _M.timeout < timeoutConst then + _M.timeout = timeoutConst end + + evaluateCurrent(_M, inputs, inputDeltas) end local areaInfo = _M.areaInfo[_M.currentArea] diff --git a/tools/status-overlay.lua b/tools/status-overlay.lua index ed2349c..3914859 100644 --- a/tools/status-overlay.lua +++ b/tools/status-overlay.lua @@ -15,6 +15,8 @@ local config = dofile(base.."/config.lua") spritelist.InitSpriteList() spritelist.InitExtSpriteList() +game.registerHandlers() + local CAMERA_MODE = 0x7e054f local DIDDY_X_VELOCITY = 0x7e0e02 local DIDDY_Y_VELOCITY = 0x7e0e06 @@ -437,12 +439,6 @@ input.keyhook("0", true) set_timer_timeout(100 * 1000) -for i=0,22,1 do - memory2.BUS:registerwrite(mem.addr.spriteBase + mem.size.sprite * i + mem.offset.sprite.x, function(addr, val) - print(memory.getregister('pc')) - end) -end - -- fe0a58 crate: near bunch and klomp on barrels -- fe0a58: Crate X position -- fe0a60: Crate Y position