<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.gameai.com/manuals/index.php?action=history&amp;feed=atom&amp;title=Behavior_history</id>
	<title>Behavior history - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.gameai.com/manuals/index.php?action=history&amp;feed=atom&amp;title=Behavior_history"/>
	<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;action=history"/>
	<updated>2026-05-06T16:08:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=192&amp;oldid=prev</id>
		<title>Davemark: Davemark moved page Behavior History to Behavior history without leaving a redirect: Capitalization</title>
		<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=192&amp;oldid=prev"/>
		<updated>2021-10-07T13:51:08Z</updated>

		<summary type="html">&lt;p&gt;Davemark moved page &lt;a href=&quot;/manuals/index.php?title=Behavior_History&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Behavior History (page does not exist)&quot;&gt;Behavior History&lt;/a&gt; to &lt;a href=&quot;/manuals/index.php/Behavior_history&quot; title=&quot;Behavior history&quot;&gt;Behavior history&lt;/a&gt; without leaving a redirect: Capitalization&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:51, 7 October 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Davemark</name></author>
	</entry>
	<entry>
		<id>http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=115&amp;oldid=prev</id>
		<title>Davemark: Added header</title>
		<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=115&amp;oldid=prev"/>
		<updated>2021-09-30T15:42:08Z</updated>

		<summary type="html">&lt;p&gt;Added header&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:42, 30 September 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{IAUS Header}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{IAUS Header}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;hr&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Part of Brain}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Concept==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Concept==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Behavior Histories''' keep track of the last time a [[Behavior]] was executed by an agent. This allows for checking the [[Behavior Runtime|runtime]] of the current behavior and the [[Behavior Cooldown|time since the behavior was run]].  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Behavior Histories''' keep track of the last time a [[Behavior]] was executed by an agent. This allows for checking the [[Behavior Runtime|runtime]] of the current behavior and the [[Behavior Cooldown|time since the behavior was run]].  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davemark</name></author>
	</entry>
	<entry>
		<id>http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=112&amp;oldid=prev</id>
		<title>Davemark: Added header</title>
		<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=112&amp;oldid=prev"/>
		<updated>2021-09-30T15:40:16Z</updated>

		<summary type="html">&lt;p&gt;Added header&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:40, 30 September 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{IAUS Header}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Concept==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Concept==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Behavior Histories''' keep track of the last time a [[Behavior]] was executed by an agent. This allows for checking the [[Behavior Runtime|runtime]] of the current behavior and the [[Behavior Cooldown|time since the behavior was run]].  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Behavior Histories''' keep track of the last time a [[Behavior]] was executed by an agent. This allows for checking the [[Behavior Runtime|runtime]] of the current behavior and the [[Behavior Cooldown|time since the behavior was run]].  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davemark</name></author>
	</entry>
	<entry>
		<id>http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=111&amp;oldid=prev</id>
		<title>Davemark: /* Code */</title>
		<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=111&amp;oldid=prev"/>
		<updated>2021-09-30T15:38:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:38, 30 September 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l28&quot;&gt;Line 28:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 28:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Getting the last time from an entry&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Getting the last time from an entry&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Cleaning the history based on an expiry time&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Cleaning the history based on an expiry time&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Cleaning the histories is called from the iteration of the [[Think Cycle|think cycle]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Cleaning the histories is called from the iteration of the [[Think Cycle&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;#Processing Histories&lt;/ins&gt;|think cycle]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davemark</name></author>
	</entry>
	<entry>
		<id>http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=110&amp;oldid=prev</id>
		<title>Davemark: Created page with &quot;==Concept== '''Behavior Histories''' keep track of the last time a Behavior was executed by an agent. This allows for checking the runtime of the curr...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.gameai.com/manuals/index.php?title=Behavior_history&amp;diff=110&amp;oldid=prev"/>
		<updated>2021-09-30T15:37:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Concept== &amp;#039;&amp;#039;&amp;#039;Behavior Histories&amp;#039;&amp;#039;&amp;#039; keep track of the last time a &lt;a href=&quot;/manuals/index.php/Behavior&quot; title=&quot;Behavior&quot;&gt;Behavior&lt;/a&gt; was executed by an agent. This allows for checking the &lt;a href=&quot;/manuals/index.php?title=Behavior_Runtime&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Behavior Runtime (page does not exist)&quot;&gt;runtime&lt;/a&gt; of the curr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Concept==&lt;br /&gt;
'''Behavior Histories''' keep track of the last time a [[Behavior]] was executed by an agent. This allows for checking the [[Behavior Runtime|runtime]] of the current behavior and the [[Behavior Cooldown|time since the behavior was run]]. &lt;br /&gt;
&lt;br /&gt;
This is also tracked for [[Behavior Type|behavior types]] as well so that one can tell when a ''type'' was done regardless of the specific behavior that called it. For example, &amp;quot;when was the last time I did a MoveToTarget?&amp;quot; can be checked even though there might be dozens of different behaviors that call &amp;quot;MoveToTarget&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Additionally, it keeps track of [[Context]] times so that information can be accessed on when a particular behavior was run with a particular [[target]]. This allows the same behavior to be run without repeating it at a particular target. One example would be waving at a variety of passing villagers but not at the same villager on a repeated basis.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
For readability of code, the various maps and their components are kept in typedefs.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
	typedef std::unordered_map&amp;lt;unsigned int, float&amp;gt; BehaviorHistoryMap;&lt;br /&gt;
	typedef std::pair&amp;lt;unsigned int, float&amp;gt; BehaviorHistoryIdAndTime;&lt;br /&gt;
&lt;br /&gt;
	typedef std::unordered_map&amp;lt;ContextEntry, float&amp;gt; ContextHistoryMap;&lt;br /&gt;
	typedef std::pair&amp;lt;ContextEntry, float&amp;gt; ContextHistoryIdAndTime;&lt;br /&gt;
&lt;br /&gt;
	typedef std::unordered_map&amp;lt;BehaviorType, float&amp;gt; BehaviorTypeHistoryMap;&lt;br /&gt;
	typedef std::pair&amp;lt;BehaviorType, float&amp;gt; BehaviorTypeIdAndTime;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
The actual objects are in the member variables in [[Brain]]:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
	//////////////////////////////////////////////////////////////////////////&lt;br /&gt;
	// History Tracking&lt;br /&gt;
	BehaviorHistoryMap behaviorHistory;		// History of recent behaviors I have performed (no context)&lt;br /&gt;
	ContextHistoryMap contextHistory;		// History of recent decisions I have performed (incl. behavior and context)&lt;br /&gt;
	BehaviorTypeHistoryMap behaviorTypeHistory;	// History of recent behaviors I have performed by type only&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Each of the maps has functions for:&lt;br /&gt;
* Storing an entry&lt;br /&gt;
* Getting the last time from an entry&lt;br /&gt;
* Cleaning the history based on an expiry time&lt;br /&gt;
Cleaning the histories is called from the iteration of the [[Think Cycle|think cycle]]&lt;/div&gt;</summary>
		<author><name>Davemark</name></author>
	</entry>
</feed>