-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcrAIg.lua
48 lines (35 loc) · 1.13 KB
/
crAIg.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package.path = package.path .. ";/Users/joecrozier/Development/crAIg/?.lua;/Users/joecrozier/Development/crAIg/runtime/;"
-- pretty = require "pl.pretty".dump
function pretty(str)
return str
end
--Initialize math.random()
math.randomseed(os.time())
math.random()
require("NEAT/newGeneration")
require("NEAT/models/Genome")
require("NEAT/mutateGenome")
require("NEAT/models/Species")
require("runtime/chooseOutputs")
require("runtime/marioCraig")
require("NEAT/util/deepFitnessCalculate")
require("runtime/persistence");
local crAIg = {}
crAIg.species = {}
crAIg.generation = 0
--Give crAIg a seed species
local seedSpecies = Species:new()
--Give crAIg a random genome
local randomGenome = Genome:new()
mutateAddSynapse(randomGenome)
table.insert(seedSpecies.genomes,randomGenome)
table.insert(crAIg.species,seedSpecies)
--Uncomment to load a previous iteration of crAIg
--crAIg = persistence.load("runtime/crAIgs/crAIg-saved-39.lua")
local numGenerations = 1000
for i=1,numGenerations do
newGeneration(crAIg)
--Save crAIg
local crAIgName = "runtime/crAIgs/crAIg-saved-"..crAIg.generation..".lua";
persistence.store(crAIgName, crAIg);
end