<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF
	xmlns="http://purl.org/rss/1.0/"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel rdf:about="http://feeds.garagegames.com/rss/blogs/developer/64841/">
		<title>Blog for Carpenter Software at GarageGames.com</title>
		<description>Blog feeds for Gamers and Developers in the GarageGames community.</description>
		<link>http://www.garagegames.com/</link>
		<image rdf:resource="http://www.garagegames.com/images/GarageGames_logo_small_w.gif" />
		<dc:date>2008-11-21T10:18:08+00:00</dc:date>
		<items>
			<rdf:Seq>
				<rdf:li rdf:resource="http://www.garagegames.com/blogs/64841/15009"/>
				<rdf:li rdf:resource="http://www.garagegames.com/blogs/64841/14232"/>
			</rdf:Seq>
		</items>
	</channel>
	<item rdf:about="http://www.garagegames.com/blogs/64841/15009">
		<dc:format>text/html</dc:format>
		<dc:date>2008-07-03T20:41:13+00:00</dc:date>
		<dc:creator>Carpenter Software</dc:creator>
		<title>Basic Polygon Texturing in Maya</title>
		<link>http://www.garagegames.com/blogs/64841/15009</link>
		<description>This was a little project I did for art school that involved polygon texturing a geometry in Autodesk Maya using Adobe Photoshop. &lt;br&gt;&lt;br&gt;The following URL should open a PDF file &lt;a href='http://www.carpentersoftware.com/images/PolygonTexturingPlan.pdf' target=_blank&gt;Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;To further demonstrate the shading and texturing, here is an animation I completed in Art School. &lt;a href='http://www.youtube.com/watch?v=bU-vHsZnZws' target=_blank&gt;Click Here&lt;/a&gt;. There are several polygon textures applied by using the method above except that the images were created by other methods but still using Maya and Photoshop to set up the UVs.&lt;br&gt;&lt;br&gt;Carpenter Software</description>
	</item>
	<item rdf:about="http://www.garagegames.com/blogs/64841/14232">
		<dc:format>text/html</dc:format>
		<dc:date>2008-02-01T01:00:21+00:00</dc:date>
		<dc:creator>Carpenter Software</dc:creator>
		<title>A Simple Finite State Machine (FSM) in Torquescript</title>
		<link>http://www.garagegames.com/blogs/64841/14232</link>
		<description>&lt;b&gt;Simple Finite State Machine using Multiple Objects&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;br&gt;The basic or simple finite state machine (FSM) is very useful in games.  Programmers seem to give life to game objects  with artificial intelligence (AI) embedded in the operating states of the FSM. On the internet and in many AI books, one can find information as to what a finite state machine is and how it works. There are many ways to write or code a FSM. Those who study game AI or academic AI, are familiar with the FSM. In a nutshell, FSM is an abstract pattern that acts as a machine that operates in one of several (two or more) predefined states and transitions from one state to another based on the transitioning rules.&lt;br&gt;&lt;br&gt;&lt;b&gt;The Search&lt;/b&gt;&lt;br&gt;To my surprise, there was no FSM written in torquescript. At least, not one I could find here at GG. So I wanted a working FSM in my code written in torquescript to help give intelligent life to my characters, but more importantly, to have more control over how the characters behave. So I wrote a simple finite state machine written in torquescript. It began with a GG forum thread at Torque Game Builder (TGB)&amp;gt;&amp;gt;Behaviors called Another Try.  There David House started the thread introducing his behavior where he used Data Blocks for his states, and the event system for his state machine. His video at YouTube showed that the object's behavior with intelligence &lt;a href='http://www.youtube.com/watch?v=nG64IBhC9tw' target=_blank&gt;Click Here to see Movie&lt;/a&gt;. I began to work on a finite state machine.  I finished it using torquescript. &lt;br&gt;&lt;br&gt;&lt;b&gt;The FSM&lt;/b&gt;&lt;br&gt;Although I am still using TGB 1.1.3, the FSM worked as expected. I also used the t2dSceneObjectDatablock as did David House above. In the datablock, I place static members and methods for states with embedded rules via their static methods (but these members and methods must be consistent with other states. Then I used t2dSceneObject to place all dynamic members and methods that match the static variables but also placed additional variables in this base object. Since all other objects are a subclass of t2dSceneObject nearly all objects may use this paradigm. To make the state machine operate, I used several commands. To switch datablocks, I used setConfigDatablock(%config), an t2dSceneObject function. To call the dynamic methods, I used &amp;quot;call(%function, [%args = &amp;quot;&amp;quot;])&amp;quot;, a console function. Lastly to cycle the state machine, I used schedule(%time, %refObject, %command, %args), another console function. &lt;br&gt;&lt;br&gt;&lt;b&gt;The Design&lt;/b&gt;&lt;br&gt;The next idea is to work on a torque scripted example with a single FSM to handle 10+ objects. This AI example will be using the fish data in a food chain scenario. One big fish, two medium fishes and eight small fishes looking for food. I am presently working on 4 states: EvadeState, ChaseState, RestState and RoamState. Where the first priority starting with EvadeState and the last priority with RoamState. Some of the fishes will not use all states, for example, the big fish may not evade and the small fishes may not chase. Almost at the end of the thread Another Try, Jussi Laasonen quoted &amp;quot;You could add some realism to your fishes by adding flocking behaviour so that smaller fishes would stick together while roaming and scatter when predator is near.&amp;quot; Although tempted even before the advice, I decided just to use simple chase and evade routines for the entire project so that I could focus on the FSM. On the fight routine, I also used the chase routine. Maybe Jussi can add the flocking behavior as a latter demonstration.&lt;br&gt;&lt;br&gt;&lt;b&gt;Dynamic Fields&lt;/b&gt;&lt;br&gt;Since I am using TGB, I will be using its editor. Already I have a small setback in assigning the states. Instead of using dataBlacks like in the above FSM example, I'll use the Dynamic Fields in the editor to place the states into the Dynamic Field called loopingState (it is now called &amp;quot;currentState&amp;quot;). So each fish will have a dynamic field called currentState initiated with the loopingRoamState (or it may be initiated with any looping-NAME-State) which is a static method that the FSM calls by the console function call(%method, %this). I am testing only one assignment at this time but maybe later there will also be an enterNAMEState and an exitNAMEState. The NAME here could mean Roam, Chase or Evade. Now I have two accessor functions: getState() and setState(). The setState function replaced the setConfigDatablock(%config) function.... Therefore the FSM uses one dynamic field for its states. In the Accessor Function setState() is the assignment for the dynamic field currentState:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;// Set Transition State (%state argument) in Dynamic Field&lt;br&gt;%this.currentState = &amp;quot;looping&amp;quot; @ %state;&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;About the same time as I started on the FSM, Phillip Oshea shared his FSM with us on the thread Another Try. His code on his animation manager showed clearly that he also used dynamic fields in his routines. Thanks for sharing your code Phillip.&lt;br&gt;&lt;br&gt;&lt;b&gt;State Transition Table&lt;/b&gt;&lt;br&gt;I want to use multiple class objects and multiple states (at least 4 states). The hard part as I am learning is setting up the states. So far I threw out code the was rubbish. I started to use a state table to layout the current states, the conditions and the state transitions. (Method taken from &amp;quot;Programming Game AI by Example&amp;quot; by Mat Buckland, p47). I am using a State Transition Table as a guide. Imagine trying to code multiple objects without it. &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;Current State.............Conditions..........State Transitions&lt;br&gt;-------------------------------------------------------------------&lt;br&gt;RoamState.................isHungry...............HuntState&lt;br&gt;RoamState.................isThreaten.............EvadeState (DoEvade)&lt;br&gt;HuntState.................foundPrey..............ChaseState (DoChase)&lt;br&gt;HuntState.................isThreaten.............EvadeState (DoEvade)&lt;br&gt;ChaseState................caughtPrey.............RoamState&lt;br&gt;ChaseState................lostPrey...............RoamState&lt;br&gt;EvadeState................isSafe.................RoamState&lt;br&gt;-------------------------------------------------------------------&lt;br&gt;&lt;i&gt;Still Deciding to Use:&lt;/i&gt;&lt;br&gt;EvadeState................isDead.................(spawn) RoamState&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;If there are a finite number of states, there cannot be a number of conditions greater than the number of states minus one. If there are four states, then there cannot be more than 3 conditions per state. I think that the HuntState above is more a chain-rule than a state-rule. Maybe the current state roam can also jump straight into a ChaseState depending the kind of AI effect. As in Phillip's FSM, he has two states, therefore a maximum of one condition per state. Either the avatar is moving or it is not. I noticed also that his state machine has an enter and an execute calls that operate on his states where I am presently using one similar to his execute call. Later I may add an enter and an exit call as well. I am surprised how big the State Transition Table may become when working with multiple objects.... All I did for an entire week was WORK on the table until it was logical. (Made sense). &lt;b&gt;See an Updated State Transition Table at the end of this Blog.&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Improved FSM&lt;/b&gt;&lt;br&gt;While working on the different state routines, I realized that it would be nice to have the enter and exit calls for the FSM. So for completeness, I finished the FSM with an enter and exit calls and some improvements. Although this code is an abstract pattern, it is still a simple FSM. Not bad for torquescript... The enter and exit states are NOT saved to dynamic fields because they are only used once in the same accessor function; whereas, the currentState is constantly looping in the FSM. I wanted the FSM slimmed down for performance reasons. Also I should mention that the FSM model was taken from &amp;quot;Programming Game AI by Example&amp;quot; by Mat Buckland. But the problem was how to convert it from c++ to torquescript.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;// FINITE STATE MACHINE&lt;br&gt;// Carpenter Software&lt;br&gt;&lt;br&gt;// Accessor Function getState()&lt;br&gt;function getState(%this)&lt;br&gt;{&lt;br&gt;	// All Objects have a dynamic field&lt;br&gt;	// called currentState (previously called loopingState) &lt;br&gt;	// that is ONLY assigned the VALUE prefix looping + the suffix&lt;br&gt;	// that is the name of Some State &amp;quot;NameState&amp;quot;.&lt;br&gt;	// Note: All objects must have&lt;br&gt;	// a valid state.&lt;br&gt;	%string = %this.currentState;&lt;br&gt;	// looping has 7 chars&lt;br&gt;	%start = 7;&lt;br&gt;	%length = strlen(%string);&lt;br&gt;	%numChars = %length - %start + 1;&lt;br&gt;	// Get substring NameState&lt;br&gt;	%state = getSubStr(%string, %start, %numChars);&lt;br&gt;	return %state;&lt;br&gt;}&lt;br&gt;&lt;br&gt;// Accessor Function setState()&lt;br&gt;function setState(%this, %state)&lt;br&gt;{&lt;br&gt;	// ONLY used for state transition&lt;br&gt;	&lt;br&gt;	// List of Vaild States by Priority&lt;br&gt;	// EvadeState&lt;br&gt;	// ChaseState&lt;br&gt;	// FightState&lt;br&gt;	// HuntState&lt;br&gt;	// AvoidState&lt;br&gt;	// RoamState&lt;br&gt;	// EatenState&lt;br&gt;	// DeadState&lt;br&gt;	// PlayState (player ONLY)&lt;br&gt;	&lt;br&gt;	// Check for the &amp;quot;none&amp;quot; State&lt;br&gt;	if (%state $= &amp;quot;none&amp;quot;) return;&lt;br&gt;	&lt;br&gt;	// Remove the prefix named looping&lt;br&gt;	// from the currentState field&lt;br&gt;	%currentState = getState(%this);&lt;br&gt;	&lt;br&gt;	// Call Exit State&lt;br&gt;	%method = &amp;quot;exit&amp;quot; @ %currentState;&lt;br&gt;	call(%method, %this);&lt;br&gt;	&lt;br&gt;	// Call Enter State&lt;br&gt;	// %state argument is our&lt;br&gt;	// transition state&lt;br&gt;	%method = &amp;quot;enter&amp;quot; @ %state;&lt;br&gt;	call(%method, %this);&lt;br&gt;&lt;br&gt;	// Set Transition State (%state argument) in Dynamic Field edited&lt;br&gt;	%this.currentState = &amp;quot;looping&amp;quot; @ %state;&lt;br&gt;}&lt;br&gt;&lt;br&gt;// Get Sprite&lt;br&gt;$spriteAvatarCount = 0;&lt;br&gt;function getSprite()&lt;br&gt;{&lt;br&gt;	if ($spriteAvatarCount &amp;gt; 6) $spriteAvatarCount = 0;&lt;br&gt;	$spriteAvatarCount++;&lt;br&gt;	if ($spriteAvatarCount == 1) return $predator;&lt;br&gt;	if ($spriteAvatarCount == 2) return $player;&lt;br&gt;	if ($spriteAvatarCount == 3) return $mediumFish;&lt;br&gt;	if ($spriteAvatarCount == 4) return $smallFishA;&lt;br&gt;	if ($spriteAvatarCount == 5) return $smallFishB;&lt;br&gt;	if ($spriteAvatarCount == 6) return $smallFishC;&lt;br&gt;	if ($spriteAvatarCount == 7) return $smallFishD;&lt;br&gt;}&lt;br&gt;&lt;br&gt;// Simple Finite State Machine&lt;br&gt;// FSM is constantly cycling&lt;br&gt;$loopingTime = 15;&lt;br&gt;function cycleFSM(%this)&lt;br&gt;{&lt;br&gt;	// Finite State Machine&lt;br&gt;	// Get Current State from Dynamic Fields&lt;br&gt;	%method = %this.currentState;&lt;br&gt;	// Call Current State&lt;br&gt;	call(%method, %this);&lt;br&gt;	// Cycle Next Sprite&lt;br&gt;	$cycleSpriteEvent = schedule($loopingTime, 0, &amp;quot;cycleSprite&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;$machineOn = 1;&lt;br&gt;function cycleSprite()&lt;br&gt;{&lt;br&gt;	// cycle FSM&lt;br&gt;	if ($machineOn) &lt;br&gt;	{&lt;br&gt;		%this = getSprite();&lt;br&gt;		$cycleFSMEvent = schedule($loopingTime, 0, &amp;quot;cycleFSM&amp;quot;, %this);&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;&lt;br&gt;// State Initialization&lt;br&gt;function initializeState()&lt;br&gt;{&lt;br&gt;	error(&amp;quot;Initialize subroutine NONE&amp;quot;);&lt;br&gt;	// Any initialization call subroutine may be placed here&lt;br&gt;	&lt;br&gt;	&lt;br&gt;	error(&amp;quot;Initialize Enter State&amp;quot;);&lt;br&gt;	for (%i = 0; %i &amp;lt; 2; %i++)&lt;br&gt;	{&lt;br&gt;		// Enter only those sprites below that should&lt;br&gt;		// be initialized with an enterNameState&lt;br&gt;		if (%i == 0) %this = $predator;&lt;br&gt;		if (%i == 1) %this = $mediumFish;&lt;br&gt;		// Remove the prefix named looping&lt;br&gt;		// from the currentState field&lt;br&gt;		%currentState = getState(%this);&lt;br&gt;		// Call Enter State&lt;br&gt;		%method = &amp;quot;enter&amp;quot; @ %currentState;&lt;br&gt;		error(%method);&lt;br&gt;		call(%method, %this);&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	error(&amp;quot;Initialization Complete&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;function setMachineON()&lt;br&gt;{&lt;br&gt;	error(&amp;quot;Finite State Machine ON&amp;quot;);&lt;br&gt;	$machineOn = 1;&lt;br&gt;	initializeState();&lt;br&gt;	cycleSprite();&lt;br&gt;}&lt;br&gt;&lt;br&gt;function setMachineOFF()&lt;br&gt;{&lt;br&gt;	error(&amp;quot;Finite State Machine OFF&amp;quot;);&lt;br&gt;	$machineOn = 0;&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;A State Example (Roam State) with embedded rules&lt;/b&gt;&lt;br&gt;Here is an example which is improved for performance and testing (profiling the states).&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;// RoamState&lt;br&gt;// Carpenter Software&lt;br&gt;&lt;br&gt;// ENTER Medium Fish&lt;br&gt;function enterMediumFishRoam(%this)&lt;br&gt;{&lt;br&gt;	// Initiate Roam Limit Randomly&lt;br&gt;	setNotHungry(%this);&lt;br&gt;	// Random Time 1 - 5 secs&lt;br&gt;	%limit = getRandom(1, 3);&lt;br&gt;	// Predator has eaten then allow hin to rest&lt;br&gt;	if (getHasEaten(%this)) &lt;br&gt;	{&lt;br&gt;		%limit += 3;&lt;br&gt;		error(&amp;quot;enterMediumFishRoam - mediumFish - getHasEaten - &amp;quot; @ %limit SPC &amp;quot;secs&amp;quot;);&lt;br&gt;	}&lt;br&gt;	// Convert secs to millisecs&lt;br&gt;	%limit *= 1000;&lt;br&gt;	%this.limitRoamTime = %limit;&lt;br&gt;	// Set dynamic field roamTime&lt;br&gt;	%this.roamTime = getSimTime();&lt;br&gt;}&lt;br&gt;&lt;br&gt;// ENTER Predator&lt;br&gt;function enterPredatorRoam(%this)&lt;br&gt;{&lt;br&gt;	// Initiate Roam Limit Randomly&lt;br&gt;	setNotHungry(%this);&lt;br&gt;	// Random Time 1 - 5 secs&lt;br&gt;	%limit = getRandom(1, 3);&lt;br&gt;	// Predator has eaten then allow hin to rest&lt;br&gt;	if (getHasEaten(%this)) &lt;br&gt;	{&lt;br&gt;		%limit += 3;&lt;br&gt;		error(&amp;quot;enterPredatorRoam - predator - getHasEaten - &amp;quot; @ %limit SPC &amp;quot;secs&amp;quot;);&lt;br&gt;	}&lt;br&gt;	// Convert secs to millisecs&lt;br&gt;	%limit *= 1000;&lt;br&gt;	// Set dynamic field limitRoamTime&lt;br&gt;	%this.limitRoamTime = %limit;&lt;br&gt;	// Set dynamic field roamTime&lt;br&gt;	%this.roamTime = getSimTime();&lt;br&gt;}&lt;br&gt;&lt;br&gt;// ENTER Roam State&lt;br&gt;function enterRoamState(%this)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Class mediumFish&lt;br&gt;	if (%class $= &amp;quot;mediumFish&amp;quot;) enterMediumFishRoam(%this);&lt;br&gt;	// Class predator&lt;br&gt;	if (%class $= &amp;quot;predator&amp;quot;) enterPredatorRoam(%this);&lt;br&gt;	// profile&lt;br&gt;	dumpEnterState(%this, &amp;quot;Roam State&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;// EXIT Medium Fish&lt;br&gt;function exitMediumFishRoam(%this)&lt;br&gt;{&lt;br&gt;	// Has Not Eaten&lt;br&gt;	setHasNotEaten(%this);&lt;br&gt;	// Must be cleared for conditional&lt;br&gt;	// (ie uses of enter and exit states)&lt;br&gt;	%this.roamTime = 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;// EXIT Predator&lt;br&gt;function exitPredatorRoam(%this)&lt;br&gt;{&lt;br&gt;	// Has Not Eaten&lt;br&gt;	setHasNotEaten(%this);&lt;br&gt;	// Must be cleared for conditional&lt;br&gt;	// (ie uses of enter and exit states)&lt;br&gt;	%this.roamTime = 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;// EXIT Roam State&lt;br&gt;function exitRoamState(%this)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Class mediumFish&lt;br&gt;	if (%class $= &amp;quot;mediumFish&amp;quot;) exitMediumFishRoam(%this);&lt;br&gt;	// Class predator&lt;br&gt;	if (%class $= &amp;quot;predator&amp;quot;) exitPredatorRoam(%this);&lt;br&gt;	// profile&lt;br&gt;	dumpExitState(%this, &amp;quot;Roam State&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;// LOOPING smallFish A, B and C&lt;br&gt;function smallFishRoam(%this)&lt;br&gt;{&lt;br&gt;	// Check Transition Rules&lt;br&gt;	////////////////////&lt;br&gt;	if (isThreaten(%this))&lt;br&gt;	{&lt;br&gt;		// profile&lt;br&gt;		dumpTransitionStates(%this, &amp;quot;Roam to Evade State&amp;quot;);&lt;br&gt;		// Set transition state&lt;br&gt;		setState(%this, &amp;quot;EvadeState&amp;quot;);&lt;br&gt;		// Change State has occurred&lt;br&gt;		return;&lt;br&gt;	}&lt;br&gt;	////////////////////&lt;br&gt;	if (inDistance(%this))&lt;br&gt;	{&lt;br&gt;		// profile&lt;br&gt;		dumpTransitionStates(%this, &amp;quot;Roam to Avoid State&amp;quot;);&lt;br&gt;		// Set transition state&lt;br&gt;		setState(%this, &amp;quot;AvoidState&amp;quot;);&lt;br&gt;		// Change State has occurred&lt;br&gt;		return;&lt;br&gt;	}&lt;br&gt;	// Looping Method&lt;br&gt;	////////////////////&lt;br&gt;	// DoRoam() checks vicinity&lt;br&gt;	// wityh predator and moves away&lt;br&gt;	// and adjusts speed to limits&lt;br&gt;	// but not both at the same time&lt;br&gt;	DoRoam(%this);&lt;br&gt;	////////////////////&lt;br&gt;}&lt;br&gt;&lt;br&gt;// LOOPING mediumFish&lt;br&gt;function mediumFishRoam(%this)&lt;br&gt;{&lt;br&gt;	// Check Transition Rules&lt;br&gt;	////////////////////&lt;br&gt;	if (isThreaten(%this))&lt;br&gt;	{&lt;br&gt;		// profile&lt;br&gt;		dumpTransitionStates(%this, &amp;quot;Roam to Evade State&amp;quot;);&lt;br&gt;		// Set transition state&lt;br&gt;		setState(%this, &amp;quot;EvadeState&amp;quot;);&lt;br&gt;		// Change State has occurred&lt;br&gt;		return;&lt;br&gt;	}&lt;br&gt;	////////////////////&lt;br&gt;	if (inDistance(%this))&lt;br&gt;	{&lt;br&gt;		// profile&lt;br&gt;		dumpTransitionStates(%this, &amp;quot;Roam to Avoid State&amp;quot;);&lt;br&gt;		// Set transition state&lt;br&gt;		setState(%this, &amp;quot;AvoidState&amp;quot;);&lt;br&gt;		// Change State has occurred&lt;br&gt;		return;&lt;br&gt;	}&lt;br&gt;	// Looping Method&lt;br&gt;	////////////////////&lt;br&gt;	// DoRoam() checks vicinity&lt;br&gt;	// wityh predator and moves away&lt;br&gt;	// and adjusts speed to limits&lt;br&gt;	// but not both at the same time&lt;br&gt;	// MUST place DoRoam() before&lt;br&gt;	// the conditional isHungry().&lt;br&gt;	DoRoam(%this);&lt;br&gt;	////////////////////&lt;br&gt;	if (isHungry(%this))&lt;br&gt;	{&lt;br&gt;		// profile&lt;br&gt;		dumpTransitionStates(%this, &amp;quot;Roam to Hunt State&amp;quot;);&lt;br&gt;		// Set transition state&lt;br&gt;		setState(%this, &amp;quot;HuntState&amp;quot;);&lt;br&gt;		// Change State has occurred&lt;br&gt;		return;&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;&lt;br&gt;// LOOPING predator&lt;br&gt;function predatorRoam(%this)&lt;br&gt;{&lt;br&gt;		// Check Transition Rules&lt;br&gt;		////////////////////&lt;br&gt;		// Looping Method&lt;br&gt;		////////////////////&lt;br&gt;		// DoRoam() checks elapsedTime&lt;br&gt;		// if elapsedTime is true&lt;br&gt;		// then object is hungry&lt;br&gt;		// If you roamed around over&lt;br&gt;		// time, you'd get hungry too.&lt;br&gt;		// MUST place DoRoam() before&lt;br&gt;		// the conditional isHungry().&lt;br&gt;		DoRoam(%this);&lt;br&gt;		////////////////////&lt;br&gt;		if (isHungry(%this))&lt;br&gt;		{&lt;br&gt;			// profile&lt;br&gt;			dumpTransitionStates(%this, &amp;quot;Roam to Hunt State&amp;quot;);&lt;br&gt;			// Set transition state&lt;br&gt;			setState(%this, &amp;quot;HuntState&amp;quot;);&lt;br&gt;			// Change State has occurred&lt;br&gt;			return;&lt;br&gt;		}&lt;br&gt;}&lt;br&gt;&lt;br&gt;// LOOPING Roam State (Static Value of Dynamic Field) &lt;br&gt;function loopingRoamState(%this)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Class smallFish&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;) smallFishRoam(%this);&lt;br&gt;	// Class mediumFish&lt;br&gt;	if (%class $= &amp;quot;mediumFish&amp;quot;) mediumFishRoam(%this);&lt;br&gt;	// Class predator&lt;br&gt;	if (%class $= &amp;quot;predator&amp;quot;) predatorRoam(%this);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Looping Method DoRoam()&lt;/b&gt;&lt;br&gt;Here is an example of the Looping Method within the Roam State....&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;function DoRoam(%this)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	&lt;br&gt;	// Adjust Speed for smallFish, mediumFish and predator&lt;br&gt;	if (isSpeedBad(%this)) adjustSpeed(%this);&lt;br&gt;	&lt;br&gt;	// mediumFish OR predator&lt;br&gt;	if ((%class $= &amp;quot;mediumFish&amp;quot;) || (%class $= &amp;quot;predator&amp;quot;))&lt;br&gt;	{&lt;br&gt;		// Check to see if roamTime has been set.&lt;br&gt;		if (%this.roamTime)&lt;br&gt;		{&lt;br&gt;			%elapsedTime = getSimTime() - %this.roamTime;&lt;br&gt;			// error(&amp;quot;DoRoam - &amp;quot; @ %this @ &amp;quot; - elapsedTime - &amp;quot; @ %elapsedTime SPC &amp;quot;ms&amp;quot;);&lt;br&gt;			%limit = %this.limitRoamTime;&lt;br&gt;			if (%elapsedTime &amp;gt; %limit) setHungry(%this);&lt;br&gt;		}&lt;br&gt;	}&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Conditions (Transition Rules)&lt;/b&gt;&lt;br&gt;Here are some examples of transition rules used by the Roam State.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;function isThreaten(%this)&lt;br&gt;{&lt;br&gt;	// If isTreaten is true&lt;br&gt;	// then transition to another State.&lt;br&gt;	return %this.threaten;&lt;br&gt;}&lt;br&gt;&lt;br&gt;function isHungry(%this)&lt;br&gt;{&lt;br&gt;	// Roam State transitions to &lt;br&gt;	// another State when hungry is true (1)&lt;br&gt;	return %this.hungry;&lt;br&gt;}&lt;br&gt;&lt;br&gt;function inDistance(%this)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	&lt;br&gt;	// smallFish&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;)&lt;br&gt;	{&lt;br&gt;		// loop posible spooks&lt;br&gt;		%prey = %this;&lt;br&gt;		for(%i = 0; %i &amp;lt; 3; %i++)&lt;br&gt;		{&lt;br&gt;			%limit = 26;&lt;br&gt;			if (%i == 0) &lt;br&gt;			{&lt;br&gt;				%hunter = $predator;&lt;br&gt;				%limit = 27;&lt;br&gt;			}&lt;br&gt;			if (%i == 1) %hunter = $player;&lt;br&gt;			if (%i == 2) %hunter = $mediumFish;&lt;br&gt;			&lt;br&gt;			// Get distance&lt;br&gt;			%distance = getDistance(%hunter, %prey);&lt;br&gt;			&lt;br&gt;			// Transition if within distance&lt;br&gt;			if (%distance &amp;lt; %limit) &lt;br&gt;			{&lt;br&gt;				setSpook(%this, %hunter);&lt;br&gt;				return true;&lt;br&gt;			}&lt;br&gt;		}&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	// mediumFish&lt;br&gt;	if (%class $= &amp;quot;mediumFish&amp;quot;)&lt;br&gt;	{&lt;br&gt;		%prey = %this;&lt;br&gt;		%hunter = $predator;&lt;br&gt;		&lt;br&gt;		// Get distance&lt;br&gt;		%distance = getDistance(%hunter, %prey);&lt;br&gt;		&lt;br&gt;		// Transition if within distance&lt;br&gt;		if (%distance &amp;lt; 35) &lt;br&gt;		{&lt;br&gt;			setSpook(%this, %hunter);&lt;br&gt;			return true;&lt;br&gt;		}&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	// Always return something&lt;br&gt;	return false;&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Supporting Function&lt;/b&gt;&lt;br&gt;Finally here is a supporting function getDistance() called from the transition rules. &lt;i&gt;The purpose as indicated in the TGB 1.1.3 Ref. documentation - t2dVectorDistance(%vector1, %vector2): Gets the scalar distance between two points. Although the t2dVectorDistance() call uses arguments named vector. They are misnomers and should be labeled point1 and point2. In TGB 1.7.x, I believe this has been corrected.&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;function getDistance(%hunter, %prey)&lt;br&gt;{&lt;br&gt;	%vector1 = %hunter.getPosition();&lt;br&gt;	%vector2 = %prey.getPosition();&lt;br&gt;	%distance = t2dVectorDistance(%vector1, %vector2);&lt;br&gt;	return %distance;&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Simple Finite State Machine (SFSM) in action&lt;/b&gt;&lt;br&gt;Well the predator and smallFish routines are completed. It looks awesome. Here you can view the first movie SFSM: &lt;a href='http://www.youtube.com/watch?v=BIK8tFqLwgU' target=_blank&gt;Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;SFSM2 in action&lt;/b&gt;&lt;br&gt;I just finished the other object, the medium fish. The medium fish has all traits. It has the traits from the predator and the traits of the small fish. I looks awesome. Here you can view the second movie SFSM2: &lt;a href='http://www.youtube.com/watch?v=MGFT7T9o_v0' target=_blank&gt;Click Here&lt;/a&gt;. If you look at the state transition table below, the colored spreadsheet. I have finished the pair IDs 1, 2, 3, 4, 5, 6 12, 13 and 14. The next sets are 7, 8, 9, 17, 18, and 19 that includes the player with similar routines of that of the other fishes. The last 4 sets are new routines that includes the fighting between the player and the medium fish.&lt;br&gt;&lt;br&gt;&lt;b&gt;SFSM3 in action&lt;/b&gt;&lt;br&gt;The player is now added to the FSM, but it was not easy. I had to change the State Transition Table below from the &amp;quot;none&amp;quot; transitions to an appropriate transition states. The above spreadsheet does not look at all like the one I have now. I have made changes over time at least 17 times. I finished sets 7, 8, 9, 17, 18, and 19 that includes the player with routines similar to the other fishes. Also I made changes to the profile to dump specific information about the player. As of now, the player looks awesome. The player eating fish and also being chased and eaten by the larger one. Here you can view the third movie SFSM3: &lt;a href='http://www.youtube.com/watch?v=v3Lg4Nqes_s' target=_blank&gt;Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;SFSM4 in action&lt;/b&gt;&lt;br&gt;Well here is the fourth movie in this project but there will be others on performance and making it look pretty as Jussi suggested above. This movie has the medium fishes, the NPC and the player, and the fighting routines, incorporated into the FSM. Here you can view the fourth movie SFSM4: &lt;a href='http://www.youtube.com/watch?v=JlKk9YovFOU' target=_blank&gt;Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;SFSM5 in action&lt;/b&gt;&lt;br&gt;Here is the one on performance and of course making it look pretty. There are 10 objects cycling the FSM. It looks awesome! Also object animations added from the fish art from GG, and also background scenery and particle effects were added. Here you can view the fifth movie from YouTube - SFSM5: &lt;a href='http://www.youtube.com/watch?v=lZtl80zChV8' target=_blank&gt;Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;Performance&lt;/b&gt;&lt;br&gt;Performance is something I always look at when working. I checked all my looping methods to make sure there is no bottlenecks. The choice of algorithm I use affects efficiency more than any other item of the design. If there is a bottleneck, I fix it to improve on its efficiency. When all that is done, I start playing with the Global $loopingTime in the FSM. It was initially set to 35 millisecs. At this rate, the minimum time between events of the same Object, the player in this case, was approximately 1 sec. This means that the closer the minimum time that the player cycles through the FSM -&amp;gt; the better. The problem with the 1 sec cycle is causing some lag time in the response among other objects that the player is interacting with. Therefore I reduced the Global $loopingTime down to 15 millisecs and obtaining a minimum time of 0.4 secs. Now the response times among other objects is much better. I am afraid that adding more objects will reduce the performance. We'll see! There are times I have been tempted to side track by adding realism as you advise but I have taken GG's advice to develop the code first. Then add all the nice stuff later. Once the logic of the program is done many things can be done to it. It will be used as a reference for many games to come. The major experiment on this is the focus on the FSM and looking at the performance in what is the best way to set up embedded rules and the States themselves. Also do it all using torquescript. One idea that has occurred to me concerning performance. If a subroutine requires time to process, so instead of using a direct call to the routine, an event call like schedule may improve the cycle of the FSM. Like adding a flocking behavior as Jussi suggests that may require intensive crunching time and as the FSM cycles, check to see if the subroutine has completed to perform another depending if the subroutines requires cycling. &lt;br&gt;&lt;br&gt;&lt;b&gt;Profiling and debugging&lt;/b&gt;&lt;br&gt;I had set the States up to profile the transitions and the object's dynamic fields live, so I could debug any problems. For example, the YouTube movie SFSM4 there is a BUG. I will use the following routines to help with the debugging:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;function getDynamics(%this, %state)&lt;br&gt;{&lt;br&gt;	// Note: %state not being used&lt;br&gt;	&lt;br&gt;	echo(&amp;quot;hunter ID&amp;quot; SPC %this.hunter);&lt;br&gt;	echo(&amp;quot;prey ID&amp;quot; SPC %this.prey);&lt;br&gt;	&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	&lt;br&gt;	// Class smallFish&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;)&lt;br&gt;	{&lt;br&gt;		echo(&amp;quot;threaten&amp;quot; SPC %this.threaten);&lt;br&gt;		echo(&amp;quot;safe&amp;quot; SPC %this.safe);&lt;br&gt;		echo(&amp;quot;eaten&amp;quot; SPC %this.eaten);&lt;br&gt;		if (%this.spook)&lt;br&gt;		{&lt;br&gt;			%spookClass = %this.spook.class;&lt;br&gt;			echo(&amp;quot;spook&amp;quot; SPC %spookClass @ &amp;quot;:&amp;quot; @ %this.spook);&lt;br&gt;		}&lt;br&gt;		else echo(&amp;quot;spook&amp;quot; SPC &amp;quot;none:&amp;quot; @ %this.spook);&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	// Class mediumFish&lt;br&gt;	if (%class $= &amp;quot;mediumFish&amp;quot;)&lt;br&gt;	{&lt;br&gt;		echo(&amp;quot;intimidated&amp;quot; SPC %this.intimidated);&lt;br&gt;		echo(&amp;quot;winFight&amp;quot; SPC %this.winFight);&lt;br&gt;		echo(&amp;quot;energy&amp;quot; SPC %this.energy);&lt;br&gt;		echo(&amp;quot;dead&amp;quot; SPC %this.dead);&lt;br&gt;		echo(&amp;quot;fight&amp;quot; SPC %this.fight);&lt;br&gt;		echo(&amp;quot;threaten&amp;quot; SPC %this.threaten);&lt;br&gt;		echo(&amp;quot;safe&amp;quot; SPC %this.safe);&lt;br&gt;		echo(&amp;quot;eaten&amp;quot; SPC %this.eaten);&lt;br&gt;		echo(&amp;quot;hungry&amp;quot; SPC %this.hungry);&lt;br&gt;		echo(&amp;quot;hasEaten&amp;quot; SPC %this.hasEaten);&lt;br&gt;		if (%this.spook)&lt;br&gt;		{&lt;br&gt;			%spookClass = %this.spook.class;&lt;br&gt;			echo(&amp;quot;spook&amp;quot; SPC %spookClass @ &amp;quot;:&amp;quot; @ %this.spook);&lt;br&gt;		}&lt;br&gt;		else echo(&amp;quot;spook&amp;quot; SPC &amp;quot;none:&amp;quot; @ %this.spook);&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	// Class mediumFish&lt;br&gt;	if (%class $= &amp;quot;player&amp;quot;)&lt;br&gt;	{&lt;br&gt;		echo(&amp;quot;intimidated&amp;quot; SPC %this.intimidated);&lt;br&gt;		echo(&amp;quot;winFight&amp;quot; SPC %this.winFight);&lt;br&gt;		echo(&amp;quot;energy&amp;quot; SPC %this.energy);&lt;br&gt;		echo(&amp;quot;dead&amp;quot; SPC %this.dead);&lt;br&gt;		echo(&amp;quot;threaten&amp;quot; SPC %this.threaten);&lt;br&gt;		echo(&amp;quot;safe&amp;quot; SPC %this.safe);&lt;br&gt;		echo(&amp;quot;eaten&amp;quot; SPC %this.eaten);&lt;br&gt;		echo(&amp;quot;hasEaten&amp;quot; SPC %this.hasEaten);&lt;br&gt;	}&lt;br&gt;	&lt;br&gt;	// Class predator&lt;br&gt;	if (%class $= &amp;quot;predator&amp;quot;)&lt;br&gt;	{&lt;br&gt;		echo(&amp;quot;hungry&amp;quot; SPC %this.hungry);&lt;br&gt;		echo(&amp;quot;hasEaten&amp;quot; SPC %this.hasEaten);&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;&lt;br&gt;function dumpTransitionStates(%this, %state)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Comment out class to profile&lt;br&gt;	// if (%class $= &amp;quot;predator&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;player&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;mediumFish&amp;quot;) return;&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;) return;&lt;br&gt;	&lt;br&gt;	echo(&amp;quot;----------------------------------&amp;quot;);&lt;br&gt;	echo(&amp;quot;TRANSITIONED&amp;quot; SPC %this.class @ &amp;quot;:&amp;quot; @ %this SPC &amp;quot;from&amp;quot; SPC %state);&lt;br&gt;	%time = getSimTime();&lt;br&gt;	// convert to secs&lt;br&gt;	%float = %time / 1000;&lt;br&gt;	%numDecimals = 1;&lt;br&gt;	%secs = mFloatLength(%float, %numDecimals);&lt;br&gt;	echo(&amp;quot;Time Stamp (secs):&amp;quot; SPC %secs);&lt;br&gt;}&lt;br&gt;&lt;br&gt;function dumpEnterState(%this, %state)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Comment out class to profile&lt;br&gt;	// if (%class $= &amp;quot;predator&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;player&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;mediumFish&amp;quot;) return;&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;) return;&lt;br&gt;	&lt;br&gt;	echo(&amp;quot;-----------------&amp;quot;);&lt;br&gt;	echo(&amp;quot;ENTER&amp;quot; SPC %this.class @ &amp;quot;:&amp;quot; @ %this SPC %state);&lt;br&gt;	getDynamics(%this, %state);&lt;br&gt;}&lt;br&gt;&lt;br&gt;function dumpExitState(%this, %state)&lt;br&gt;{&lt;br&gt;	// Get class&lt;br&gt;	%class = %this.class;&lt;br&gt;	// Comment out class to profile&lt;br&gt;	// if (%class $= &amp;quot;predator&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;player&amp;quot;) return;&lt;br&gt;	// if (%class $= &amp;quot;mediumFish&amp;quot;) return;&lt;br&gt;	if (%class $= &amp;quot;smallFish&amp;quot;) return;&lt;br&gt;	&lt;br&gt;	echo(&amp;quot;-----------------&amp;quot;);&lt;br&gt;	echo(&amp;quot;EXIT&amp;quot; SPC %this.class @ &amp;quot;:&amp;quot; @ %this SPC %state);&lt;br&gt;	getDynamics(%this, %state);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Profile&lt;/b&gt;&lt;br&gt;The following is a profile live as the game is running. Without this profile, I could not debug the game. Note that the small fish is turned off from profiling. Also note as the two fishes fight, their energies start at the same value. The player at first is losing but that is changed when I use a keyboard technique in the fight. Lower down the list, the player is winning. At the end, the medium fish transitions from the fight state to the dead state, and the player transitions from the fight state to the play state. The entire fight endures for approximately 16 seconds (view time stamps). All the while, the predator does his thing.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class='codeblock'&gt;&lt;pre&gt;Finite State Machine ON&lt;br&gt;&lt;br&gt;Initialize subroutine NONE&lt;br&gt;Initialize Enter State&lt;br&gt;enterRoamState&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 0&lt;br&gt;hasEaten 0&lt;br&gt;enterRoamState&lt;br&gt;-----------------&lt;br&gt;...deleted... (a part from a very long profile)&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED mediumFish:2712 from Roam to Hunt State&lt;br&gt;Time Stamp (secs): 57.2&lt;br&gt;-----------------&lt;br&gt;EXIT mediumFish:2712 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 750&lt;br&gt;dead 0&lt;br&gt;fight 1&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;-----------------&lt;br&gt;ENTER mediumFish:2712 Hunt State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 750&lt;br&gt;dead 0&lt;br&gt;fight 0&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED mediumFish:2712 from Hunt to Fight State&lt;br&gt;Time Stamp (secs): 57.6&lt;br&gt;2712 pushIDs 2712 2712 2715 2715&lt;br&gt;-----------------&lt;br&gt;EXIT mediumFish:2712 Hunt State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 1&lt;br&gt;winFight 0&lt;br&gt;energy 750&lt;br&gt;dead 0&lt;br&gt;fight 1&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;-----------------&lt;br&gt;ENTER mediumFish:2712 Fight State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 1&lt;br&gt;winFight 0&lt;br&gt;energy 675&lt;br&gt;dead 0&lt;br&gt;fight 1&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED player:2715 from Play to Fight State&lt;br&gt;Time Stamp (secs): 57.8&lt;br&gt;-----------------&lt;br&gt;EXIT player:2715 Play State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 1&lt;br&gt;winFight 0&lt;br&gt;energy 675&lt;br&gt;dead 0&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER player:2715 Fight State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 1&lt;br&gt;winFight 0&lt;br&gt;energy 675&lt;br&gt;dead 0&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hasEaten 0&lt;br&gt;mediumFishFight -&amp;gt; Energy: 675&lt;br&gt;2714 pushIDs 2714 2714 2718 2718&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Hunt to Chase State&lt;br&gt;Time Stamp (secs): 58.0&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Hunt State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2718&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Chase State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2718&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 670&lt;br&gt;mediumFishFight -&amp;gt; Energy: 670&lt;br&gt;playerFight -&amp;gt; Energy: 665&lt;br&gt;mediumFishFight -&amp;gt; Energy: 665&lt;br&gt;playerFight -&amp;gt; Energy: 660&lt;br&gt;mediumFishFight -&amp;gt; Energy: 660&lt;br&gt;playerFight -&amp;gt; Energy: 655&lt;br&gt;mediumFishFight -&amp;gt; Energy: 655&lt;br&gt;playerFight -&amp;gt; Energy: 650&lt;br&gt;mediumFishFight -&amp;gt; Energy: 650&lt;br&gt;playerFight -&amp;gt; Energy: 645&lt;br&gt;mediumFishFight -&amp;gt; Energy: 645&lt;br&gt;2714 popIDs 0 0 0 0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Chase to Roam State&lt;br&gt;Time Stamp (secs): 59.3&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Chase State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 0&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 640&lt;br&gt;mediumFishFight -&amp;gt; Energy: 640&lt;br&gt;playerFight -&amp;gt; Energy: 635&lt;br&gt;mediumFishFight -&amp;gt; Energy: 635&lt;br&gt;playerFight -&amp;gt; Energy: 625&lt;br&gt;mediumFishFight -&amp;gt; Energy: 635&lt;br&gt;playerFight -&amp;gt; Energy: 620&lt;br&gt;mediumFishFight -&amp;gt; Energy: 630&lt;br&gt;playerFight -&amp;gt; Energy: 610&lt;br&gt;mediumFishFight -&amp;gt; Energy: 630&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Roam to Hunt State&lt;br&gt;Time Stamp (secs): 60.3&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Hunt State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 605&lt;br&gt;mediumFishFight -&amp;gt; Energy: 625&lt;br&gt;2714 pushIDs 2714 2714 2713 2713&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Hunt to Chase State&lt;br&gt;Time Stamp (secs): 60.5&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Hunt State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2713&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Chase State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2713&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 595&lt;br&gt;mediumFishFight -&amp;gt; Energy: 625&lt;br&gt;playerFight -&amp;gt; Energy: 590&lt;br&gt;mediumFishFight -&amp;gt; Energy: 620&lt;br&gt;playerFight -&amp;gt; Energy: 580&lt;br&gt;mediumFishFight -&amp;gt; Energy: 620&lt;br&gt;playerFight -&amp;gt; Energy: 575&lt;br&gt;mediumFishFight -&amp;gt; Energy: 615&lt;br&gt;playerFight -&amp;gt; Energy: 565&lt;br&gt;mediumFishFight -&amp;gt; Energy: 615&lt;br&gt;playerFight -&amp;gt; Energy: 560&lt;br&gt;mediumFishFight -&amp;gt; Energy: 610&lt;br&gt;playerFight -&amp;gt; Energy: 555&lt;br&gt;mediumFishFight -&amp;gt; Energy: 605&lt;br&gt;playerFight -&amp;gt; Energy: 550&lt;br&gt;mediumFishFight -&amp;gt; Energy: 600&lt;br&gt;playerFight -&amp;gt; Energy: 545&lt;br&gt;mediumFishFight -&amp;gt; Energy: 595&lt;br&gt;2714 popIDs 0 0 0 0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Chase to Roam State&lt;br&gt;Time Stamp (secs): 62.4&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Chase State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 1&lt;br&gt;enterPredatorRoam - predator - getHasEaten - 5 secs&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 0&lt;br&gt;hasEaten 1&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 590&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 580&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 570&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 560&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 550&lt;br&gt;playerFight -&amp;gt; Energy: 540&lt;br&gt;mediumFishFight -&amp;gt; Energy: 540&lt;br&gt;playerFight -&amp;gt; Energy: 535&lt;br&gt;mediumFishFight -&amp;gt; Energy: 535&lt;br&gt;playerFight -&amp;gt; Energy: 530&lt;br&gt;mediumFishFight -&amp;gt; Energy: 530&lt;br&gt;playerFight -&amp;gt; Energy: 525&lt;br&gt;mediumFishFight -&amp;gt; Energy: 525&lt;br&gt;playerFight -&amp;gt; Energy: 520&lt;br&gt;mediumFishFight -&amp;gt; Energy: 520&lt;br&gt;playerFight -&amp;gt; Energy: 515&lt;br&gt;mediumFishFight -&amp;gt; Energy: 515&lt;br&gt;playerFight -&amp;gt; Energy: 510&lt;br&gt;mediumFishFight -&amp;gt; Energy: 510&lt;br&gt;playerFight -&amp;gt; Energy: 505&lt;br&gt;mediumFishFight -&amp;gt; Energy: 505&lt;br&gt;playerFight -&amp;gt; Energy: 500&lt;br&gt;mediumFishFight -&amp;gt; Energy: 500&lt;br&gt;playerFight -&amp;gt; Energy: 495&lt;br&gt;mediumFishFight -&amp;gt; Energy: 495&lt;br&gt;playerFight -&amp;gt; Energy: 490&lt;br&gt;mediumFishFight -&amp;gt; Energy: 490&lt;br&gt;playerFight -&amp;gt; Energy: 485&lt;br&gt;mediumFishFight -&amp;gt; Energy: 485&lt;br&gt;playerFight -&amp;gt; Energy: 485&lt;br&gt;mediumFishFight -&amp;gt; Energy: 475&lt;br&gt;playerFight -&amp;gt; Energy: 480&lt;br&gt;mediumFishFight -&amp;gt; Energy: 470&lt;br&gt;playerFight -&amp;gt; Energy: 480&lt;br&gt;mediumFishFight -&amp;gt; Energy: 460&lt;br&gt;playerFight -&amp;gt; Energy: 475&lt;br&gt;mediumFishFight -&amp;gt; Energy: 455&lt;br&gt;playerFight -&amp;gt; Energy: 475&lt;br&gt;mediumFishFight -&amp;gt; Energy: 445&lt;br&gt;playerFight -&amp;gt; Energy: 470&lt;br&gt;mediumFishFight -&amp;gt; Energy: 440&lt;br&gt;playerFight -&amp;gt; Energy: 470&lt;br&gt;mediumFishFight -&amp;gt; Energy: 430&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Roam to Hunt State&lt;br&gt;Time Stamp (secs): 67.4&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Hunt State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 465&lt;br&gt;mediumFishFight -&amp;gt; Energy: 425&lt;br&gt;playerFight -&amp;gt; Energy: 465&lt;br&gt;mediumFishFight -&amp;gt; Energy: 415&lt;br&gt;playerFight -&amp;gt; Energy: 460&lt;br&gt;mediumFishFight -&amp;gt; Energy: 410&lt;br&gt;playerFight -&amp;gt; Energy: 460&lt;br&gt;mediumFishFight -&amp;gt; Energy: 400&lt;br&gt;playerFight -&amp;gt; Energy: 455&lt;br&gt;mediumFishFight -&amp;gt; Energy: 395&lt;br&gt;playerFight -&amp;gt; Energy: 455&lt;br&gt;mediumFishFight -&amp;gt; Energy: 385&lt;br&gt;2714 pushIDs 2714 2714 2716 2716&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Hunt to Chase State&lt;br&gt;Time Stamp (secs): 68.7&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Hunt State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2716&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Chase State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2716&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 450&lt;br&gt;mediumFishFight -&amp;gt; Energy: 380&lt;br&gt;playerFight -&amp;gt; Energy: 450&lt;br&gt;mediumFishFight -&amp;gt; Energy: 370&lt;br&gt;playerFight -&amp;gt; Energy: 445&lt;br&gt;mediumFishFight -&amp;gt; Energy: 365&lt;br&gt;playerFight -&amp;gt; Energy: 435&lt;br&gt;mediumFishFight -&amp;gt; Energy: 365&lt;br&gt;playerFight -&amp;gt; Energy: 430&lt;br&gt;mediumFishFight -&amp;gt; Energy: 360&lt;br&gt;2714 popIDs 0 0 0 0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Chase to Roam State&lt;br&gt;Time Stamp (secs): 69.8&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Chase State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 0&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 420&lt;br&gt;mediumFishFight -&amp;gt; Energy: 360&lt;br&gt;playerFight -&amp;gt; Energy: 415&lt;br&gt;mediumFishFight -&amp;gt; Energy: 355&lt;br&gt;playerFight -&amp;gt; Energy: 405&lt;br&gt;mediumFishFight -&amp;gt; Energy: 355&lt;br&gt;playerFight -&amp;gt; Energy: 400&lt;br&gt;mediumFishFight -&amp;gt; Energy: 350&lt;br&gt;playerFight -&amp;gt; Energy: 390&lt;br&gt;mediumFishFight -&amp;gt; Energy: 350&lt;br&gt;playerFight -&amp;gt; Energy: 385&lt;br&gt;mediumFishFight -&amp;gt; Energy: 345&lt;br&gt;playerFight -&amp;gt; Energy: 380&lt;br&gt;mediumFishFight -&amp;gt; Energy: 340&lt;br&gt;playerFight -&amp;gt; Energy: 375&lt;br&gt;mediumFishFight -&amp;gt; Energy: 335&lt;br&gt;playerFight -&amp;gt; Energy: 370&lt;br&gt;mediumFishFight -&amp;gt; Energy: 330&lt;br&gt;playerFight -&amp;gt; Energy: 365&lt;br&gt;mediumFishFight -&amp;gt; Energy: 325&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Roam to Hunt State&lt;br&gt;Time Stamp (secs): 71.9&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Hunt State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 360&lt;br&gt;mediumFishFight -&amp;gt; Energy: 320&lt;br&gt;2714 pushIDs 2714 2714 2716 2716&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Hunt to Chase State&lt;br&gt;Time Stamp (secs): 72.1&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Hunt State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2716&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Chase State&lt;br&gt;hunter ID 2714&lt;br&gt;prey ID 2716&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;playerFight -&amp;gt; Energy: 355&lt;br&gt;mediumFishFight -&amp;gt; Energy: 315&lt;br&gt;playerFight -&amp;gt; Energy: 350&lt;br&gt;mediumFishFight -&amp;gt; Energy: 310&lt;br&gt;2714 popIDs 0 0 0 0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED predator:2714 from Chase to Roam State&lt;br&gt;Time Stamp (secs): 72.5&lt;br&gt;-----------------&lt;br&gt;EXIT predator:2714 Chase State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 1&lt;br&gt;enterPredatorRoam - predator - getHasEaten - 5 secs&lt;br&gt;-----------------&lt;br&gt;ENTER predator:2714 Roam State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;hungry 0&lt;br&gt;hasEaten 1&lt;br&gt;playerFight -&amp;gt; Energy: 345&lt;br&gt;mediumFishFight -&amp;gt; Energy: 305&lt;br&gt;playerFight -&amp;gt; Energy: 340&lt;br&gt;mediumFishFight -&amp;gt; Energy: 300&lt;br&gt;playerFight -&amp;gt; Energy: 335&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED mediumFish:2712 from Fight to Dead State&lt;br&gt;Time Stamp (secs): 73.0&lt;br&gt;-----------------&lt;br&gt;EXIT mediumFish:2712 Fight State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 750&lt;br&gt;dead 1&lt;br&gt;fight 1&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;-----------------&lt;br&gt;ENTER mediumFish:2712 Dead State&lt;br&gt;hunter ID 2712&lt;br&gt;prey ID 2715&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 750&lt;br&gt;dead 1&lt;br&gt;fight 1&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hungry 1&lt;br&gt;hasEaten 0&lt;br&gt;spook none:0&lt;br&gt;----------------------------------&lt;br&gt;TRANSITIONED player:2715 from Fight to Play State&lt;br&gt;Time Stamp (secs): 73.2&lt;br&gt;2715 popIDs 0 0 0 0&lt;br&gt;-----------------&lt;br&gt;EXIT player:2715 Fight State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 535&lt;br&gt;dead 0&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hasEaten 0&lt;br&gt;-----------------&lt;br&gt;ENTER player:2715 Play State&lt;br&gt;hunter ID 0&lt;br&gt;prey ID 0&lt;br&gt;intimidated 0&lt;br&gt;winFight 0&lt;br&gt;energy 535&lt;br&gt;dead 0&lt;br&gt;threaten 0&lt;br&gt;safe 1&lt;br&gt;eaten 0&lt;br&gt;hasEaten 0&lt;br&gt;&lt;br&gt;Finite State Machine OFF&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Programming Level&lt;/b&gt;&lt;br&gt;I have decided on a programming level. At whatever level, torquescript beginners should experiment with it. The code is considered in my opinion an intermediate to advance torquescript level and caution is advised when using this code. Of course, all comments are welcomed.&lt;br&gt;&lt;br&gt;&lt;b&gt;References&lt;/b&gt;&lt;br&gt;(1) &amp;quot;Programming Game AI by Example&amp;quot; by Mat Buckland, 2005, Wordware Publishing, Inc.&lt;br&gt;(2) To view thread Reference for this blog &lt;a href='http://www.garagegames.com/mg/forums/result.thread.php?qt=69545'&gt; Click Here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;Code&lt;/b&gt;&lt;br&gt;For those who want the torquescript code, email me a request to carpentersoftware@mac.com. PLEASE READ NOTICE ABOUT DISTRIBUTION ON THE POST BELOW DATED FEB 6, 2008.&lt;br&gt;&lt;br&gt;&lt;b&gt;Updated State Transition Table&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;img src='http://www.carpentersoftware.com/images/StateTransitionTable20.png'  alt=&quot;&quot;&gt;&lt;br&gt;&lt;br&gt;Carpenter Software</description>
	</item>
</rdf:RDF>
