Kill the run the instant the map screen gets loaded
This commit is contained in:
parent
9fa4ef5463
commit
9a996b7285
2 changed files with 20 additions and 6 deletions
14
game.lua
14
game.lua
|
@ -401,14 +401,28 @@ function _M.onceAreaLoaded(handler)
|
|||
table.insert(areaLoadedQueue, handler)
|
||||
end
|
||||
|
||||
local mapLoadedQueue = {}
|
||||
function _M.onceMapLoaded(handler)
|
||||
-- TODO For now we only want one at a time
|
||||
mapLoadedQueue = {}
|
||||
table.insert(mapLoadedQueue, handler)
|
||||
end
|
||||
|
||||
function processAreaLoad()
|
||||
for i=#areaLoadedQueue,1,-1 do
|
||||
table.remove(areaLoadedQueue, i)()
|
||||
end
|
||||
end
|
||||
|
||||
function processMapLoad()
|
||||
for i=#mapLoadedQueue,1,-1 do
|
||||
table.remove(mapLoadedQueue, i)()
|
||||
end
|
||||
end
|
||||
|
||||
function _M.registerHandlers()
|
||||
memory2.BUS:registerwrite(0xb517b2, processAreaLoad)
|
||||
memory2.WRAM:registerread(0x06b1, processMapLoad)
|
||||
end
|
||||
|
||||
return _M
|
||||
|
|
|
@ -662,6 +662,10 @@ function on_timer()
|
|||
end
|
||||
pool.currentFrame = 0
|
||||
timeout = config.NeatConfig.TimeoutConstant
|
||||
-- Kill the run if we go back to the map screen
|
||||
game.onceMapLoaded(function()
|
||||
timeout = -100000
|
||||
end)
|
||||
game.clearJoypad()
|
||||
startKong = game.getKong()
|
||||
startBananas = game.getBananas()
|
||||
|
@ -942,11 +946,6 @@ function mainLoop (species, genome)
|
|||
timeout = timeout + 60 * 10
|
||||
end
|
||||
|
||||
local lives = game.getLives()
|
||||
if lives == 0 then
|
||||
timeout = 0
|
||||
end
|
||||
|
||||
timeout = timeout - 1
|
||||
|
||||
-- Continue if we haven't timed out
|
||||
|
@ -986,9 +985,10 @@ function mainLoop (species, genome)
|
|||
most = most - pool.currentFrame / 2
|
||||
end
|
||||
|
||||
|
||||
local fitness = bananaCoinsFitness - hitPenalty + powerUpBonus + most + game.getJumpHeight() / 100
|
||||
|
||||
local lives = game.getLives()
|
||||
|
||||
if startLives < lives then
|
||||
local ExtraLiveBonus = (lives - startLives)*1000
|
||||
fitness = fitness + ExtraLiveBonus
|
||||
|
|
Loading…
Add table
Reference in a new issue