Add fitness when goal barrel moves

This commit is contained in:
Empathic Qubit 2021-03-08 04:57:32 -05:00
parent 3814061f47
commit 4c11f9e3ce
3 changed files with 30 additions and 6 deletions

View file

@ -1,6 +1,10 @@
local base = string.gsub(@@LUA_SCRIPT_FILENAME@@, "(.*/)(.*)", "%1")
util = dofile(base.."/util.lua")
local util = dofile(base.."/util.lua")
local spritelist = dofile(base.."/spritelist.lua")
spritelist.InitSpriteList()
spritelist.InitExtSpriteList()
FG_COLOR = 0x00ffffff
BG_COLOR = 0x99000000
@ -281,7 +285,12 @@ Stage (movement): %04x
local sprcolor = BG_COLOR
if detailsidx == idx then
sprcolor = 0x00ff0000
elseif spritelist.Sprites[sprite.control] == -1 then
sprcolor = 0x66990000
elseif spritelist.Sprites[sprite.control] == 1 then
sprcolor = 0x66009900
end
gui.text(sprite.screenX * 2, sprite.screenY * 2, string.format("%04x, %04x, %04x", sprite.control, sprite.animnum, sprite.attr), FG_COLOR, sprcolor)
local filename = os.getenv("HOME").."/neat-donk/catchem/"..sprite.animnum..","..sprite.attr..".png"

View file

@ -59,6 +59,23 @@ function _M.getKremCoins()
return krem
end
function _M.getGoalHit()
local sprites = _M.getSprites()
for i=1,#sprites,1 do
local sprite = sprites[i]
if sprite.control ~= 0x0164 then
goto continue
end
-- Check if the goal barrel is moving up
if sprite.velocityY < 0 then
return true
end
::continue::
end
return false
end
function _M.getKong()
local kong = memory.readword(KONG_LETTERS)
return bit.popcount(kong)

View file

@ -989,13 +989,11 @@ function mainLoop (species, genome)
print("ExtraLiveBonus added " .. ExtraLiveBonus)
end
-- FIXME sus
--[[
if rightmost > 4816 then
if game.getGoalHit() then
fitness = fitness + 1000
print("!!!!!!Beat level!!!!!!!")
statusLine = string.format("LEVEL WON! Fitness: %d", fitness)
statusColor = 0x0000ff00
end
-- ]]
if fitness == 0 then
fitness = -1
end