<?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>Science of Board Games &#187; Simulations</title>
	<atom:link href="http://www.scienceofboardgames.com/category/simulations/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scienceofboardgames.com</link>
	<description>Rants and raves about board games, cards, randomness, and stuff</description>
	<lastBuildDate>Fri, 30 Apr 2010 23:37:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Future of Board Games?</title>
		<link>http://www.scienceofboardgames.com/2009/10/the-future-of-board-games/</link>
		<comments>http://www.scienceofboardgames.com/2009/10/the-future-of-board-games/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 15:30:18 +0000</pubDate>
		<dc:creator>thursday</dc:creator>
				<category><![CDATA[Simulations]]></category>

		<guid isPermaLink="false">http://www.scienceofboardgames.com/?p=221</guid>
		<description><![CDATA[The video below shows what may be the future of board games: the Microsoft Surface. You can manipulate boards, as well as place physical markers on top of the screen (and the screen will interact with them). This is a proof of concept showing how the Microsoft Surface could be used to play Dungeons and [...]]]></description>
			<content:encoded><![CDATA[<p>The video below shows what may be the future of board games: the Microsoft Surface. You can manipulate boards, as well as place physical markers on top of the screen (and the screen will interact with them).</p>
<p>This is a proof of concept showing how the Microsoft Surface could be used to play Dungeons and Dragons, but it's easy to imagine it being used for a big game like Twilight Imperium.</p>
<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7132858&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7132858&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>
<p><a href="http://vimeo.com/7132858">Surfacescapes Demo Walkthrough</a> from <a href="http://vimeo.com/surfacescapes">Surfacescapes</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienceofboardgames.com/2009/10/the-future-of-board-games/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simulating Board Games: Rejection Sampling</title>
		<link>http://www.scienceofboardgames.com/2009/09/simulating-board-games-rejection-sampling/</link>
		<comments>http://www.scienceofboardgames.com/2009/09/simulating-board-games-rejection-sampling/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:30:29 +0000</pubDate>
		<dc:creator>Christopher Swenson</dc:creator>
				<category><![CDATA[Featured Post]]></category>
		<category><![CDATA[Simulations]]></category>
		<category><![CDATA[monty hall]]></category>
		<category><![CDATA[probability]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.scienceofboardgames.com/?p=154</guid>
		<description><![CDATA[There are a lot of ways to analyse a board game scenario: you can try to work out the values analytically – that is, try to come up with an exact mathematical formula, or you can try to simulate real world scenarios with computer code, and see how often the situation you are looking for [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of ways to analyse a board game scenario: you can try to work out the values analytically – that is, try to come up with an exact mathematical formula, or you can try to simulate real world scenarios with computer code, and see how often the situation you are looking for happens, or somewhere between these two methods.</p>
<p>The most basic technique of simulating a game is called rejection sampling.  That is, you try your best to simulate every possible variable in a game (or in the piece you are studying), and then randomly pick values for the variables and measure the outcomes.  After some amount of time, you just stop, and tabulate the results.</p>
<p>It's called rejection sampling because, typically, you are measuring the likelihood of one particular event happening, and you do this by randomly simulating as above, and throwing away all of the results where the event did not happen.  It's by far the laziest and usually easiest way to measure something in a system such as a board game.</p>
<p>In addition to being the laziest way, it is also good for confirming the results of other types of analysis – it is unlikely for your rejection sampling technique to be wrong, unless the model is bad or the events you are trying to measure are extremely unlikely.</p>
<p>To demonstrate how I use rejection sampling, we can use it to confirm the <a href="http://en.wikipedia.org/wiki/Monty_Hall_problem">Monty Hall</a> riddle.  Basically, you are a contestant on a game show, and are asked to pick on of three doors, behind one of which is a new car that you win if you pick it.  After picking a door, the host then reveals one of the other doors without a car in it, and offers to let you switch your choice.  So, should you switch?  The answer is always yes, though I won't go into details: suffice it to say that it's a non-intuitive probability calculation.  If you switch, you have a 2/3 chance of winning the car, and if you stay the course, you have a 1/3 chance of winning.</p>
<p>The following is a piece of Python code to simulate this using rejection sampling.</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># reproducible results</span>
<span style="color: #dc143c;">random</span>.<span style="color: black;">seed</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1234</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> monty_hall<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
  doors = <span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
  winner = <span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># three doors, only one with a win</span>
&nbsp;
  <span style="color: #dc143c;">random</span>.<span style="color: black;">shuffle</span><span style="color: black;">&#40;</span>winner<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># shuffle the doors</span>
&nbsp;
  mydoor = <span style="color: #dc143c;">random</span>.<span style="color: black;">sample</span><span style="color: black;">&#40;</span>doors, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># pick a random door</span>
  doors.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>mydoor<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># reveal one of the two doors</span>
  revealed = <span style="color: #dc143c;">random</span>.<span style="color: black;">sample</span><span style="color: black;">&#40;</span>doors, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
  doors.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>revealed<span style="color: black;">&#41;</span>
  <span style="color: #808080; font-style: italic;"># sanity check: don't reveal the door with the prize</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> winner<span style="color: black;">&#91;</span>revealed<span style="color: black;">&#93;</span> == <span style="color: #ff4500;">1</span>: revealed, doors = doors<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, <span style="color: black;">&#91;</span>revealed<span style="color: black;">&#93;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># would you like to switch to the other door?</span>
  <span style="color: #808080; font-style: italic;"># ALWAYS ANSWER YES</span>
  mydoor = doors<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;"># switch</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">return</span> winner<span style="color: black;">&#91;</span>mydoor<span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># perform rejection sampling 10,000 times</span>
total = <span style="color: #ff4500;">10000</span>
wins = <span style="color: #ff4500;">0</span>
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span>total<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">if</span> monty_hall<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">1</span>: wins += <span style="color: #ff4500;">1</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Won:&quot;</span>, <span style="color: #ff4500;">100.0</span> * wins / total, <span style="color: #483d8b;">&quot;percent of the time&quot;</span></pre>
<p>Produces the output:</p>
<pre>Won: 66.68 percent of the time</pre>
<p>The code is pretty straightforward as far as Python board game simulation code goes.  There's no odd probability counting going on, no calls to permuted choice functions, no brute force or clever backtracking.  Just simply doing a run and seeing if you win, repeat.</p>
<p>This demonstrates two key principles for board game simulations: you should almost always do some kind of rejection sampling code as a reality check of any other results you come up with, and probabilities are weird and often counter-intuitive, so tread lightly.</p>
<p><a href="http://www.flickr.com/photos/debaird/1337108791/">Photo — Debaird</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scienceofboardgames.com/2009/09/simulating-board-games-rejection-sampling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
