<?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>monte carlo | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/monte-carlo/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>Fri, 18 Sep 2020 16:02:32 +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>monte carlo | 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>How to measure the area of a circle</title>
		<link>https://learncgames.com/how-to-measure-the-area-of-a-circle/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-measure-the-area-of-a-circle</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 19 Sep 2020 23:00:04 +0000</pubDate>
				<category><![CDATA[Techniques]]></category>
		<category><![CDATA[monte carlo]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1421</guid>

					<description><![CDATA[<p>Well if you remember maths (or math for US readers), you&#8217;ll know that the area of a circle is pi X r X r where r is the radius and pi is that 3.14159 number. But what if you are given a weird shape instead of a circle? Like some of those in the picture. [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-measure-the-area-of-a-circle/">How to measure the area of a circle</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignleft size-medium wp-image-1422" src="https://learncgames.com/wp-content/uploads/2020/09/oddshapes-300x186.png" alt="Odd Shapes" width="300" height="186" srcset="https://learncgames.com/wp-content/uploads/2020/09/oddshapes-300x186.png 300w, https://learncgames.com/wp-content/uploads/2020/09/oddshapes.png 528w" sizes="(max-width: 300px) 100vw, 300px" />Well if you remember maths (<em>or math for US readers</em>), you&#8217;ll know that the area of a circle is <strong>pi X r X r</strong> where r is the radius and pi is that 3.14159 number.</p>
<p>But what if you are given a weird shape instead of a circle? Like some of those in the picture.</p>
<p>There&#8217;s a method called Monte Carlo because of the casino there. In effect you simulate throwing darts at the shape (<em>say printed out and stuck on the wall</em>). You throw thousands or millions of darts and count how many hit the particular shape and how many darts were thrown in total. You only count those that hit the rectangular paper; those that miss it don&#8217;t count.</p>
<p>Then you divide the number of hits by the number thrown, multiply it by the width and height of the picture (<em>which is rectangular or square</em>) and that is a close approximation to the area. In more advanced ,maths/math, this method is sometimes used to calculate the integral of a function. The integral is the area under the function. Some complicated functions are particularly hard to integrate, so using a Monte Carlo method can solve it for you.</p>
<p>I&#8217;ll publish a C program to run Monte Carlo on an image in a day or two.</p>
<p>An alternative way of measuring the area is by using recursion. I discussed it in this article <a title="Link to article on recursive fill" href="https://learncgames.com/using-recursive-fill-to-count-maps/" target="_blank" rel="nofollow noopener noreferrer">Using recursive fill to count maps</a>.</p>The post <a href="https://learncgames.com/how-to-measure-the-area-of-a-circle/">How to measure the area of a circle</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">1421</post-id>	</item>
	</channel>
</rss>
