<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yangbo&#039;s Blog!</title>
	<atom:link href="http://blog.lookbackon.com/?feed=rss2&#038;lang=zh-cn" rel="self" type="application/rss+xml" />
	<link>http://blog.lookbackon.com</link>
	<description>Artificial Intelligence Board Game.</description>
	<lastBuildDate>Fri, 23 Apr 2010 07:01:45 +0000</lastBuildDate>
	<language>zh-cn</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Bitboards</title>
		<link>http://blog.lookbackon.com/?p=371&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=371&amp;lang=zh-cn#comments</comments>
		<pubDate>Thu, 08 Apr 2010 16:51:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[BoardGame(民间棋类游戏)]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=371</guid>
		<description><![CDATA[Contents &#91; hide &#93; 1 and 2 xor 3 or 4 not 5 rotate 6 reverse AS3 BitBoard(based-on BitVector) preview: This is our ChineseChess as3 bitboard: [R][K][B][O][M][O][B][K][R] [0][0][0][0][0][0][0][0][0] [0][C][0][0][0][0][0][C][0] [P][0][P][0][P][0][P][0][P] [0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0] [p][0][p][0][p][0][p][0][p] [0][C][0][0][0][0][0][C][0] [0][0][0][0][0][0][0][0][0] [r][k][b][o][m][o][b][k][r] Operations: and public function and(value:BitBoard):BitBoard { var bb:BitBoard = new BitBoard(this.column,this.row); for(var h:int=0;h&#60;_row;h++) { for(var w:int=0;w&#60;_column;w++) { bb.setBitt(h,w, Boolean((value.getBitt(h,w)&#38;this.getBitt(h,w)))); [...]]]></description>
			<content:encoded><![CDATA[<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#and'>1 and</a></li>
<li><a href='#xor'>2 xor</a></li>
<li><a href='#or'>3 or</a></li>
<li><a href='#not'>4 not</a></li>
<li><a href='#rotate'>5 rotate</a></li>
<li><a href='#reverse'>6 reverse</a></li>
</ol>
</div>
<p>AS3 BitBoard(based-on BitVector) preview:<br />
This is our <a href="http://www.godpaper.com/godpaper/index.php?title=中国象棋">ChineseChess</a> as3 bitboard:<br />
        <strong>[R][K][B][O][M][O][B][K][R]</strong><br />
	<strong>[0][0][0][0][0][0][0][0][0]</strong><br />
	<strong>[0][C][0][0][0][0][0][C][0]</strong><br />
	<strong>[P][0][P][0][P][0][P][0][P]</strong><br />
	<strong>[0][0][0][0][0][0][0][0][0]</strong><br />
	<strong>[0][0][0][0][0][0][0][0][0]</strong><br />
	<strong>[p][0][p][0][p][0][p][0][p]</strong><br />
	<strong>[0][C][0][0][0][0][0][C][0]</strong><br />
	<strong>[0][0][0][0][0][0][0][0][0]</strong><br />
	<strong>[r][k][b][o][m][o][b][k][r]</strong><br />
<strong>Operations</strong>:<br />
<a name='and'></a><br />
<h2>and</h2>
<pre class="brush: as3;">
public function and(value:BitBoard):BitBoard
		{
			var bb:BitBoard =
new BitBoard(this.column,this.row);
			for(var h:int=0;h&lt;_row;h++)
			{
				for(var w:int=0;w&lt;_column;w++)
				{
					bb.setBitt(h,w,
Boolean((value.getBitt(h,w)&amp;this.getBitt(h,w))));
				}
			}
			return bb;
		}
</pre>
<p><a name='xor'></a><br />
<h2>xor</h2>
<pre class="brush: as3;">
public function xor(value:BitBoard):BitBoard
		{
			var bb:BitBoard =
new BitBoard(this.column,this.row);
			for(var h:int=0;h&lt;_row;h++)
			{
				for(var w:int=0;w&lt;_column;w++)
				{
					bb.setBitt(h,w,
Boolean((value.getBitt(h,w)^this.getBitt(h,w))));
				}
			}
			return bb;
		}
</pre>
<p><a name='or'></a><br />
<h2>or</h2>
<pre class="brush: as3;">
public function or(value:BitBoard):BitBoard
		{
			var bb:BitBoard =
new BitBoard(this.column,this.row);
			for(var h:int=0;h&lt;_row;h++)
			{
				for(var w:int=0;w&lt;_column;w++)
				{
					bb.setBitt(h,w,
Boolean((value.getBitt(h,w)|this.getBitt(h,w))));
				}
			}
			return bb;
		}
</pre>
<p><a name='not'></a><br />
<h2>not</h2>
<pre class="brush: as3;">
public function not():BitBoard
		{
			var bb:BitBoard =
new BitBoard(this.column,this.row);
			for(var h:int=0;h&lt;_row;h++)
			{
				for(var w:int=0;w&lt;_column;w++)
				{
					bb.setBitt(h,w,
!Boolean(this.getBitt(h,w)));
				}
			}
			return bb;
		}
</pre>
<p><a name='rotate'></a><br />
<h2>rotate</h2>
<pre class="brush: as3;">
public function rotate90():BitBoard
		{
			var bb:BitBoard =
new BitBoard(_row,_column);
			for(var w:int=0;w&lt;_row;w++)
			{
				for(var h:int=0;h&lt;_column;h++)
				{
					bb.setBitt(h,w,
Boolean(this.getBitt(w,h)));
				}
			}
			return bb;
		}
</pre>
<p><a name='reverse'></a><br />
<h2>reverse</h2>
<pre class="brush: as3;">
public function reverse():BitBoard
		{
			var bb:BitBoard =
new BitBoard(this.column,this.row);
			for(var w:int=0;w&lt;_column;w++)
			{
				for(var h:int=0;h&lt;_row;h++)
				{
					bb.setBitt(h,w,
Boolean(this.getBitt(_row-h-1,w)));
				}
			}
			return bb;
		}
</pre>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=371&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programming game AI(ArtificalNerualNetwork) by (as3)example</title>
		<link>http://blog.lookbackon.com/?p=347&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=347&amp;lang=zh-cn#comments</comments>
		<pubDate>Tue, 29 Dec 2009 05:29:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=347</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_match_all() expects parameter 2 to be string, array given in <b>/home/content/g/o/d/godpaper/html/blog/wp-content/plugins/wordpress-wiki/wordpress-wiki.php</b> on line <b>394</b><br />
<br />
<b>Warning</b>:  preg_match_all() expects parameter 2 to be string, array given in <b>/home/content/g/o/d/godpaper/html/blog/wp-content/plugins/wordpress-wiki/wordpress-wiki.php</b> on line <b>394</b><br />
Contents &#91; hide &#93; 1 Example: 2 Code snippet 3 Supply interpretation ArticicalNerualNetwork Example: First off,let's overview this simple as3-based ArticicalNerualNetwork : 1.Neruron; 2.Nerurons; 3.NerualNetwork; Next, Code snippet 1.Neruron; package { /** * A Neuron is the basic building block of a Neural Network * * @author Knight.zhou * */ public class Neuron { //-------------------------------------------------------------------------- [...]]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_match_all() expects parameter 2 to be string, array given in <b>/home/content/g/o/d/godpaper/html/blog/wp-content/plugins/wordpress-wiki/wordpress-wiki.php</b> on line <b>394</b><br />
<br />
<b>Warning</b>:  preg_match_all() expects parameter 2 to be string, array given in <b>/home/content/g/o/d/godpaper/html/blog/wp-content/plugins/wordpress-wiki/wordpress-wiki.php</b> on line <b>394</b><br />
<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#Example:'>1 Example:</a></li>
<li><a href='#Code snippet'>2 Code snippet</a></li>
<li><a href='#Supply interpretation'>3 Supply interpretation</a></li>
</ol>
</div>
<p><a href="http://blog.lookbackon.com/?page_id=316">ArticicalNerualNetwork</a> <img src='http://blog.lookbackon.com/wp-includes/images/smilies/icon_question.gif' alt=':?:' class='wp-smiley' /><br />
<a name='Example:'></a><br />
<h2>Example:</h2>
<p>First off,let's overview this simple as3-based <a href="http://blog.lookbackon.com/?page_id=316">ArticicalNerualNetwork</a> :<br />
1.Neruron;<br />
2.Nerurons;<br />
3.NerualNetwork;</p>
<p>Next,<br />
<a name='Code snippet'></a><br />
<h2>Code snippet</h2>
<p><strong>1.Neruron;</strong></p>
<pre class="brush: as3;">
package
{
	/**
	 * A Neuron is the basic building block of a Neural Network
	 *
	 * @author Knight.zhou
	 *
	 */
	public class Neuron
	{
//--------------------------------------------------------------------------
//
//  Constructor
//
//--------------------------------------------------------------------------
		public function Neuron(layer:int,index:int)
		{
			this.layer = layer;
			this.index = index;
		}
//--------------------------------------------------------------------------
//
//  Properties
//
//--------------------------------------------------------------------------
		//----------------------------------
		//  layer(native)
		//----------------------------------
		/// Internal storage for Neuron.Layer public property
		private var _layer:int;
		public function get layer():int
		{
			return _layer;
		}
		/// INPUT LAYER = 0, HIDDEN LAYER = 1, OUTPUT LAYER = 2
		public function set layer(value:int):void
		{
			_layer = value;
		}
		//----------------------------------
		//  index(native)
		//----------------------------------
		/// Internal storage for Neuron.Index public property
		private var _index:int;
		public function get index():int
		{
			return _index;
		}
		/// Identifies a Neuron or the position of a Neuron in a LAYER
		public function set index(value:int):void
		{
			_index = value;
		}
		//----------------------------------
		//  input(native)
		//----------------------------------
		/// Internal storage for Neuron.Input public property
		private var _input:int;
		public function get input():int
		{
			return _input;
		}
		/// Input data fed to the Neural Network
		public function set input(value:int):void
		{
			_input = value;
			if(this.layer==0)
			{
				this.output = this.input;
			}else
			{
				this.output = this.logisticFunction(this.input);
				//System.Diagnostics.Debug.WriteLine(&quot;Layer : &quot; + this.player + &quot; Input &quot; + this.pinput + &quot; Output &quot; + this.poutput);
			}
		}
		//----------------------------------
		//  output(native)
		//----------------------------------
		/// Internal storage for Neuron.Output public property
		private var _output:int;
		public function get output():int
		{
			return _output;
		}
		/// Calculated Ouput from the INPUT, HIDDEN or OUTPUT LAYER
		public function set output(value:int):void
		{
			_output = value;
		}
		//----------------------------------
		//  outputTraning(native)
		//----------------------------------
		/// Internal storage for Neutron.OutputTraining public property
		private var _outputTraning:int;
		public function get outputTraning():int
		{
			return _outputTraning;
		}
		/// Expected or Target or Learning output for a neutron
		/// in the OUPUT LAYER
		public function set outputTraning(value:int):void
		{
			_outputTraning = value;
		}
		//----------------------------------
		//  weight(native)
		//----------------------------------
		/// Internal storage for Network.Weight public property
		protected var _weight:Array=[];
		/// Storage for array of weights from OUTPUT to
		/// HIDDEN LAYER and from HIDDENLAYER TO INPUT
		/// LAYER. Each Neuron in the OUTPUT and HIDDEN
		/// LAYER is connected to an array of Neurons
		public function get weight():Array
		{
			return _weight;
		}
		//----------------------------------
		//  bias(native)
		//----------------------------------
		/// Internal storage for Network.Bias public property
		private var _bias:Number;
		public function get bias():Number
		{
			return _bias;
		}
		/// Varies the OUTPUT of a Neuronin a HIDDEN or OUTPUT LAYER
		public function set bias(value:Number):void
		{
			_bias = value;
		}
		//----------------------------------
		//  error(native)
		//----------------------------------
		/// Internal storage for Network.Error public property
		private var _error:Number;
		public function get error():Number
		{
			return _error;
		}
		/// Error = (ACTUALOUTPUT * (1 - ACTUALOUTPUT) * (EXPECTEDOUTPUT - ACTUALOUTPUT))
		public function set error(value:Number):void
		{
			_error = value;
		}
//--------------------------------------------------------------------------
//
//  Methods:
//
//--------------------------------------------------------------------------
		//----------------------------------
		//  logisticFunction(native)
		//----------------------------------
		/// Sigmoid Function or Logistic Function or Activation Function
		/// is applied to the INPUT to a NETWORK LAYER to get an OUTPUT
		/// The value to calculate a Sigmoid or Logistic Function for
		/// System.Double datatype of the Logistic or Sigmoid Function result
		public function logisticFunction(val:Number):Number
		{
			var tempExp:uint = Math.exp(-val);
			trace(&quot;tempExp:&quot;,tempExp);
			var logisticFunctionResult:Number = 1.0 / (1.0 + tempExp );
			trace(&quot;logisticFunctionResult:&quot;,logisticFunctionResult);
			return logisticFunctionResult;
		}
		//------------------------------------
		//  logisticFunctionDerivative(native)
		//------------------------------------
		/// Derivative of the Sigmoid Function or Logistic Function or Activation Function
		/// The value to calculate the derivative of the Sigmoid Function for
		/// System.Double datatype of the numeric result
		public function logisticFunctionDerivative(val:Number):Number
		{
			return val * (1 - val);
		}
	}
}
</pre>
<p><strong>2.Nerurons;</strong></p>
<pre class="brush: as3;">
package
{
	import mx.collections.ArrayCollection;

	/**
	 *A Neural Network Layer or collection of cells or neurons
	 *
	 * @author Knight.zhou
	 *
	 */
	public class Neurons extends ArrayCollection
	{
//--------------------------------------------------------------------------
//
//  Constructor
//
//--------------------------------------------------------------------------
		public function Neurons()
		{
		}
//--------------------------------------------------------------------------
//
//  Methods:
//
//--------------------------------------------------------------------------
		//----------------------------------
		//  add(native)
		//----------------------------------
		/// Adds a neuron to a Neural Network Layer or collection of cells
		/// The neuron to add to a Neural Network Layer
		public function add(newNeuron:Neuron):void
		{
			this.addItem(newNeuron);
		}
		//----------------------------------
		//  insert(native)
		//----------------------------------
		public function insert(index:int,newNeuron:Neuron):void
		{
			this.addItemAt(newNeuron,index);
		}

		/// ReadOnly indexer - retrieves the neuron at a
		/// specific position orlocation in the Neural
		/// Network Layer or Neural Network Collection
		//----------------------------------
		//  gett(native)
		//----------------------------------
		public function gett(index:int):Neuron
		{
			return this.getItemAt(index) as Neuron;
		}

	}
}
</pre>
<p><strong>3.NerualNetwork;</strong></p>
<pre class="brush: as3;">
package
{
	import mx.collections.ArrayCollection;

	public class NeuralNetWork
	{
//--------------------------------------------------------------------------
//
//  Variables
//
//--------------------------------------------------------------------------
		/// Static variable for random numbers
		static private var random:Number = 0.5;
		/// Static variable for number of neurons or cells in INPUT LAYER
		static private var input_count:int = 3;
		/// Static variable for number of neurons or cells in HIDDEN LAYER
		static private var hidden_count:int = 2;
		/// Static variable for number of neurons or cells in OUTPUT LAYER
		static private var output_count:int = 1;
		/// Static variable for the number of processing cycles of the Neural Network
		static public var iterations:int = 5;
		/// Represents the LEARNING RATE used in gradient descent to
		/// prevent weights from converging at sub-optimal solutions.
		public var learning_rate:Number = 0.8;
		/// A two dimensional array of input data from a training sample
		/// An INPUT represented as double [,] inputDataArray = new Double [,]
		/// {{0.20, 0.80}, {0.80, 0.4}} would represent 2 training instances
		/// for an INPUT LAYER with 2 NEURONS or CELLS
		public var input_data:ArrayCollection;
		/// A two dimensional array of output data from a training sample
		/// An OUTPUT represented as double [,] outputDataArray = new Double [,]
		/// {{0}, {1}} would represent 2 training instances
		/// for an OUTPUT LAYER with 1 NEURON or CELL
		public var output_data:ArrayCollection;
		/// A collection of neurons representing the input layer
		private var inputNeurons:Neurons;
		/// A collection of neurons representing the hidden layer
		private var hiddenNeurons:Neurons;
		/// A collection of neurons representing the output layer
		public var outputNeurons:Neurons;

//--------------------------------------------------------------------------
//
//  Constructor
//
//--------------------------------------------------------------------------
		public function NeuralNetWork()
		{
		}
//--------------------------------------------------------------------------
//
//  Properties
//
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//
//  Methods
//
//--------------------------------------------------------------------------
		/// Initializes the LAYERS in the NEURAL NETWORK
		/// INPUTS data for the NEURONS in the INPUT LAYER
		/// OUTPUT data for the NEURONS in the OUTPUT LAYER
		/// The number of neurons in the HIDDEN LAYER
		//----------------------------------
		//  initialize(native)
		//----------------------------------
		public function initialize(inputData:ArrayCollection,outputData:ArrayCollection,hidden_layer_count:int):void
		{
			this.input_data = inputData;
			input_count = (this.input_data.length+1);//

			hidden_count = hidden_layer_count;

			this.output_data = outputData;//
			output_count = this.output_data.length+1;

			inputNeurons = new Neurons();
			for(var i:int=0;i&lt;input_count;i++)
			{
				var a:Neuron = new Neuron(0,i);
				inputNeurons.add(a);
			}

			hiddenNeurons = new Neurons();
			for(var j:int=0;j&lt;hidden_count;j++)
			{
				var b:Neuron = new Neuron(1,j);
				hiddenNeurons.add(b);
			}

			outputNeurons = new Neurons();
			for(var k:int=0;k&lt;output_count;k++)
			{
				var c:Neuron = new Neuron(2,k);
				outputNeurons.add(c);
			}
		}
		//----------------------------------
		//  feedForward(native)
		//----------------------------------
		/// Initializes the NEURAL NETWORK with training data input
		/// or a real world data input for classification.
		/// FeedForward feeds the INPUT to the INPUT LAYER neurons
		/// FeedForward feeds the OUTPUT from the INPUT LAYER to the HIDDEN LAYER
		/// FeedForward feeds the OUTPUT from the HIDDEN LAYER to the OUTPUT LAYER
		/// FeedForward uses the Sigmoid Function or Logistic Function to calculate
		/// the OUTPUT from the INPUT in the HIDDEN and OUTPUT LAYERS

		/// A numeric ordered value representing the training or
		/// classification instance. If the dataset contains 10
		/// instances or rows, the first row has a sampleNumber = 0
		/// and the last row or instance has a sample number = 9
		public function feedForward(sampleNumer:int):void
		{
			var total:Number;
			var ch:Neuron = null;
			var ci:Neuron = null;
			var co:Neuron = null;
			//feed the input data to the input Neurons layer
			trace(&quot;input_data.length:&quot;,input_data.length);
			for(var i:int=0;i&lt;inputNeurons.length;i++)
			{
				ci = inputNeurons.gett(i);
				ci.input = this.input_data.getItemAt(sampleNumer)[i];
			}
			//feedforward from input to hidden Neurons
			for(var h:int=0;h&lt;hiddenNeurons.length;h++)
			{
				total = 0.0;
				ch = hiddenNeurons[h];
				for(var j:int=0;j&lt;inputNeurons.length;j++)
				{
					ci = inputNeurons[j];
					total += ci.output*ci.weight[j];
				}
				ch.input = total+ch.bias;
			}
			//feedforward from hidden to output Neurons
			for(var o:int=0;o&lt;outputNeurons.length;o++)
			{
				total = 0.0;
				co = outputNeurons.getItemAt(o) as Neuron;
				//feed the expected training result to the output Neurons layer
				co.outputTraning = this.output_data.getItemAt(sampleNumer)[o];
				for(var k:int=0;k&lt;hiddenNeurons.length;k++)
				{
					ch = hiddenNeurons[k];
					total += ch.output*co.weight[k];
				}
				co.input = total+co.bias;
			}
		}
		//----------------------------------
		//  backPropagate(native)
		//----------------------------------
		/// Recalculates the BIAS and ERROR in the HIDDEN LAYER
		/// and OUTPUT LAYER. Adjustes the WEIGHTS between the
		/// OUTPUT LAYER and HIDDEN LAYER and between the HIDDEN
		/// LAYER and the INPUT LAYER using the derivative of
		/// the Sigmoid Function or Logistic Function
		public function backPropagate():void
		{
			var total:Number;
			var ch:Neuron = null;
			var ci:Neuron = null;
			var co:Neuron = null;
			//calculate error rate for Output layer
			for(var o:int;o&lt;outputNeurons.length;o++)
			{
				co = outputNeurons[o];
				co.error = co.logisticFunctionDerivative(co.output)*(co.outputTraning-co.output);
			}
			//error from output to hidden layer
			for(var h:int=0;h&lt;hiddenNeurons.length;h++)
			{
				total = 0.0;
				ch = hiddenNeurons[h];
				for(var o:int;o&lt;outputNeurons.length;o++)
				{
					co = outputNeurons[o];
					total += co.error*co.weight[o];
				}
				ch.error = ch.logisticFunction(co.output)*total;
			}
			//update all weights in the network
			//from output Neurons to hidden Neurons
			for(var o:int=0;o&lt;outputNeurons.length;o++)
			{
				co = outputNeurons[o];
				for(var h:int=0;h&lt;hiddenNeurons.length;h++)
				{
					ch = hiddenNeurons[h];
					co.weight[h] += this.learning_rate*co.error*co.output;
				}
				co.bias += this.learning_rate*co.error;
			}
			//update all weights in the network
			//from hidden Neurons to input Neurons
			for(var h:int=0;h&lt;hiddenNeurons.length;h++)
			{
				ch = hiddenNeurons[h];
				for(var i:int=0;i&lt;inputNeurons.length;i++)
				{
					ci = inputNeurons[i];
					ch.weight[i] += this.learning_rate*ch.error*ci.output;
				}
				ch.bias += this.learning_rate*ch.error;
			}
		}
	}
}
internal class Random
{
	/// Generates random double values between -1.0 and +1.0
	/// System.Double data type between -1.0 and +1.0
	public static function gett(minLimit:Number=-1000,maxLimit:Number=1000):Number
	{
		return (Math.random()*(maxLimit-minLimit+1)+minLimit);
	}
}
</pre>
<p><a name='Supply interpretation'></a><br />
<h2>Supply interpretation</h2>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=347&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming game AI(Steering behaivor) by (as3)example</title>
		<link>http://blog.lookbackon.com/?p=322&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=322&amp;lang=zh-cn#comments</comments>
		<pubDate>Sun, 29 Nov 2009 12:18:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=322</guid>
		<description><![CDATA[Contents &#91; hide &#93; 1 Example: 2 Code snippet: 2.1 IVehicle; 2.2 ISteeringVehicle; 2.3 Behaviors; 3 Supplmentary interpretation 3.1 Arrival Steering behavior Example: First off,let's overview this simple as3-based Steering behavior System: 1.Vehicle; 2.Steering Vehicle; 3.Behaviors; Next,how to construct Steering Behavior using AS3? Code snippet: IVehicle; /** * The interface of vechicle type. * all [...]]]></description>
			<content:encoded><![CDATA[<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#Example:'>1 Example:</a></li>
<li><a href='#Code snippet:'>2 Code snippet:</a></li>
<li class='lvl2'><a href='#IVehicle;'>2.1 IVehicle;</a></li>
<li class='lvl2'><a href='#ISteeringVehicle;'>2.2 ISteeringVehicle;</a></li>
<li class='lvl2'><a href='#Behaviors;'>2.3 Behaviors;</a></li>
<li><a href='#Supplmentary interpretation'>3 Supplmentary interpretation</a></li>
<li class='lvl2'><a href='#Arrival'>3.1 Arrival</a></li>
</ol>
</div>
<p><a href="http://blog.lookbackon.com/?page_id=316">Steering behavior</a> <img src='http://blog.lookbackon.com/wp-includes/images/smilies/icon_question.gif' alt=':?:' class='wp-smiley' /><br />
<a name='Example:'></a><br />
<h2>Example:</h2>
<p>First off,let's overview this simple as3-based <a href="http://blog.lookbackon.com/?page_id=316">Steering behavior</a> System:<br />
1.Vehicle;<br />
2.Steering Vehicle;<br />
3.Behaviors;</p>
<p>Next,how to construct Steering Behavior using AS3?<br />
<a name='Code snippet:'></a><br />
<h2>Code snippet:</h2>
<p><a name='IVehicle;'></a><br />
<h3>IVehicle;</h3>
<pre class="brush: as3;">
/**
	 * The interface of vechicle type.
	 * all kinds of monster's type is vechicle.
	 *
	 * @author Knight.zhou
	 *
	 */
	public interface IVehicle
	{
		/**
		 * Sets / gets what will happen if character hits edge.
		 */
		function set edgeBehavior(value:String):void;
		function get edgeBehavior():String;
		/**
		 * Sets / gets mass of character.
		 */
		function set mass(value:Number):void;
		function get mass():Number;
		/**
		 * Sets / gets maximum speed of character.
		 */
		function set maxSpeed(value:Number):void;
		function get maxSpeed():Number;
		/**
		 * Sets / gets position of character as a Vector2D.
		 */
		function set position(value:Vector2D):void;
		function get position():Vector2D;
		/**
		 * Sets / gets velocity of character as a Vector2D.
		 */
		function set velocity(value:Vector2D):void;
		function get velocity():Vector2D;
		/**
		 * Sets x position of character. Overrides Sprite.x to set internal Vector2D position as well.
		 */
		function set x(value:Number):void
		/**
		 * Sets y position of character. Overrides Sprite.y to set internal Vector2D position as well.
		 */
		function set y(value:Number):void
		/**
		 * update vehicle 's properties.
		 */
		function update():void;
	}
</pre>
<p><a name='ISteeringVehicle;'></a><br />
<h3>ISteeringVehicle;</h3>
<pre class="brush: as3;">
/**
	 *
	 * @author Knight.zhou
	 *
	 */
	public interface ISteeredVehicle extends IVehicle
	{
		function set maxForce(value:Number):void;
		function get maxForce():Number;

		function set inSightDist(value:Number):void;
		function get inSightDist():Number;

		function set tooCloseDist(value:Number):void;
		function get tooCloseDist():Number;

		function inSight(vehicle:VehicleSample):Boolean;
		function tooClose(vehicle:VehicleSample):Boolean;
	}
</pre>
<p><a name='Behaviors;'></a><br />
<h3>Behaviors;</h3>
<p><strong>IArrive</strong></p>
<pre class="brush: as3;">
/**
	 *
	 * @author Knight.zhou
	 *
	 */
	public interface IArrive
	{
		function set arriveThreshold(value:Number):void;
		function get arriveThreshold():Number;

		function arrive(target:Vector2D):void;
	}
</pre>
<p><a name='Supplmentary interpretation'></a><br />
<h2>Supplmentary interpretation</h2>
<p><a name='Arrival'></a><br />
<h3>Arrival</h3>
<pre class="brush: as3;">
//----------------------------------
		//  arrive(implement IArrive)
		//----------------------------------
		/**
		 *
		 * @param target type is Vector2D
		 *
		 */
		private var _maxForce:Number = 100;
		private var _steeringForce:Vector2D = new Vector2D();
		public function arrive(target:Vector2D):void
		{
			var desiredVelocity:Vector2D = target.subtract(_position);
			desiredVelocity.normalize();

			var dist:Number = _position.dist(target);
			if(dist &gt; _arriveThreshold)
			{
				desiredVelocity = desiredVelocity.multiply(maxSpeed);
			}
			else
			{
				desiredVelocity = desiredVelocity.multiply(maxSpeed * dist / _arriveThreshold);
			}

			var force:Vector2D = desiredVelocity.subtract(_velocity);
			_steeringForce = _steeringForce.add(force);
		}
		//----------------------------------
		//  update(override)
		//----------------------------------
		override public function update():void
		{
			_steeringForce.truncate(_maxForce);
			_steeringForce = _steeringForce.divide(mass);
			velocity = velocity.add(_steeringForce);
			_steeringForce = new Vector2D();

			//Handles all basic motion. Should be called on each frame / timer interval.

			// make sure velocity stays within max speed.
			velocity.truncate(maxSpeed);

			// add velocity to position
			_position = _position.add(_velocity);

			// handle any edge behavior
			if(edgeBehavior == WRAP)
			{
				wrap();
			}
			else if(edgeBehavior == BOUNCE)
			{
				bounce();
			}

			// update position of sprite
			x = position.x;
			y = position.y;

			// rotate heading to match velocity
//			rotation = _velocity.angle * 180 / Math.PI;
		}
		//----------------------------------
		//  bounce(private)
		//----------------------------------
		/**
		 * Causes character to bounce off edge if edge is hit.
		 */
		private function bounce():void
		{
			if(stage != null)
			{
				if(position.x &gt; stage.stageWidth)
				{
					position.x = stage.stageWidth;
					velocity.x *= -1;
				}
				else if(position.x &lt; 0)
				{
					position.x = 0;
					velocity.x *= -1;
				}

				if(position.y &gt; stage.stageHeight)
				{
					position.y = stage.stageHeight;
					velocity.y *= -1;
				}
				else if(position.y &lt; 0)
				{
					position.y = 0;
					velocity.y *= -1;
				}
			}
		}
		//----------------------------------
		//  wrap(private)
		//----------------------------------
		/**
		 * Causes character to wrap around to opposite edge if edge is hit.
		 */
		private function wrap():void
		{
			if(stage != null)
			{
				if(position.x &gt; stage.stageWidth) position.x = 0;
				if(position.x &lt; 0) position.x = stage.stageWidth;
				if(position.y &gt; stage.stageHeight) position.y = 0;
				if(position.y &lt; 0) position.y = stage.stageHeight;
			}
		}
</pre>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=322&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programming game AI(FiniteStateMachine) by (as3)Example</title>
		<link>http://blog.lookbackon.com/?p=297&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=297&amp;lang=zh-cn#comments</comments>
		<pubDate>Tue, 24 Nov 2009 15:13:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=297</guid>
		<description><![CDATA[Contents &#91; hide &#93; 1 Example: 2 Code snippet: 2.1 IState; 2.2 IFiniteStateMachine 2.3 Agent; 3 Supplmentary interpretation 3.1 FiniteStateMachine 3.2 SadLow 3.3 Supple Interpretation Finite State Machine(FSM)??? Example: First off,let's overview this simple as3-based Finite State Machine System: 1.IState; 2.IFiniteStateMachine; 3.Agent; Next,how to construct Finite State Machine(FSM) using AS3? Code snippet: IState; /** * [...]]]></description>
			<content:encoded><![CDATA[<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#Example:'>1 Example:</a></li>
<li><a href='#Code snippet:'>2 Code snippet:</a></li>
<li class='lvl2'><a href='#IState;'>2.1 IState;</a></li>
<li class='lvl2'><a href='#IFiniteStateMachine'>2.2 IFiniteStateMachine</a></li>
<li class='lvl2'><a href='#Agent;'>2.3 Agent;</a></li>
<li><a href='#Supplmentary interpretation'>3 Supplmentary interpretation</a></li>
<li class='lvl2'><a href='#FiniteStateMachine'>3.1 FiniteStateMachine</a></li>
<li class='lvl2'><a href='#SadLow'>3.2 SadLow</a></li>
<li class='lvl2'><a href='#Supple Interpretation'>3.3 Supple Interpretation</a></li>
</ol>
</div>
<p><a href="http://blog.lookbackon.com/?page_id=301">Finite State Machine(FSM)???</a><br />
<a name='Example:'></a><br />
<h2>Example:</h2>
<p>First off,let's overview this simple as3-based <a href="http://blog.lookbackon.com/?page_id=301">Finite State Machine</a> System:<br />
1.IState;<br />
2.IFiniteStateMachine;<br />
3.Agent;</p>
<p>Next,how to construct Finite State Machine(FSM) using AS3?<br />
<a name='Code snippet:'></a><br />
<h2>Code snippet:</h2>
<p><a name='IState;'></a><br />
<h3>IState;</h3>
<pre class="brush: as3;">
/**
	 * Each state implements the IState interface.
	 * Each state implements enter and exit metheod
	 * for one-off action that the agent takes
	 * when entering and leaving the state,
	 * in addition to the update method
	 * which is run repeatedly while in the state.
	 * The time parameter in the update method
	 * is the duration of the frame we're excuting.
	 *
	 * @author Knight.zhou
	 *
	 */
	public interface IState
	{
		/**
		 *
		 * @param value is the description of monster's state.
		 *
		 */
		function set description(value:String):void;
		function get description():String;

		function enter():void;//called on entering the state
		function exit():void;//called on leaving the state
		function update(time:Number=0):void;//called every frame while in the state
	}
</pre>
<p><a name='IFiniteStateMachine'></a><br />
<h3>IFiniteStateMachine</h3>
<pre class="brush: as3;">
/**
     * Our FiniteStateMachine must implment this interface.
     *
     * @author Knight.zhou
     *
     */
    public interface IFiniteStateMachine
    {
        function set globalState(s:IState):void;
        function get globalState():IState;

        function set currentState(s:IState):void;
        function get currentState():IState;

        function set previousState(s:IState):void;
        function get previousState():IState;

        function set nextState(s:IState):void;
        function get nextState():IState;
    }
</pre>
<p><a name='Agent;'></a><br />
<h3>Agent;</h3>
<pre class="brush: as3;">
/**
	 * The agent uses an instance of the FiniteStateMachine class the handle its AI.
	 * The agent class is a lot more manageable without the FSM implementation
	 * and all the states inside it. and must have a single FSM class
	 * that can be used by all agents(who)can even share states across agents too.
	 *
	 * @author Knight.zhou
	 *
	 */
	public class Agent
	{
		private var fsm:FiniteStateMachine;
		public var name:String = &quot;unnamed&quot;;
		public var carrier:SWFLoader;
		public var traceTarget:TextArea;
		/**
		 *
		 * @param the name of agent;
		 * @param the carrier of agent;
		 * @param the agen's traceTarget;
		 *
		 */
		public function Agent(name:String,carrier:SWFLoader,traceTarget:TextArea=null)
		{
			fsm = new FiniteStateMachine(this);
			this.name = name;
			this.carrier = carrier;
			this.traceTarget = traceTarget;
		}

		public function update():void
		{
			fsm.update();
		}

		public function getFSM():FiniteStateMachine
		{
			return fsm;
		}
	}
</pre>
<p><a name='Supplmentary interpretation'></a><br />
<h2>Supplmentary interpretation</h2>
<p>Custom state class implement sample:<br />
<a name='FiniteStateMachine'></a><br />
<h3>FiniteStateMachine</h3>
<pre class="brush: as3;">
/**
	 * The FiniteStateMachine is responsible for
	 * managing the current state.
	 *
	 * Add a number of features to the FSM class to
	 * all chaining of states and returning to previous states.
	 *
	 * @author Knight.zhou
	 *
	 */
	public class FiniteStateMachine implements IFiniteStateMachine
	{
		private static const LOG:ILogger = LogUtil.getLogger(FiniteStateMachine);
	    private var _globalState:IState;//For globally track monster's state.
		private var _currentState:IState;
		private var _previousState:IState;
		private var _nextState:IState;
		protected var owner:Agent;

		public function FiniteStateMachine( owner:Agent,
		                                    currentState:IState=null,
		                                    previousState:IState=null,
		                                    nextState:IState=null
		                                  )
		{
		    this.owner = owner;
			this.currentState = currentState;
			this.previousState = previousState;
			this.nextState = nextState;
		}
		/**
         * Prepare a global state for globally tracking current state.
         *
         * @param s is anew state;
         *
         */
        public function set globalState( s:IState ):void
        {
            _globalState = s ;
        }
        public function get globalState():IState
        {
            return _globalState;
        }
        /**
         * Prepare a state for using the current state.
         *
         * @param s is anew state;
         *
         */
        public function set currentState( s:IState ):void
        {
            _currentState = s ;
        }
        public function get currentState():IState
        {
            return _currentState;
        }
		/**
		 * Prepare a state for use after the current state.
		 *
		 * @param s is anew state;
		 *
		 */
		public function set nextState( s:IState ):void
		{
			_nextState = s ;
		}
		public function get nextState():IState
        {
            return _nextState;
        }
		/**
         * Prepare a state for use before the current state.
         *
         * @param s is anew state;
         *
         */
        public function set previousState( s:IState ):void
        {
            _previousState = s ;
        }
        public function get previousState():IState
        {
            return _previousState;
        }
		/**
		 * Update the FSM.
		 */
		public function update():void
		{
			if(currentState)
			{
				currentState.update();
			}
		}
		/**
		 * Change to another state.
		 *
		 * @param s is anew state.
		 *
		 */
		public function changeState( s:IState ):void
		{
			LOG.info(&quot;exited:{0}&quot;,currentState);
			currentState.exit();
			previousState = currentState;
			globalState = s;
			currentState = s;
			currentState.enter();
			LOG.info(&quot;entered:{0}&quot;,currentState);
		}
		/**
		 * Go to the previous state.
		 */
		public function goToPreviousState():void
		{
			changeState( previousState );
		}
		/**
		 * Go to the next state.
		 */
		public function goToNextState():void
		{
			changeState( nextState );
		}
</pre>
<p><a name='SadLow'></a><br />
<h3>SadLow</h3>
<pre class="brush: as3;">
/**
	 * Monster's all kinds of talk states
	 *
	 * @author Knight.zhou
	 *
	 */
	public class SadLow implements IState
	{
		private var agent:Agent;
		//----------------------------------
		//  description(native)
		//----------------------------------
		private var _description:String = &quot;STATE_SAD_LOW&quot;;
		public function get description():String
		{
			return _description;
		}
		public function set description(value:String):void
		{
			_description = value;
		}
		public function SadLow(monster:Agent)
		{
			this.monster = monster;
		}

		public function enter():void
		{
			//TODO: implement function
		}

		public function exit():void
		{
			//TODO: implement function
		}

		public function update(time:Number=0):void
		{
                       //TODO: implement function
		}
	}
</pre>
<p><a name='Supple Interpretation'></a><br />
<h3>Supple Interpretation</h3>
<p><strong>XMLFiniteStateMachine</strong></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;fsm name=&quot;XML FiniteStateMachine&quot;&gt;
	&lt;states&gt;
		&lt;state name=&quot;stateName&quot;&gt;
			&lt;transition input=&quot;someInputValue&quot; trigger=&quot;triggerName&quot; source=&quot;head&quot; next=&quot;nextTransition&quot;/&gt;
		&lt;/state&gt;
       &lt;/states&gt;
&lt;/fsm&gt;
</pre>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=297&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming game AI(FuzzyLogic) by (as3)example</title>
		<link>http://blog.lookbackon.com/?p=282&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=282&amp;lang=zh-cn#comments</comments>
		<pubDate>Thu, 19 Nov 2009 13:06:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=282</guid>
		<description><![CDATA[Contents &#91; hide &#93; 1 Example: 1.1 Variable; 1.2 VariableValue; 1.3 MemberShipFunctions; 1.4 FuzzyRule; 1.5 FuzzySet; 1.6 FuzzySystem; 1.7 IFuzzyBasicComparisonRules 2 Code snippet: 2.1 1.Variable; 2.2 2.VariableValue; 2.3 3.MemberShipFunctions; 2.4 4.FuzzyRule; 2.5 5.FuzzySet; 2.6 6.FuzzySystem; 3 Supplmentary interpretation 3.1 TriangleMemberShipFunction 3.2 TrapezoidalMemberShipFunction 3.3 LeftShoulderMemberShipFunction 3.4 LeftShoulderFlip270MemberShipFunction 3.5 RightShoulderMemberShipFunction 3.6 RightShoulderFlip90MemberShipFunction 3.7 InverseTrapezoidalMemberShipFunction 3.8 InverseTrapezoidalFlip90MemberShipFunction Fuzzy [...]]]></description>
			<content:encoded><![CDATA[<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#Example:'>1 Example:</a></li>
<li class='lvl2'><a href='#Variable;'>1.1 Variable;</a></li>
<li class='lvl2'><a href='#VariableValue;'>1.2 VariableValue;</a></li>
<li class='lvl2'><a href='#MemberShipFunctions;'>1.3 MemberShipFunctions;</a></li>
<li class='lvl2'><a href='#FuzzyRule;'>1.4 FuzzyRule;</a></li>
<li class='lvl2'><a href='#FuzzySet;'>1.5 FuzzySet;</a></li>
<li class='lvl2'><a href='#FuzzySystem;'>1.6 FuzzySystem;</a></li>
<li class='lvl2'><a href='#IFuzzyBasicComparisonRules'>1.7 IFuzzyBasicComparisonRules</a></li>
<li><a href='#Code snippet:'>2 Code snippet:</a></li>
<li class='lvl2'><a href='#1.Variable;'>2.1 1.Variable;</a></li>
<li class='lvl2'><a href='#2.VariableValue;'>2.2 2.VariableValue;</a></li>
<li class='lvl2'><a href='#3.MemberShipFunctions;'>2.3 3.MemberShipFunctions;</a></li>
<li class='lvl2'><a href='#4.FuzzyRule;'>2.4 4.FuzzyRule;</a></li>
<li class='lvl2'><a href='#5.FuzzySet;'>2.5 5.FuzzySet;</a></li>
<li class='lvl2'><a href='#6.FuzzySystem;'>2.6 6.FuzzySystem;</a></li>
<li><a href='#Supplmentary interpretation'>3 Supplmentary interpretation</a></li>
<li class='lvl2'><a href='#TriangleMemberShipFunction'>3.1 TriangleMemberShipFunction</a></li>
<li class='lvl2'><a href='#TrapezoidalMemberShipFunction'>3.2 TrapezoidalMemberShipFunction</a></li>
<li class='lvl2'><a href='#LeftShoulderMemberShipFunction'>3.3 LeftShoulderMemberShipFunction</a></li>
<li class='lvl2'><a href='#LeftShoulderFlip270MemberShipFunction'>3.4 LeftShoulderFlip270MemberShipFunction</a></li>
<li class='lvl2'><a href='#RightShoulderMemberShipFunction'>3.5 RightShoulderMemberShipFunction</a></li>
<li class='lvl2'><a href='#RightShoulderFlip90MemberShipFunction'>3.6 RightShoulderFlip90MemberShipFunction</a></li>
<li class='lvl2'><a href='#InverseTrapezoidalMemberShipFunction'>3.7 InverseTrapezoidalMemberShipFunction</a></li>
<li class='lvl2'><a href='#InverseTrapezoidalFlip90MemberShipFunction'>3.8 InverseTrapezoidalFlip90MemberShipFunction</a></li>
</ol>
</div>
<p><a href="http://blog.lookbackon.com/?page_id=287&lang=zh-cn">Fuzzy Logic</a> <img src='http://blog.lookbackon.com/wp-includes/images/smilies/icon_question.gif' alt=':?:' class='wp-smiley' /><br />
<a name='Example:'></a><br />
<h2>Example:</h2>
<p>First off,let's overview this simple as3-based <a href="http://blog.lookbackon.com/?page_id=287&lang=zh-cn">Fuzzy Logic System:</a><br />
<a name='Variable;'></a><br />
<h3>Variable;</h3>
<p><a name='VariableValue;'></a><br />
<h3>VariableValue;</h3>
<p><a name='MemberShipFunctions;'></a><br />
<h3>MemberShipFunctions;</h3>
<p>1.Linear;<br />
2.Triangle;<br />
3.Trapezoidal;<br />
<a name='FuzzyRule;'></a><br />
<h3>FuzzyRule;</h3>
<p><a name='FuzzySet;'></a><br />
<h3>FuzzySet;</h3>
<p><a name='FuzzySystem;'></a><br />
<h3>FuzzySystem;</h3>
<p><a name='IFuzzyBasicComparisonRules'></a><br />
<h3>IFuzzyBasicComparisonRules</h3>
<p>Next,how to construct Fuzzy Logic System using AS3 <img src='http://blog.lookbackon.com/wp-includes/images/smilies/icon_question.gif' alt=':?:' class='wp-smiley' /><br />
<a name='Code snippet:'></a><br />
<h2>Code snippet:</h2>
<p><a name='1.Variable;'></a><br />
<h3>1.Variable;</h3>
<pre class="brush: as3;">
    /**
	 * Lingustic variables:
	 * these are simply variables whoes values are lingustic.
	 * e.g.:for the lingustic variable &quot;direction&quot; the possible values
	 * could be &quot;north&quot;,&quot;west&quot;,&quot;south&quot;,&quot;east&quot;.
	 *
	 * @author Knight.zhou
	 *
	 */
	public class Variable
	{
		protected var values:Array;
		public function Variable()
		{
			values = [];
		}

		public function addValue(value:VariableValue):void
		{
			values.push( value );
		}

		public function gett(index:String):VariableValue
		{
			for each( var value:VariableValue  in values)
			{
				if(value.value == index)
				{
					return value;
				}
			}
			return null;
		}
	}
</pre>
<p><a name='2.VariableValue;'></a><br />
<h3>2.VariableValue;</h3>
<pre class="brush: as3;">
    /**
	 * Define a linguistic value and has an IMemberShipFunction
	 * that define a MemberShip function for the sepcific value.
	 *
	 * @author Knight.zhou
	 *
	 */
	public class VariableValue
	{
		private var memberShip:IMemberShipFunction;
		private var _value:String;
		public function get value():String
		{
			return _value;
		}

		public function VariableValue(valueS:String,memberShip:IMemberShipFunction)
		{
			this._value = valueS;
			this.memberShip = memberShip;
		}

		public function memberShipOf(valueN:Number):Number
		{
			return memberShip.memberShipOf(valueN);
		}
	}
</pre>
<p><a name='3.MemberShipFunctions;'></a><br />
<h3>3.MemberShipFunctions;</h3>
<pre class="brush: as3;">
  /**
	 * Define an interface that let you create your own membership function for the VariableValue.
	 * These functions take a crisp value(angle or others)
	 * as a parameter and output a number between 0 and 1.
	 * Each lingustic value has an assoicated MemberShip function.
	 * The idea behind the MemberShip function is to define
	 * how much a crisp value is related to a specific lingustic value.
	 * The most common MemberShip functions are:
	 * Linear,
	 * Triangular,
	 * Tapezoidal(Left shoulder,right shoulder)
	 *
	 *
	 * @author Knight.zhou
	 *
	 */
	public interface IMemberShipFunction
	{
		function memberShipOf(value:Number):Number;
	}
</pre>
<p><a name='4.FuzzyRule;'></a><br />
<h3>4.FuzzyRule;</h3>
<pre class="brush: as3;">
import mx.logging.ILogger;

	/**
	 * Fuzzy rules are basically if&lt;condition&gt; then &lt;decision&gt;.
	 * The condition part is,for this example ,
	 * in form of &lt;linguistic variable 1&gt; = &lt;linguistic value 1&gt;
	 * AND &lt;linguistic variable 2&gt; = &lt;linguistic value 2&gt; AND...
	 * the decision part,in this Fuzzy system,
	 * is a assignment of a crisp value.
	 * e.g.: IF direction=north AND direction=west  THEN  turn:=-15°
	 * new FuzzyRule( 15, new Array( &quot;east&quot;, &quot;left&quot; ))
	 *
	 * @author Knight.zhou
	 *
	 */
	public class FuzzyRule
	{
		private static const LOG:ILogger = LogUtil.getLogger(FuzzyRule);
		private var ifValues:Array;
		private var crispResult:Number;
		private var vars:Array;

		public function FuzzyRule(crispResult:Number,ifValues:Array,vars:Array=null)
		{
			this.crispResult = crispResult;
			this.ifValues = ifValues;
			this.vars = vars;
		}

		public function addIfValue(value:String):void
		{
			ifValues.push( value );
		}

		public function getWeight(sets:Array):Number
		{
			var res:Number = 1;
			var i:Number = 0;
			for each(var ifValue:String in ifValues)
			{
				var fs:FuzzySet = sets[i] as FuzzySet;
//				LOG.debug(&quot;fs.getMemberShip({0}):{1}&quot;,ifValue,fs.getMemberShip(ifValue));
				res *= fs.getMemberShip(ifValue);
				i++;
			}
			return res;
		}

		public function get crispOutput():Number
		{
			return crispResult;
		}
</pre>
<p><a name='5.FuzzySet;'></a><br />
<h3>5.FuzzySet;</h3>
<pre class="brush: as3;">
	/**
	 * These are sets whose elements are all the possible linguistic
	 * value of a specific linguistic variable,each assoicated
	 * with a MemberShip function value of the same Crisp value.
	 * e.g.:the set defined by the direction linguistic variable
	 * and the crisp value 80° would be
	 * (direction, 80°) :== {(north, 0.9),(west,0),(south,0),(east,0.1)}
	 *
	 * @author Knight.zhou
	 *
	 */
	public class FuzzySet
	{
		private var variable:Variable;
		private var crispValue:Number;

		public function FuzzySet(variable:Variable,crispValue:Number)
		{
			this.variable = variable;
			this.crispValue = crispValue;
		}

		public function getMemberShip(value:String):Number
		{
			var variableValue:VariableValue = variable.gett(value);
			if(variableValue!=null)
			{
				return variableValue.memberShipOf(crispValue);
			}else
			{
				throw new Error(&quot;INVALID_FUZZY_LOGIC_VALUE!&quot;);
			}
			return -1;
		}

	}
</pre>
<p><a name='6.FuzzySystem;'></a><br />
<h3>6.FuzzySystem;</h3>
<pre class="brush: as3;">
/**
	 * This class lets you define a set of rules.
	 * all defining the same crisp variable and calculate
	 * the aggregated crisp output.
	 * e.g.:
	 * system.addRule(new FuzzyRule(15, new Array(  &quot;north&quot;, &quot;left&quot; ) ));
	 *
	 * @author Knight.zhou
	 *
	 */
	public class FuzzySystem
	{
		private var rules:Array;

		public function FuzzySystem()
		{
			rules  = [];
		}

		public function addRule(rule:FuzzyRule):void
		{
			rules.push( rule );
		}

		public function crispOutput(sets:Array):Number
		{
			var vals:Number=0.00;
			var weights:Number=0.00;
			for each(var rule:FuzzyRule in rules)
			{
				weights += rule.getWeight( sets );
				vals += rule.getWeight( sets )*rule.crispOutput;
			}
			return vals/weights;
		}
	}
</pre>
<p><a name='Supplmentary interpretation'></a><br />
<h2>Supplmentary interpretation</h2>
<p><a name='TriangleMemberShipFunction'></a><br />
<h3>TriangleMemberShipFunction</h3>
<pre class="brush: as3;">
   /**
     * For instance the &quot;north&quot; lingustic value could have
     * a Triangular membership function
     * with parameter a=0°, b=90° and c=180°.
     * This would mean that a 45° angle
     * would have a 0.5 Membership to the linguistic value &quot;north&quot;.
     *
	 * *******e.g.*****
	 *
	 *        a
	 *      /   \
	 *     b-----c
	 *
	 * *****e.g.********
	 *
	 * @author Knight.zhou
	 *
	 */
	public class TriangleMemberShipFunction implements IMemberShipFunction
	{
		/*private var a:Number;
		private var b:Number;
		private var c:Number;*/

		/*public function TriangleMemberShipFunction(a:Number,b:Number,c:Number)
		{
			this.a = a;
			this.b = b;
			this.c = c;
		}

		public function memberShipOf(value:Number):Number
		{
			if ((a &lt; value) &amp;&amp; (value &lt;= b))
				return (value - a) / (b - a);
			if ((b &lt; value) &amp;&amp; (value &lt; c))
				return (c - value) / (c - b);
			return 0;
		}*/

		private var leftOffset:Number;
		private var rightOffset:Number;
		private var peakPoint:Number;

		public function TriangleMemberShipFunction(leftOffset:Number,b:Number,rightOffset:Number)
		{
			this.leftOffset = leftOffset;
			this.peakPoint = peakPoint;
			this.rightOffset = rightOffset;
		}

		public function memberShipOf(value:Number):Number
		{
			//check leftOffset or rightOffset equal to 0;
			if ( ((this.leftOffset==0) &amp;&amp; (value == this.peakPoint))
				||((this.rightOffset==0) &amp;&amp; (value == this.peakPoint))
				)
			{
				return 1.0;
			}
			//check less than peakpoint;
			if( (value&lt;=this.peakPoint) &amp;&amp; (value&gt;=(this.peakPoint-this.leftOffset)) )
			{
				var gradLeft:Number = 1.0/this.leftOffset;
				return gradLeft *(value-(this.peakPoint-this.leftOffset));
			}
			//check more than peakpoint;
			else if( (value&gt;this.peakPoint) &amp;&amp; (value&lt;(this.peakPoint+this.rightOffset)))
			{
				var gradRight:Number = 1.0/-this.rightOffset;
				return gradRight*(value-this.peakPoint)+1.0;
			}
			//others
			else
			{
				return 0;
			}
			return 0;
		}
	}
</pre>
<p><a name='TrapezoidalMemberShipFunction'></a><br />
<h3>TrapezoidalMemberShipFunction</h3>
<pre class="brush: as3;">
     /**
	 * Trapezoidal member ship function.
	 *
	 * *****e.g.*******
	 *
	 *     b------c
	 *    /        \
	 *  a-----------d
	 *
	 * *****e.g.*******
	 *
	 * @author Knight.zhou
	 *
	 */
	public class TrapezoidalMemberShipFunction implements IMemberShipFunction
	{
		private var a:Number;
		private var b:Number;
		private var c:Number;
		private var d:Number;

		public function TrapezoidalMemberShipFunction(a:Number,b:Number,c:Number,d:Number)
		{
			this.a = a;
			this.b = b;
			this.c = c;
			this.d = d;
		}

		public function memberShipOf(value:Number):Number
		{
			var result:Number=0;

			if( ((a==b)&amp;&amp;(value==a))
				|| ((c==d)&amp;&amp;(value==c))
			)
			{
				result = 1.0;
			}
			if( value&gt;=a &amp;&amp; value&lt;b)
			{
				result = (b - value) / (b - a);
			}
			else if(value&gt;=b &amp;&amp; value&lt;c)
			{
				result = 1.0;
			}else if(value&gt;=c &amp;&amp; value&lt;d)
			{
				result = (value - c) / (d - c);
			}
			//			LOG.debug(&quot;current value:{0}||result:{1}&quot;,value.toString(),result.toString());
			return result;
		}
	}
</pre>
<p><a name='LeftShoulderMemberShipFunction'></a><br />
<h3>LeftShoulderMemberShipFunction</h3>
<pre class="brush: as3;">
     /**
         * Left shoulder member ship functions
         *
	 *******e.g.*******
	 *
	 * -------a
	 *                \
	 * 			b
	 *
	 *******e.g.*******
	 *
         * @author Knight.zhou
         *
         */
    public class LeftShoulderMemberShipFunction implements IMemberShipFunction
    {
        private var peakPoint:Number;
        private var leftOffset:Number;
        private var rightOffset:Number;
        private var midPoint:Number;

        public function LeftShoulderMemberShipFunction(leftOffset:Number,peakPoint:Number,rightOffset:Number)
        {
            this.peakPoint = peakPoint;
            this.leftOffset = leftOffset;
            this.rightOffset = rightOffset;
//            this.midPoint = (leftOffset+rightOffset)/2;
			this.midPoint = peakPoint-leftOffset/2;
        }

        public function memberShipOf(value:Number):Number
        {
            //check offset equal 0;
            if( (this.rightOffset==0) &amp;&amp; (value==this.peakPoint)
				||(this.leftOffset==0) &amp;&amp; (value==this.peakPoint)
			  )
            {
                return 1.0;
            }
            //check value more than peak
            if( (value&gt;=this.peakPoint) &amp;&amp; (value&lt;=(this.peakPoint+this.rightOffset)) )
            {
                var grad:Number = -(1.0/this.rightOffset);
                return grad * (value-this.peakPoint)+1.0;
            }
            //check value less than peak
            else if( (value&lt;this.peakPoint) &amp;&amp; (value&gt;(this.peakPoint-this.leftOffset)))
            {
                return 1.0;
            }
            return 0;
        }

    }
</pre>
<p><a name='LeftShoulderFlip270MemberShipFunction'></a><br />
<h3>LeftShoulderFlip270MemberShipFunction</h3>
<pre class="brush: as3;">
     /**
         * Left shoulder flip 270 degree member ship functions
         *
	 *******e.g.*******
	 *
	 * a----b
	 * |      |
	 * |      d
	 * |  *
	 * c
	 *
	 *******e.g.*******
	 *
         * @author Knight.zhou
         *
         */
    public class LeftShoulderFlip270MemberShipFunction implements IMemberShipFunction
    {
        private var peakPoint:Number;
        private var upOffset:Number;
        private var downOffset:Number;

        public function LeftShoulderFlip270MemberShipFunction(upOffset:Number,peakPoint:Number,downOffset:Number)
        {
            this.peakPoint = peakPoint;
            this.upOffset = upOffset;
            this.downOffset = downOffset;
        }

        public function memberShipOf(value:Number):Number
        {
            //check offset equal 0;
            if( (this.downOffset==0) &amp;&amp; (value==this.peakPoint)
				||(this.upOffset==0) &amp;&amp; (value==this.peakPoint)
			  )
            {
                return 1.0;
            }
            //check value more than peak
            if( (value&gt;=this.peakPoint) &amp;&amp; (value&lt;=(this.peakPoint+this.upOffset)) )
            {
				return 1.0;
            }
            //check value less than peak
            else if( (value&lt;this.peakPoint) &amp;&amp; (value&gt;(this.peakPoint-this.downOffset)))
            {
				var grad:Number = -(1.0/this.downOffset);
				return grad * (value-this.peakPoint)+1.0;
            }
            return 0;
        }

    }
</pre>
<p><a name='RightShoulderMemberShipFunction'></a><br />
<h3>RightShoulderMemberShipFunction</h3>
<pre class="brush: as3;">
/**
     * Right shoulder member ship functions
     *
	 * *******e.g.*****
	 *
	 *    a------
	 *   /
	 *  b
	 *
	 *******e.g.*******
	 *
     * @author Knight.zhou
     *
     */
    public class RightShoulderMemberShipFunction implements IMemberShipFunction
    {
		private static const LOG:ILogger = LogUtil.getLogger(RightShoulderMemberShipFunction);
        private var peakPoint:Number;
        private var leftOffset:Number;
        private var rightOffset:Number;
        private var midPoint:Number;

        public function RightShoulderMemberShipFunction(leftOffset:Number,peakPoint:Number,rightOffset:Number)
        {
            this.peakPoint = peakPoint;
            this.leftOffset = leftOffset;
            this.rightOffset = rightOffset;
//            this.midPoint = (leftOffset+rightOffset)/2;
			this.midPoint = peakPoint+rightOffset/2;
        }

        public function memberShipOf(value:Number):Number
        {
            //check offset equal 0;
            if( (this.leftOffset==0) &amp;&amp; (value==this.midPoint) ||
				(this.rightOffset==0) &amp;&amp; (value==this.midPoint)
			  )
            {
                return 1.0;
            }
            //check value less than peak
            if( (value&lt;=this.peakPoint) &amp;&amp; (value&gt;=(this.peakPoint-this.leftOffset)) )
            {
//				LOG.debug(&quot;current value:{0}||this.peakPoint-this.leftOffset:{1}&quot;,value,(this.peakPoint-this.leftOffset));
                var grad:Number = 1.0/this.leftOffset;
                return grad * (value-(this.peakPoint-this.leftOffset));
            }
            //check value more than peak
            else if( (value&gt;this.peakPoint) &amp;&amp; (value&lt;=this.peakPoint+this.rightOffset) )
            {
                return 1.0;
            }
            return 0;
        }

    }
</pre>
<p><a name='RightShoulderFlip90MemberShipFunction'></a><br />
<h3>RightShoulderFlip90MemberShipFunction</h3>
<pre class="brush: as3;">
/**
     * Right shoulder flip 90 degress member ship functions
     *
	 *******e.g.*******
	 *
	 * b
	 * |   *
	 * |       d
	 * |       |
	 * a-----d
	 *
	 *******e.g.*******
	 *
     * @author Knight.zhou
     *
     */
    public class RightShoulderFlip90MemberShipFunction implements IMemberShipFunction
    {
        private var peakPoint:Number;
        private var upOffset:Number;
        private var downOffset:Number;

        public function RightShoulderFlip90MemberShipFunction(upOffset:Number,peakPoint:Number,downOffset:Number)
        {
            this.peakPoint = peakPoint;
            this.upOffset = upOffset;
            this.downOffset = downOffset;
        }

        public function memberShipOf(value:Number):Number
        {
            //check offset equal 0;
            if( (this.downOffset==0) &amp;&amp; (value==this.peakPoint)
				||(this.upOffset==0) &amp;&amp; (value==this.peakPoint)
			  )
            {
                return 1.0;
            }
            //check value more than peak
            if( (value&gt;this.peakPoint) &amp;&amp; (value&lt;=(this.peakPoint+this.upOffset)) )
            {
                var grad:Number = 1.0/this.upOffset;
                return grad * (value-this.peakPoint);
            }
            //check value less than peak
            else if( (value&lt;=this.peakPoint) &amp;&amp; (value&gt;(this.peakPoint-this.downOffset)))
            {
                return 1.0;
            }
            return 0;
        }

    }
</pre>
<p><a name='InverseTrapezoidalMemberShipFunction'></a><br />
<h3>InverseTrapezoidalMemberShipFunction</h3>
<pre class="brush: as3;">
/**
	 * Inverse trapezoidal member ship function.
	 *
	 * ******e.g.*******
	 *
	 *  a-----------d
	 *    \            /
	 *     b------c
	 *
	 * *****e.g.********
	 *
	 * @author Knight.zhou
	 *
	 */
	public class InverseTrapezoidalMemberShipFunction implements IMemberShipFunction
	{
		private static const LOG:ILogger = LogUtil.getLogger(InverseTrapezoidalMemberShipFunction);
		private var a:Number;
		private var b:Number;
		private var c:Number;
		private var d:Number;

		public function InverseTrapezoidalMemberShipFunction(a:Number,b:Number,c:Number,d:Number)
		{
			this.a = a;
			this.b = b;
			this.c = c;
			this.d = d;
		}

		public function memberShipOf(value:Number):Number
		{
			var result:Number=0;

			if( ((a==b)&amp;&amp;(value==a))
				|| ((c==d)&amp;&amp;(value==c))
			)
			{
				result = 1.0;
			}
			if( value&gt;=a &amp;&amp; value&lt;b)
			{
				result = (b - value) / (b - a);
			}
			else if(value&gt;=b &amp;&amp; value&lt;=c)
			{
				result = 1.0;
			}else if(value&gt;c &amp;&amp; value&lt;=d)
			{
				result = (value - c) / (d - c);
			}else
			{
			    result = 0.0;
			}
//			LOG.debug(&quot;current value:{0}||result:{1}&quot;,value.toString(),result.toString());
			return result;
		}
	}
</pre>
<p><a name='InverseTrapezoidalFlip90MemberShipFunction'></a><br />
<h3>InverseTrapezoidalFlip90MemberShipFunction</h3>
<pre class="brush: as3;">
/**
	 * Inverse trapezoidal member ship function.
	 *
	 * ******e.g.*******
	 *
	 *     b
	 *    /|
	 *  /  |
	 * a   |
	 * |   |
	 * |   |
	 * c   |
	 *   \ |
	 *    \|
	 *     d
	 *
	 * *****e.g.********
	 *
	 * @author Knight.zhou
	 *
	 */
	public class InverseTrapezoidalFlip90MemberShipFunction implements IMemberShipFunction
	{
		private static const LOG:ILogger = LogUtil.getLogger(InverseTrapezoidalMemberShipFunction);
		private var a:Number;
		private var b:Number;
		private var c:Number;
		private var d:Number;

		public function InverseTrapezoidalFlip90MemberShipFunction(a:Number,b:Number,c:Number,d:Number)
		{
			this.a = a;
			this.b = b;
			this.c = c;
			this.d = d;
		}

		public function memberShipOf(value:Number):Number
		{
			var result:Number=0;

			if( ((a==b)&amp;&amp;(value==a))
				|| ((c==d)&amp;&amp;(value==c))
			)
			{
				result = 1.0;
			}
			if( value&gt;a &amp;&amp; value&lt;=b)
			{
				result = (b - value) / (b - a);
			}
			else if(value&gt;c &amp;&amp; value&lt;=a)
			{
				result = 1.0;
			}else if(value&gt;d &amp;&amp; value&lt;=c)
			{
				result = (value - d) / (c - d);
			}else
			{
			    result = 0;
			}
//			LOG.debug(&quot;current value:{0}||result:{1}&quot;,value.toString(),result.toString());
			return result;
		}
	}
</pre>
<p>p.s:<br />
Defuzzation using IFuzzyBasicComparisonRules:</p>
<pre class="brush: as3;">
/**
	 * The IFuzzyBasicComparisonRulses interface works on the idea
	 * that it can be inherited by any object that we wish to implement to.
	 * The reason to use an interface is because at this moment in time
	 * we don't know what class the interface is going to be used
	 * in nor if the rules for the comparisons is even going to be used
	 * between objects that are of the same type.
	 * I think I should make it specifically clear at this point
	 * that what the interface implements is not the rule itself,
	 * because at this very low level of dealing with a simple number,
	 * it would involve too much twisting logic into the class to make it work.
	 * The idea being that at some point a class would use the FuzzyDouble class
	 * and deal with the Fuzzy Double depending on the rules set within the object.
	 * So at this point, we are merely setting the rules that the type
	 * is supposed to adhere to.
	 *
	 * @author knight.zhou
	 *
	 * @see http://www.codeproject.com/KB/recipes/fuzzylogicvadaline.aspx
	 */
	public interface IFuzzyBasicComparisonRules
	{
		function isGreaterThan(value:Number):Number;

		function isLessThan(value:Number):Number;

		function isEqual(value:Number):Number;
	}
</pre>
<p>Application demo(with reference diagram):<br />
<a href="http://www.lookbackon.com/lab/FuzzyLogicSystem/bin-release/FuzzyLogicSystem.swf">http://www.lookbackon.com/lab/FuzzyLogicSystem/bin-release/FuzzyLogicSystem.swf</a><br />
<a href="http://www.lookbackon.com/lab/FuzzyLogicSystem/bin-release/srcview/index.html">View Source:</a></p>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=282&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programming game AI(Evaluation) by (as3)example</title>
		<link>http://blog.lookbackon.com/?p=278&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=278&amp;lang=zh-cn#comments</comments>
		<pubDate>Wed, 14 Oct 2009 02:58:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=278</guid>
		<description><![CDATA[References: http://www.ics.uci.edu/~eppstein/180a/990114.html http://www.elephantbase.net/computer/evalue_intro1.htm http://www.elephantbase.net/computer/evalue_intro2.htm]]></description>
			<content:encoded><![CDATA[<h2>References:</h2>
<p><a href="http://www.ics.uci.edu/~eppstein/180a/990114.html">http://www.ics.uci.edu/~eppstein/180a/990114.html</a><br />
<a href="http://www.elephantbase.net/computer/evalue_intro1.htm">http://www.elephantbase.net/computer/evalue_intro1.htm</a><br />
<a href="http://www.elephantbase.net/computer/evalue_intro2.htm">http://www.elephantbase.net/computer/evalue_intro2.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=278&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming game AI(Search) by (as3)example</title>
		<link>http://blog.lookbackon.com/?p=271&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=271&amp;lang=zh-cn#comments</comments>
		<pubDate>Wed, 14 Oct 2009 02:40:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=271</guid>
		<description><![CDATA[一般认为，问题求解就是通过搜索寻找问题求解操作的以个合适的序列，以满足问题的要求。问题求解方法可分为两大类：非层次的(nohierarchical)和层次的（hierarchical）。非层次方法寻找问题的解；层次方法则是把整个问题分解为较为容易解决的子问题，子问题还可以继续分解，整个问题的解由子问题的解组成。 状态空间搜索 下面首先介绍搜索方法，再介绍一些常用的问题求解方法。 搜索方法也称控制策略，控制策略内容可分两部分：一个是选择合适的操作；一个是记住已施行的操作序列及它们所产生的状态描述。控制策略对应的多种搜索方式： 不可撤回方法 试探性方法 层次方法 回朔策略 图搜索策略 任意路径的图搜索 最佳路径的图搜索 与或图的搜索 博弈树搜索 MinMax AlphaBeta 约束满足搜索 约束满足问题(constriant satisfaction problem,简称CSP)就是为一组变量寻找满足约束的赋值。 通用问题求解]]></description>
			<content:encoded><![CDATA[<p>一般认为，问题求解就是通过搜索寻找问题求解操作的以个合适的序列，以满足问题的要求。问题求解方法可分为两大类：非层次的(nohierarchical)和层次的（hierarchical）。非层次方法寻找问题的解；层次方法则是把整个问题分解为较为容易解决的子问题，子问题还可以继续分解，整个问题的解由子问题的解组成。</p>
<h2>状态空间搜索</h2>
<p>下面首先介绍搜索方法，再介绍一些常用的问题求解方法。<br />
搜索方法也称控制策略，控制策略内容可分两部分：一个是选择合适的操作；一个是记住已施行的操作序列及它们所产生的状态描述。控制策略对应的多种搜索方式：<br />
<strong>不可撤回方法</strong><br />
<strong>试探性方法</strong><br />
<strong>层次方法</strong></p>
<h3>回朔策略</h3>
<h3>图搜索策略</h3>
<h3>任意路径的图搜索</h3>
<h3>最佳路径的图搜索</h3>
<h3>与或图的搜索</h3>
<h2>博弈树搜索</h2>
<h3>MinMax</h3>
<h3>AlphaBeta</h3>
<h2>约束满足搜索</h2>
<p>约束满足问题(constriant satisfaction problem,简称CSP)就是为一组变量寻找满足约束的赋值。</p>
<h2>通用问题求解</h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=271&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming game AI(Learning) by (as3)Example</title>
		<link>http://blog.lookbackon.com/?p=267&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=267&amp;lang=zh-cn#comments</comments>
		<pubDate>Wed, 14 Oct 2009 02:17:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=267</guid>
		<description><![CDATA[正如人类有各种各样的学习方法一样，机器学习也有很多方法。根据机器学习所采用的学习策略、知识表示方法及其应用领域，可以把机器学习方法划分为8类，下面加以列举： 机械学习(rote learning) 存储组织 信息的适应性问题 存储与推导计算之间的权衡 通过采纳建议学习(learning by advictaking) 请求 解释 实用化 并入 评价 通过例子学习(learning from example) 通过类比学习(learning by analogy) 基于解释的学习(explanation-based learning) 通过观察学习(learning from observation and discovery) 连接学习(connectionist learning) 遗传算法(genetic algorithm)]]></description>
			<content:encoded><![CDATA[<p>正如人类有各种各样的学习方法一样，机器学习也有很多方法。根据机器学习所采用的学习策略、知识表示方法及其应用领域，可以把机器学习方法划分为8类，下面加以列举：</p>
<h2>机械学习(rote learning)</h2>
<h3>存储组织</h3>
<h3>信息的适应性问题</h3>
<h3>存储与推导计算之间的权衡</h3>
<h2>通过采纳建议学习(learning by advictaking)</h2>
<h3>请求</h3>
<h3>解释</h3>
<h3>实用化</h3>
<h3>并入</h3>
<h3>评价</h3>
<h2>通过例子学习(learning from example)</h2>
<h2>通过类比学习(learning by analogy)</h2>
<h2>基于解释的学习(explanation-based learning)</h2>
<h2>通过观察学习(learning from observation and discovery)</h2>
<h2>连接学习(connectionist learning)</h2>
<h2>遗传算法(genetic algorithm)</h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=267&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming game AI(Knowledge) by (as3)Example</title>
		<link>http://blog.lookbackon.com/?p=260&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=260&amp;lang=zh-cn#comments</comments>
		<pubDate>Wed, 14 Oct 2009 01:59:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=260</guid>
		<description><![CDATA[知识获取的基本过程： 明确问题的性质，建立问题求解模型。 确定知识表示形式，建立问题求解的基本框架。 实现知识库，简历原型专家系统。 测试于精炼知识库。 知识获取的主要手段： 面谈法(interview) 模拟法(simulation) 模拟法可分为静态模拟(static simulation)和动态模拟(dynamic simulation)。 口语记录分析(protocal analysis)]]></description>
			<content:encoded><![CDATA[<h2>知识获取的基本过程：</h2>
<h3>明确问题的性质，建立问题求解模型。</h3>
<h3>确定知识表示形式，建立问题求解的基本框架。</h3>
<h3>实现知识库，简历原型专家系统。</h3>
<h3>测试于精炼知识库。</h3>
<h2>知识获取的主要手段：</h2>
<h3>面谈法(interview)</h3>
<h3>模拟法(simulation)</h3>
<p>模拟法可分为静态模拟(static simulation)和动态模拟(dynamic simulation)。</p>
<h3>口语记录分析(protocal analysis)</h3>
]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=260&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The2Tigers(二虎棋)</title>
		<link>http://blog.lookbackon.com/?p=142&amp;lang=zh-cn</link>
		<comments>http://blog.lookbackon.com/?p=142&amp;lang=zh-cn#comments</comments>
		<pubDate>Mon, 24 Aug 2009 16:22:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[BoardGame(民间棋类游戏)]]></category>
		<category><![CDATA[Flex/AS3/Flash]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[Degrafa]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.lookbackon.com/?p=142</guid>
		<description><![CDATA[Contents &#91; hide &#93; 1 Example: 2 Code snippet 3 Supplmentary interpretation Example: Code snippet Supplmentary interpretation Thinking... Fuzzy logic, whenever is safty,wherever is dangerous? This page is wiki editable click here to edit this page.]]></description>
			<content:encoded><![CDATA[<div class='contents'>
<h3>Contents</h3>
<p> &#91; <a class='show' onclick='toggle_hide_show(this)'>hide</a> &#93; </p>
<ol class='content_list'>
<li><a href='#Example:'>1 Example:</a></li>
<li><a href='#Code snippet'>2 Code snippet</a></li>
<li><a href='#Supplmentary interpretation'>3 Supplmentary interpretation</a></li>
</ol>
</div>
<p><a name='Example:'></a><br />
<h2>Example:</h2>
<p>
		<span class="flash">
		<object width="100%" height="630">
			<param name="movie" value="http://www.lookbackon.com/lab/Game/The2Tigers/Main.swf"></param>
			<param name="allowFullScreen" value="true"></param>
			<param name="allowscriptaccess" value="always"></param>
			<embed src="http://www.lookbackon.com/lab/Game/The2Tigers/Main.swf" type="application/x-shockwave-flash"allowscriptaccess="always" allowfullscreen="true" width="100%" height="630"></embed>
		</object>
		</span>
		<br />
<a name='Code snippet'></a><br />
<h2>Code snippet</h2>
<p><a name='Supplmentary interpretation'></a><br />
<h2>Supplmentary interpretation</h2>
<p>Thinking...<br />
<a href = 'http://blog.lookbackon.com/wp-admin/post-new.php' >Fuzzy logic</a>, whenever is safty,wherever is dangerous?</p>
This page is wiki editable click <a href='http://blog.lookbackon.com/wp-login.php?redirect_to=http://blog.lookbackon.com/?feed=rss2&lang=zh-cn'> here</a> to edit this page.]]></content:encoded>
			<wfw:commentRss>http://blog.lookbackon.com/?feed=rss2&amp;p=142&amp;lang=zh-cn</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
