Add files via upload

This commit is contained in:
mam91 2017-11-20 21:49:39 -06:00 committed by GitHub
parent 46428eecd2
commit f078b7babe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 99414 additions and 0 deletions

BIN
neat-mario/DP1.State Normal file

Binary file not shown.

7348
neat-mario/DP1.state.pool Normal file

File diff suppressed because it is too large Load diff

7288
neat-mario/backup.0 Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

39
neat-mario/config.lua Normal file
View file

@ -0,0 +1,39 @@
local _M = {}
_M.NeatConfig = {
Filename = "DP1.state",
Population = 300,
DeltaDisjoint = 2.0,
DeltaWeights = 0.4,
DeltaThreshold = 1.0,
StaleSpecies = 15,
MutateConnectionsChance = 0.25,
PerturbChance = 0.90,
CrossoverChance = 0.75,
LinkMutationChance = 2.0,
NodeMutationChance = 0.50,
BiasMutationChance = 0.40,
StepSize = 0.1,
DisableMutationChance = 0.4,
EnableMutationChance = 0.2,
TimeoutConstant = 20,
MaxNodes = 1000000,
}
_M.ButtonNames = {
"A",
"B",
"X",
"Y",
"Up",
"Down",
"Left",
"Right",
}
_M.BoxRadius = 6
_M.InputSize = (_M.BoxRadius*2+1)*(_M.BoxRadius*2+1)
_M.Running = false
return _M

96
neat-mario/game.lua Normal file
View file

@ -0,0 +1,96 @@
--Notes here
config = require "config"
local _M = {}
function _M.getPositions()
marioX = memory.read_s16_le(0x94)
marioY = memory.read_s16_le(0x96)
local layer1x = memory.read_s16_le(0x1A);
local layer1y = memory.read_s16_le(0x1C);
screenX = marioX-layer1x
screenY = marioY-layer1y
end
function _M.getTile(dx, dy)
x = math.floor((marioX+dx+8)/16)
y = math.floor((marioY+dy)/16)
return memory.readbyte(0x1C800 + math.floor(x/0x10)*0x1B0 + y*0x10 + x%0x10)
end
function _M.getSprites()
local sprites = {}
for slot=0,11 do
local status = memory.readbyte(0x14C8+slot)
if status ~= 0 then
spritex = memory.readbyte(0xE4+slot) + memory.readbyte(0x14E0+slot)*256
spritey = memory.readbyte(0xD8+slot) + memory.readbyte(0x14D4+slot)*256
sprites[#sprites+1] = {["x"]=spritex, ["y"]=spritey}
end
end
return sprites
end
function _M.getExtendedSprites()
local extended = {}
for slot=0,11 do
local number = memory.readbyte(0x170B+slot)
if number ~= 0 then
spritex = memory.readbyte(0x171F+slot) + memory.readbyte(0x1733+slot)*256
spritey = memory.readbyte(0x1715+slot) + memory.readbyte(0x1729+slot)*256
extended[#extended+1] = {["x"]=spritex, ["y"]=spritey}
end
end
return extended
end
function _M.getInputs()
_M.getPositions()
sprites = _M.getSprites()
extended = _M.getExtendedSprites()
local inputs = {}
for dy=-config.BoxRadius*16,config.BoxRadius*16,16 do
for dx=-config.BoxRadius*16,config.BoxRadius*16,16 do
inputs[#inputs+1] = 0
tile = _M.getTile(dx, dy)
if tile == 1 and marioY+dy < 0x1B0 then
inputs[#inputs] = 1
end
for i = 1,#sprites do
distx = math.abs(sprites[i]["x"] - (marioX+dx))
disty = math.abs(sprites[i]["y"] - (marioY+dy))
if distx <= 8 and disty <= 8 then
inputs[#inputs] = -1
end
end
for i = 1,#extended do
distx = math.abs(extended[i]["x"] - (marioX+dx))
disty = math.abs(extended[i]["y"] - (marioY+dy))
if distx < 8 and disty < 8 then
inputs[#inputs] = -1
end
end
end
end
return inputs
end
function _M.clearJoypad()
controller = {}
for b = 1,#config.ButtonNames do
controller["P1 " .. config.ButtonNames[b]] = false
end
joypad.set(controller)
end
return _M

1101
neat-mario/mario-neat.lua Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
--Notes here
local _M = {}
function _M.sigmoid(x)
return 2/(1+math.exp(-4.9*x))-1
end
return _M

7348
neat-mario/temp.pool Normal file

File diff suppressed because it is too large Load diff