From f346531178bb5ba1b91dd6b6b2cbf99f7178c5ee Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Sat, 6 Mar 2021 09:52:51 -0500 Subject: [PATCH] Only count upwards motion for barrel launch --- README.md | 1 + game.lua | 6 ++++++ neat-donk.lua | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c8d4063..0c8a57a 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,4 @@ An AI based on SethBling's MarI/O to play Donkey Kong Country 2 with lsnes. * [SethBling's Mar I/O](https://github.com/mam91/neat-genetic-mario) * [Basic tilemap info from p4plus2/DKC2-disassembly](https://github.com/p4plus2/DKC2-disassembly) * [dkjson](http://dkolf.de/src/dkjson-lua.fsl/home) +* [LibDeflate](https://github.com/SafeteeWoW/LibDeflate) diff --git a/game.lua b/game.lua index 1309e23..6fbdaf8 100644 --- a/game.lua +++ b/game.lua @@ -71,11 +71,17 @@ end function _M.getVelocityY() local sprite = _M.getSprite(leader) + if sprite == nil then + return 1900 + end return sprite.velocityY end function _M.getVelocityX() local sprite = _M.getSprite(leader) + if sprite == nil then + return 1900 + end return sprite.velocityX end diff --git a/neat-donk.lua b/neat-donk.lua index d3ccb42..a5cd2a8 100644 --- a/neat-donk.lua +++ b/neat-donk.lua @@ -802,10 +802,10 @@ function mainLoop (species, genome) -- Don't punish being launched by barrels -- FIXME Will this skew mine cart levels? - if math.abs(game.getVelocityY()) > 0x1800 or math.abs(game.getVelocityX()) > 0x1800 then - statusLine = "Barrel launch!!!" + if game.getVelocityY() < -1850 then + statusLine = string.format("Gotta go fast!!! %d", partyX) statusColor = 0x0000ff00 - timeout = timeoutConst + timeout = timeoutConst + 60 * 2 end if not vertical then