-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
76 lines (54 loc) · 1.78 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
DNA = require("dna")
Brain = require("brain")
Neurone = require("neuron")
function love.load(arg)
if arg[#arg] == "-debug" then require("mobdebug").start() end
local dna = DNA.new()
dna:addNode("input", 0, "linear")
dna:addNode("input", 0, "linear")
dna:addNode("output", 0, "linear")
dna:addNode("hidden", 0, "linear")
dna:addNode("hidden", 0, "linear")
dna:addConnection(1, 4, 1)
dna:addConnection(1, 3, 2)
dna:addConnection(2, 4, 2)
dna:addConnection(4, 3, 1)
dna:addConnection(5, 3, 1)
--print(dna:string())
local brain = Brain.new(dna)
print(brain:process({3, 4})[1])
--print(brain:string())
end
function love.update(dt)
end
function love.draw()
end
local a = {true, false}
function love.keypressed(key)
if key == "space" then
--[[local nDna = DNA.new()
nDna:addNode("input", 0, "linear")
nDna:addNode("input", 0, "linear")
nDna:addNode("input", 0, "linear")
nDna:addNode("output", 0, "step")
nDna:addNode("output", 0, "step")
nDna:addNode("output", 0, "step")
nDna:generate(3, 3)
local nBrain = Brain.new(nDna)
print(nBrain:string())
print("\n")
print(unpack(nBrain:process({250, 0, 12})))]]
a = Neurone.new(1, Neurone.activationFunctions.linear)
b = Neurone.new(2, Neurone.activationFunctions.linear)
c = Neurone.new(3, Neurone.activationFunctions.linear)
d = Neurone.new(4, Neurone.activationFunctions.linear)
e = Neurone.new(5, Neurone.activationFunctions.linear)
f = Neurone.new(6, Neurone.activationFunctions.linear)
a:connect(c)
c:connect(f)
c:connect(d)
d:connect(e)
b:connect(e)
print(detectLoop(a, b))
end
end