summaryrefslogtreecommitdiffstats
path: root/ai/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ai/Node.cpp')
-rw-r--r--ai/Node.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/ai/Node.cpp b/ai/Node.cpp
index a6702b09..c95d6eae 100644
--- a/ai/Node.cpp
+++ b/ai/Node.cpp
@@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
-// Name: Node.cpp
+// Name: ai/Node.cpp
// Purpose: A node in a Neural Network layer
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Sun Apr 15 16:56:23 2007
-// Copyright: ©2007 Ben Boeckel and Nerdy Productions
+// Copyright: ©2007 Nerdy Productions
// Licence:
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -36,6 +36,22 @@ PokeGen::NeuralNetwork::Node::Node(Layer *own, unsigned idx, double mom, double
function = func;
}
+void PokeGen::NeuralNetwork::Node::UpdateWeights(int n)
+{
+ if (n < 0)
+ {
+ weights.push_back((abs(std::rand())%201)/100.0);
+ weightChanges.push_back(0);
+ }
+ else if (n < ownerLayer->child->GetNumNodes())
+ {
+ weights.erase(weights.begin() + n);
+ weightChanges.erase(weightChanges.begin() + n);
+ }
+ else
+ return;
+}
+
void PokeGen::NeuralNetwork::Node::SetInput(double i)
{
input = i;
@@ -71,7 +87,7 @@ void PokeGen::NeuralNetwork::Node::RandomizeWeights()
weights.clear();
int i = 0;
for (; i < ownerLayer->child->GetNumNodes(); ++i)
- weights.push_back((abs(rand())%201)/100.0);
+ weights.push_back((abs(std::rand())%201)/100.0);
weightChanges.clear();
weightChanges.resize(i - 1, 0);
}