⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 neuron.cs

📁 AI Life (Neural Networks, Genetic Algorithms, Steering Behaviours)
💻 CS
字号:
using System;

namespace AI_Life
{

	public class Neuron
	{

        //=========================================================//
		int numInputs;		// number of inputs
		double[] weights;	// array of weights

		public Neuron(int initNumInputs)
		{
			numInputs = initNumInputs + 1; // + 1 for bias
			weights = new double[numInputs];

			for (int i=0; i<numInputs; i++)
				weights[i] = ((float)(Cosmos.randomR.NextDouble()) * 2) - 1;

		}

		public double NumInputs
		{
            get
            {
                return numInputs;
            }
		}

		public void SetWeight(int index, double newVal)
		{
			weights[index] = newVal;
		}

		public double GetWeight(int index)
		{
			return weights[index];
		}
	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -