Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- math.randomseed(os.time())
- memory.usememorydomain("RAM")
- local Count = 0
- local CreatureCount = 0
- local Read1 = 0x006D
- local Read2 = 0x0086
- local Inputs = joypad.get(1)
- local Scores = {}
- local NSI = {}
- while Count < 99 do
- NSI[Count] = {}
- Count = Count + 1
- end
- Count = 0
- local Generation = 1
- local Genome = 0
- local ClnInputs = 0
- local Frame = 0
- savestate.load("SMB.state");
- while true do
- Count = (Generation - 1) * 10
- print(table.getn(NSI[3]))
- print((Generation * 10) - 1)
- while table.getn(NSI[3]) <= (Generation * 10) - 1 do
- if CreatureCount == 4 then
- break
- else
- NSI[CreatureCount][Count] = math.random(0, 255)
- Count = Count + 1
- if Count == (Generation * 10) then
- CreatureCount = CreatureCount + 1
- Count = (Generation - 1) * 10
- end
- end
- end
- Count = 0
- ClnInputs = NSI[Genome][Frame]
- if ClnInputs >= 128 then
- Inputs["P1 A"] = true
- ClnInputs = ClnInputs - 128
- else
- Inputs["P1 A"] = false
- end
- if ClnInputs >= 64 then
- Inputs["P1 B"] = true
- ClnInputs = ClnInputs - 64
- else
- Inputs["P1 B"] = false
- end
- if ClnInputs >= 32 then
- Inputs["P1 Select"] = true
- ClnInputs = ClnInputs - 32
- else
- Inputs["P1 Select"] = false
- end
- if ClnInputs >= 16 then
- Inputs["P1 Start"] = true
- ClnInputs = ClnInputs - 16
- else
- Inputs["P1 Start"] = false
- end
- if ClnInputs >= 8 then
- Inputs["P1 Up"] = true
- ClnInputs = ClnInputs - 8
- else
- Inputs["P1 Up"] = false
- end
- if ClnInputs >= 4 then
- Inputs["P1 Down"] = true
- ClnInputs = ClnInputs - 4
- else
- Inputs["P1 Down"] = false
- end
- if ClnInputs >= 2 then
- Inputs["P1 Left"] = true
- ClnInputs = ClnInputs - 2
- else
- Inputs["P1 Left"] = false
- end
- if ClnInputs >= 1 then
- Inputs["P1 Right"] = true
- ClnInputs = ClnInputs - 1
- else
- Inputs["P1 Right"] = false
- end
- joypad.set(Inputs);
- Frame = Frame + 1
- if Frame > (Generation * 10) - 1 then
- Frame = 0
- Scores[Genome] = (memory.readbyte(Read1) * 256) + memory.readbyte(Read2)
- Genome = Genome + 1
- savestate.load("SMB.state");
- end
- if Genome >= 4 then
- Genome = 0
- Generation = Generation + 1
- end
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement