Don't kill the run on the bonus intro screen

This commit is contained in:
Empathic Qubit 2021-05-05 18:18:59 -04:00
parent 0a59ab8b21
commit 1c1307a0e2
4 changed files with 26 additions and 23 deletions

View file

@ -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.

View file

@ -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, {

View file

@ -331,7 +331,6 @@ local function evaluateNetwork(_M, network, inputs, inputDeltas)
return {}
end
for i=1,Inputs do
network.neurons[i].value = inputs[i] * inputDeltas[i]
end
@ -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]

View file

@ -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