<?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>AI | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/ai/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Sun, 27 Dec 2020 16:08:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>AI | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Some thoughts about game AI</title>
		<link>https://learncgames.com/some-thoughts-about-game-ai/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-thoughts-about-game-ai</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 27 Dec 2020 00:00:29 +0000</pubDate>
				<category><![CDATA[design]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[empire]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2189</guid>

					<description><![CDATA[<p>When I say AI, I mean control logic for computer played units in a game, not Ai as in Machine Learning or Artificial Intelligence. For instance in the Empire type game, that I started (On the Games source link) which has ships and units fighting on land and sea, capturing cities and building new units. [&#8230;]</p>
The post <a href="https://learncgames.com/some-thoughts-about-game-ai/">Some thoughts about game AI</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:292,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/dimitrisvetsikas1969-1857980\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3786392&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:293,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3786392&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 13:40:36&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-11 07:06:18&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-16 23:19:52&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-22 05:24:19&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-06 13:24:27&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-12 10:07:11&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-17 13:33:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-25 21:47:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-02 23:47:17&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-02 23:47:17&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2192" aria-describedby="caption-attachment-2192" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2192" src="https://learncgames.com/wp-content/uploads/2020/12/military-3786392_640-300x200.jpg" alt="Military" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2020/12/military-3786392_640-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2020/12/military-3786392_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2192" class="wp-caption-text">Image by <a href="https://pixabay.com/users/dimitrisvetsikas1969-1857980/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3786392">Dimitris Vetsikas</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3786392">Pixabay</a></figcaption></figure>
<p>When I say AI, I mean control logic for computer played units in a game, not Ai as in Machine Learning or Artificial Intelligence. For instance in the Empire type game, that I started (On the <strong>Games source</strong> link) which has ships and units fighting on land and sea, capturing cities and building new units.</p>
<p>An AI for an Empire type game has a lot of logic to be implemented. I thought about this quite a bit and came up with a task based Ai system. A neutral city is spotted by an exploring ship. If its a transport with armour on infantry then it just attacks the city and hopefully captures it.</p>
<p>If not a task is created. This comprises a number of steps.</p>
<ol>
<li>Locate units nearest to the city that aren&#8217;t allocated to the task.</li>
<li>If the units are on the same continent then just send them to attack the city.</li>
<li>If not Locate the nearest transport and send it to rendezvous with the units at the nearest point to them. Load the units.</li>
<li>If there aren&#8217;t any units free then locate the nearest friendly city that&#8217;s not tasked with anything and task it to build the units.</li>
<li>If there&#8217;s no transport, have the city build a transport after building the armour/infantry units.</li>
</ol>
<p>That&#8217;s just one for task but what if a friendly city is threatened and the tasked units are the nearest. Care has to be taken so that units aren&#8217;t flip flopped, getting orders one turn then being pulled away three turns later to a different task.</p>
<p>Each task should be given a time-to-live (say 30 turns), long enough to acquire the resources (units it needs) to do the job and reach the target. The rule then is no diverting units on a task unless a dire emergency (like threatening one of its cities) and those are the nearest.</p>
<p>There&#8217;s nothing worse than allocating units to a task then seeing enemy units sail right past unopposed. Writing code to deal with different situations and priorities is not an easy task</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/some-thoughts-about-game-ai/">Some thoughts about game AI</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2189</post-id>	</item>
	</channel>
</rss>
