nnlist1.cpp

来自「游戏编程精髓里的人工智能源代码很好的源代码!」· C++ 代码 · 共 88 行

CPP
88
字号
/* Copyright (C) Andre' LaMothe, 2000.  * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Andre' LaMothe, 2000" */// MCULLOCCH PITTS SIMULATOR /////////////////////////////////////////////////////// INCLUDES //////////////////////////////////////////////////////////////////////#ifdef _WIN32#include <conio.h>#include <io.h>#else#include <ctype.h>#endif#include <stdlib.h>#include <malloc.h>#include <memory.h>#include <string.h>#include <stdarg.h>#include <stdio.h>#include <math.h>#include <fcntl.h>// MAIN //////////////////////////////////////////////////////////////////////////void main(void){float	threshold,	// this is the theta term used to threshold the summation 		w1,w2,		// these hold the weights		x1,x2,		// inputs to the neurode				y_in,		// summed input activation		y_out;		// final output of neurode		printf("\nMcCulloch-Pitts Single Neurode Simulator.\n");printf("\nPlease Enter Threshold?");scanf("%f",&threshold);printf("\nEnter value for weight w1?");scanf("%f",&w1);printf("\nEnter value for weight w2?");scanf("%f",&w2);printf("\n\nBegining Simulation:");// enter main event loopwhile(1)	{	printf("\n\nSimulation Parms: threshold=%f, W=(%f,%f)\n",threshold,w1,w2);	// request inputs from user	printf("\nEnter input for X1?");	scanf("%f",&x1);	printf("\nEnter input for X2?");	scanf("%f",&x2);	// compute activation	y_in = x1*w1 + x2*w2;	// input result to activation function (simple binary step)	if (y_in>=threshold)		y_out = (float)1.0;	else		y_out = (float)0.0;	// print out result	printf("\nNeurode Output is %f\n",y_out);	// try again	printf("\nDo you wish to continue Y or N?");	char ans[8];	scanf("%s",ans);	if (toupper(ans[0])!='Y')		break;			} // end whileprintf("\n\nSimulation Complete.\n");} // end main

⌨️ 快捷键说明

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