Severe punishment for falling
This commit is contained in:
parent
75c3ef6f4b
commit
3f872c169c
2 changed files with 18 additions and 2 deletions
9
game.lua
9
game.lua
|
@ -372,6 +372,15 @@ function _M.getJumpHeight()
|
|||
return sprite.jumpHeight
|
||||
end
|
||||
|
||||
function _M.fell()
|
||||
local sprite = _M.getSprite(_M.leader)
|
||||
if sprite == nil then
|
||||
return 0
|
||||
end
|
||||
|
||||
return sprite.motion == 0x3b
|
||||
end
|
||||
|
||||
function _M.getSprite(idx)
|
||||
local baseAddr = idx * mem.size.sprite + mem.addr.spriteBase
|
||||
local spriteData = memory.readregion(baseAddr, mem.size.sprite)
|
||||
|
|
11
runner.lua
11
runner.lua
|
@ -618,9 +618,11 @@ local function mainLoop(_M, genome)
|
|||
message(_M, string.format("We missed %d frames", frame - lastFrame), 0x00990000)
|
||||
end
|
||||
|
||||
local fell = game.fell()
|
||||
|
||||
-- Continue if we haven't timed out
|
||||
local timeoutBonus = _M.currentFrame / 4
|
||||
if _M.timeout + timeoutBonus > 0 then
|
||||
if not fell and _M.timeout + timeoutBonus > 0 then
|
||||
return mainLoop(_M, genome)
|
||||
end
|
||||
|
||||
|
@ -643,7 +645,12 @@ local function mainLoop(_M, genome)
|
|||
|
||||
local distanceTraversed = getDistanceTraversed(_M.areaInfo) - _M.currentFrame / 2
|
||||
|
||||
local fitness = bananaCoinsFitness - bumpPenalty - hitPenalty + powerUpBonus + distanceTraversed + game.getJumpHeight() / 100
|
||||
local fitness = bananaCoinsFitness - bumpPenalty - hitPenalty + powerUpBonus + distanceTraversed
|
||||
|
||||
if fell then
|
||||
fitness = fitness / 10
|
||||
message(_M, "Fall penalty 1/10")
|
||||
end
|
||||
|
||||
local lives = game.getLives()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue