summaryrefslogtreecommitdiffstats
path: root/ai/Node.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-05 15:57:58 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-05 15:57:58 +0000
commit0d2d8121cbb6a45180d88021fe2e5ac86b3532e3 (patch)
tree512385f11f6d152f76ac36c7950bfe75992291ff /ai/Node.cpp
parent21cb50c82f18b3a2ee1e77a7de11413ce45e6587 (diff)
downloadsigen-0d2d8121cbb6a45180d88021fe2e5ac86b3532e3.tar.gz
sigen-0d2d8121cbb6a45180d88021fe2e5ac86b3532e3.tar.xz
sigen-0d2d8121cbb6a45180d88021fe2e5ac86b3532e3.zip
Got rid of XML for INI format, in process of moving over; added /ai/Net.{h, cpp}
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@8 6ecfd1a5-f3ed-3746-8530-beee90d26b22
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);
}