From 3f872c169ca4f99d2957738ef3cf50cc6d1d5a77 Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Thu, 6 May 2021 01:40:17 -0400 Subject: [PATCH] Severe punishment for falling --- game.lua | 9 +++++++++ runner.lua | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/game.lua b/game.lua index 014d6b0..f17fca4 100644 --- a/game.lua +++ b/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) diff --git a/runner.lua b/runner.lua index 4e66fbc..e322c18 100644 --- a/runner.lua +++ b/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()