KONG letters. Damage.
This commit is contained in:
parent
a00100de98
commit
2751f90884
2 changed files with 27 additions and 22 deletions
19
game.lua
19
game.lua
|
@ -18,6 +18,9 @@ CAMERA_Y = 0x7e17c0
|
|||
PARTY_X = 0x7e0a2a
|
||||
PARTY_Y = 0x7e0a2c
|
||||
SOLID_LESS_THAN = 0x7e00a0
|
||||
KONG_LETTERS = 0x7e0902
|
||||
MATH_LIVES = 0x7e08be
|
||||
DISPLAY_LIVES = 0x7e0c0
|
||||
|
||||
function _M.getPositions()
|
||||
tilePtr = memory.readhword(TILEDATA_POINTER)
|
||||
|
@ -42,6 +45,11 @@ function _M.getCoins()
|
|||
return coins
|
||||
end
|
||||
|
||||
function _M.getKong()
|
||||
local kong = memory.readword(KONG_LETTERS)
|
||||
return bit.popcount(kong)
|
||||
end
|
||||
|
||||
function _M.getLives()
|
||||
local lives = memory.readsbyte(0x7e08be) + 1
|
||||
return lives
|
||||
|
@ -52,9 +60,9 @@ function _M.writeLives(lives)
|
|||
memory.writebyte(0x7e08c0, lives - 1)
|
||||
end
|
||||
|
||||
function _M.getPowerup()
|
||||
function _M.getBoth()
|
||||
-- FIXME consider invincibility barrels
|
||||
return memory.readword(HAVE_BOTH)
|
||||
return bit.band(memory.readword(HAVE_BOTH), 0x40)
|
||||
end
|
||||
|
||||
function _M.writePowerup(powerup)
|
||||
|
@ -64,11 +72,12 @@ end
|
|||
|
||||
|
||||
function _M.getHit(alreadyHit)
|
||||
return not alreadyHit and memory.readbyte(0x7e08be) < memory.readbyte(0x7e08c0)
|
||||
return not alreadyHit and memory.readword(MATH_LIVES) < memory.readword(DISPLAY_LIVES)
|
||||
end
|
||||
|
||||
function _M.getHitTimer()
|
||||
return memory.readbyte(0x7e08c0) - memory.readbyte(0x7e08be)
|
||||
function _M.getHitTimer(lastBoth)
|
||||
return (memory.readword(DISPLAY_LIVES) - memory.readword(MATH_LIVES))
|
||||
+ lastBoth - _M.getBoth()
|
||||
end
|
||||
|
||||
-- Logic from 0xb5c3e1, 0xb5c414, 0xb5c82c
|
||||
|
|
|
@ -8,6 +8,7 @@ game = dofile(base.."/game.lua")
|
|||
mathFunctions = dofile(base.."/mathFunctions.lua")
|
||||
util = dofile(base.."/util.lua")
|
||||
|
||||
kong = 0
|
||||
form = nil
|
||||
netPicture = nil
|
||||
runInitialized = {}
|
||||
|
@ -663,10 +664,9 @@ function on_timer()
|
|||
startBananas = game.getBananas()
|
||||
startCoins = game.getCoins()
|
||||
startLives = game.getLives()
|
||||
checkPartyCollision = true
|
||||
partyHitCounter = 0
|
||||
powerUpCounter = 0
|
||||
powerUpBefore = game.getPowerup()
|
||||
powerUpBefore = game.getBoth()
|
||||
local species = pool.species[pool.currentSpecies]
|
||||
local genome = species.genomes[pool.currentGenome]
|
||||
generateNetwork(genome)
|
||||
|
@ -793,21 +793,14 @@ function mainLoop (species, genome)
|
|||
-- FIXME Measure distance to target / area exit
|
||||
-- We might not always be horizontal
|
||||
|
||||
local hitTimer = game.getHitTimer()
|
||||
local hitTimer = game.getHitTimer(powerUpBefore)
|
||||
|
||||
if checkPartyCollision == true then
|
||||
if hitTimer > 0 then
|
||||
partyHitCounter = partyHitCounter + 1
|
||||
--print("party took damage, hit counter: " .. partyHitCounter)
|
||||
checkPartyCollision = false
|
||||
end
|
||||
if hitTimer > 0 then
|
||||
partyHitCounter = partyHitCounter + 1
|
||||
--print("party took damage, hit counter: " .. partyHitCounter)
|
||||
end
|
||||
|
||||
if hitTimer == 0 then
|
||||
checkPartyCollision = true
|
||||
end
|
||||
|
||||
powerUp = game.getPowerup()
|
||||
powerUp = game.getBoth()
|
||||
if powerUp > 0 then
|
||||
if powerUp ~= powerUpBefore then
|
||||
powerUpCounter = powerUpCounter+1
|
||||
|
@ -815,6 +808,8 @@ function mainLoop (species, genome)
|
|||
end
|
||||
end
|
||||
|
||||
kong = game.getKong()
|
||||
|
||||
local lives = game.getLives()
|
||||
|
||||
timeout = timeout - 1
|
||||
|
@ -825,11 +820,11 @@ function mainLoop (species, genome)
|
|||
local bananas = game.getBananas() - startBananas
|
||||
local coins = game.getCoins() - startCoins
|
||||
|
||||
print("Bananas: " .. bananas .. " coins: " .. coins)
|
||||
print(string.format("Bananas: %d, coins: %d, KONG: %d", bananas, coins, kong))
|
||||
|
||||
local bananaCoinsFitness = (bananas * 50) + (coins * 0.2)
|
||||
local bananaCoinsFitness = (kong * 60) + (bananas * 50) + (coins * 0.2)
|
||||
if (bananas + coins) > 0 then
|
||||
print("Bananas and Coins added " .. bananaCoinsFitness .. " fitness")
|
||||
print("Bananas, Coins, KONG added " .. bananaCoinsFitness .. " fitness")
|
||||
end
|
||||
|
||||
local hitPenalty = partyHitCounter * 100
|
||||
|
@ -1237,6 +1232,7 @@ function displayForm()
|
|||
gui.text(130, 30, "Max: " .. math.floor(pool.maxFitness))
|
||||
--gui.text(330, 5, "Measured: " .. math.floor(measured/total*100) .. "%")
|
||||
gui.text(5, 65, "Bananas: " .. (game.getBananas() - startBananas))
|
||||
gui.text(5, 85, "KONG: " .. kong)
|
||||
gui.text(130, 65, "Coins: " .. (game.getCoins() - startCoins))
|
||||
gui.text(130, 80, "Lives: " .. game.getLives())
|
||||
gui.text(230, 65, "Damage: " .. partyHitCounter)
|
||||
|
|
Loading…
Add table
Reference in a new issue