<?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>Master Baboon &#187; admin</title>
	<atom:link href="http://www.masterbaboon.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.masterbaboon.com</link>
	<description>The sea of the simulation</description>
	<lastBuildDate>Mon, 14 Nov 2011 08:27:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Warning: time sink! Or: the latest Google AI challenge</title>
		<link>http://www.masterbaboon.com/2011/11/warning-time-sink-or-the-latest-google-ai-challenge/</link>
		<comments>http://www.masterbaboon.com/2011/11/warning-time-sink-or-the-latest-google-ai-challenge/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 08:38:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=559</guid>
		<description><![CDATA[It&#8217;s that time of the year again&#8230; the word spreads, I download it, and my nights fly by. It&#8217;s time for the new Google AI Challenge: http://aichallenge.org/ ! This time we will be writing multi-agent systems, as we program cyber-ant-colonies fighting against each other for bread crumbs.]]></description>
			<content:encoded><![CDATA[<blockquote><p>It&#8217;s that time of the year again&#8230; the word spreads, I download it, and my nights fly by. It&#8217;s time for the new <strong>Google AI Challenge</strong>: <a href="http://aichallenge.org/">http://aichallenge.org/</a> ! This time we will be writing multi-agent systems, as we program cyber-ant-colonies fighting against each other for bread crumbs.</p>
<div id="attachment_560" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.masterbaboon.com/wp-content/uploads/2011/11/GoogleAIChallenge_ants.png"><img class="size-medium wp-image-560" title="AI challenge screenshot: ants!" src="http://www.masterbaboon.com/wp-content/uploads/2011/11/GoogleAIChallenge_ants-300x289.png" alt="" width="300" height="289" /></a><p class="wp-caption-text">The colored dots are ants of different colonies. The black dots are obstacles. The barely visible brown-ish dots are food.</p></div></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/11/warning-time-sink-or-the-latest-google-ai-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The road to javascript</title>
		<link>http://www.masterbaboon.com/2011/06/the-road-to-javascript/</link>
		<comments>http://www.masterbaboon.com/2011/06/the-road-to-javascript/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 13:06:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[games]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=547</guid>
		<description><![CDATA[I wanted to learn javascript and wrote a small game with an old school look using textareas, that I&#8217;m glad to share: Writing javascript is quite intuitive for a Python developer, even though I&#8217;m sure that there are many idioms and tricks that I did not know about (and the code I wrote is the [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to learn javascript and wrote a <a href="http://www.masterbaboon.com/brum/" target="_blank">small game</a> with an old school look using textareas, that I&#8217;m glad to share:</p>
<div id="attachment_548" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.masterbaboon.com/brum/"><img class="size-medium wp-image-548" title="brum_screenshot" src="http://www.masterbaboon.com/wp-content/uploads/2011/06/brum_screenshot-300x300.jpg" alt="A screenshot of the game" width="300" height="300" /></a><p class="wp-caption-text">A screenshot of the game</p></div>
<p>Writing javascript is quite intuitive for a Python developer, even though I&#8217;m sure that there are many idioms and tricks that I did not know about (and the code I wrote is the stream-of-thought kind).  I&#8217;m somewhat disappointed as I thought javascript would be more standard across browsers, but there remain important differences, for example in the way Firefox and IE handle ranges in textarea.</p>
<p>I haven&#8217;t tried the game on Safari or Opera, please let me know if it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/06/the-road-to-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Games with extensible AI</title>
		<link>http://www.masterbaboon.com/2011/06/games-with-extensible-ai/</link>
		<comments>http://www.masterbaboon.com/2011/06/games-with-extensible-ai/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 00:01:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=501</guid>
		<description><![CDATA[Some computer games offer the possibility to extend their Artificial Intelligence with external scripts, or are explicitly designed to be played by bots. Such games are a great resource to develop, test, and teach AI algorithms. I have been looking for a list of this kind of games, but could find very little information, often [...]]]></description>
			<content:encoded><![CDATA[<p>Some computer games offer the possibility to extend their Artificial Intelligence with external scripts, or are explicitly designed to be played by bots. Such games are a great resource to develop, test, and teach AI algorithms.</p>
<p>I have been looking for a list of this kind of games, but could find very little information, often outdated. This is my own, annotated list; let me know if I missed something, and I&#8217;ll make amend. I included only decently active projects:</p>
<p><strong>Games for bots:</strong></p>
<ol>
<li><strong><a href="http://robocode.sourceforge.net/" target="_blank">Robocode</a> (Java, .NET)</strong>: AI bots control tanks equipped with cannon and radar on an square arena. A game with a long tradition, descending from the classic AI games <a href="http://en.wikipedia.org/wiki/RobotWar" target="_blank">RobotWar </a>(1981) and <a href="http://en.wikipedia.org/wiki/Crobots" target="_blank">crobots </a>(1985). This is a very active project, with tournaments organized regularly all over the world. The strategical possibilities are quite limited, though.</li>
<li><strong><a href="http://csclub.uwaterloo.ca/contest/">Tron</a> challenge (any language)</strong>: This is the first AI competition organized by the <a href="http://csclub.uwaterloo.ca/" target="_blank">University of Waterloo Computer Science Club</a> and sponsored by Google. The AIs control the &#8220;snakes&#8221; in a variant of the popular game <a href="http://en.wikipedia.org/wiki/Snake_%28video_game%29">Snake</a> (or <a href="http://en.wikipedia.org/wiki/Nibbles_%28video_game%29">Nibbles</a>, of QBasic fame) on a number of boards with symmetric walls. Although the competition is closed, the code is open source and perfectly usable. A nice game, but there seems to be one dominating strategy: using minimax. Entries in the competition differ in their cleverness in coming up with various approximations to prune down the huge tree of possible  moves, and in handling the endgame.</li>
<li><strong><a href="http://ai-contest.com/" target="_blank">Planet Wars</a> challenge (any language)</strong>: Second AI competition, again organized by the <a href="http://csclub.uwaterloo.ca/" target="_blank">University of Waterloo CS Club</a>. The inspiration is the galactic conquer game <a href="http://www.galcon.com/games/?action=game&amp;name=igalcon" target="_blank">Galcon</a>. Bots controls fleets of spaceships to control planets for resources. Unlike the first competition, the optimal strategy is far from obvious, and the game offers a lot of space for experimenting with different approaches. Not as visually fun as other games, though.</li>
<li><strong><a href="http://inst.eecs.berkeley.edu/~cs188/pacman/projects/contest/contest.html">PacMan capture the flag</a> (Python)</strong>: The CS department at Berkeley offers a very popular <a href="http://inst.eecs.berkeley.edu/~cs188/sp11/information.html" target="_blank">Artificial Intelligence course</a> that requires students to <a href="http://inst.eecs.berkeley.edu/~cs188/pacman/pacman.html" target="_blank">code up classical AI algorithms</a> to control agents in a PacMan-like environment. The course concludes with a <a href="http://inst.eecs.berkeley.edu/~cs188/pacman/projects/contest/contest.html" target="_blank">tournament </a>in which PacMan agents compete to eat each other&#8217;s dots. The game is extremely fun as I wrote about <a href="http://www.masterbaboon.com/2009/09/pacman-capture-the-flag-a-fun-game-for-artificial-intelligence-development-and-education/" target="_self">in</a> <a href="http://www.masterbaboon.com/2010/09/tracking-down-the-enemy/" target="_self">previous</a> <a href="http://www.masterbaboon.com/2011/01/tracking-down-the-enemy-2/">posts</a>. The code is <a href="http://inst.eecs.berkeley.edu/~cs188/pacman/projects/contest/contest.html" target="_blank">available online</a> (although somewhat messy). Unfortunately (but understandably, since the game is used in a course), the authors don&#8217;t want the code of developed agents to leak online.</li>
<li><strong><a href="http://gridsoccer.codeplex.com/" target="_blank">Grid-Soccer</a> (Mono, .NET):</strong> This is a multi-agent soccer-like game played on a grid board. I haven&#8217;t tried this one yet&#8230; According to the authors, it was originally conceived as a testbed for multi-agent reinforcement learning algorithms.</li>
</ol>
<p><strong>Scriptable games</strong> (games that expose an interface for external clients):</p>
<ol>
<li><strong><a href="http://en.wikipedia.org/wiki/StarCraft:_Brood_War" target="_blank">Starcraft Brood War</a> (any language): </strong>This is your one chance at writing AI bots for a commercial game! <img src='http://www.masterbaboon.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Starcraft <a href="http://code.google.com/p/bwapi/" target="_blank">has been hacked</a> to allow to control any aspect of the game through a user-written client (building construction, units movement, the full monty). Since 2010 there have been a few <a href="http://code.google.com/p/bwapi/wiki/Competitions#AIIDE_2011" target="_blank">AI competitions</a> open to the public (two of them still accepting entries!). Here&#8217;s a video from last year&#8217;s <a href="http://eis.ucsc.edu/StarCraftAICompetition" target="_blank">AIIDE tournament</a>:
<p><iframe width="544" height="327" src="http://www.youtube.com/embed/2rqpz2GU9GU" frameborder="0" allowfullscreen></iframe></li>
<li><strong><a href="http://xblast.sourceforge.net/" target="_blank">XBlast (potentially any):</a> </strong>A free version of <a href="http://en.wikipedia.org/wiki/Bomberman" target="_blank">Bomberman</a>. The game has not been used to develop AI agents&#8230; yet. It is built with a server-client architecture and it&#8217;s begging to get bots running on it.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/06/games-with-extensible-ai/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fight the machine at NYT</title>
		<link>http://www.masterbaboon.com/2011/03/fight-the-machine-at-nyt/</link>
		<comments>http://www.masterbaboon.com/2011/03/fight-the-machine-at-nyt/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 22:41:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=496</guid>
		<description><![CDATA[Perhaps inspired by the victory of the artificial brain Watson against humanity, the New York Times is offering today an interactive feature that allows to play a series of Rock-Paper-Scissors games against the computer. The prediction algorithm seems to be a simple Bayesian estimator like the one I implemented for the Karate A.I. game. The [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps inspired by the <a href="http://en.wikipedia.org/wiki/Watson_%28artificial_intelligence_software%29" target="_blank">victory of the artificial brain Watson against humanity</a>, the New York Times is offering today an interactive feature that allows to play a series of <a href="http://www.nytimes.com/interactive/science/rock-paper-scissors.html" target="_blank">Rock-Paper-Scissors games</a> against the computer.</p>
<p>The prediction algorithm seems to be a simple Bayesian estimator like the one I implemented for the <a href="http://www.masterbaboon.com/2009/05/my-ai-reads-your-mind-and-kicks-your-ass-part-2/">Karate A.I. game</a>. The interesting twist is that in &#8220;Veteran mode&#8221; the AI will make use its interaction with previous users to define a prior over possible move sequences. It surely works against me&#8230;</p>
<p style="text-align: center;"><a href="http://www.nytimes.com/interactive/science/rock-paper-scissors.html"><img class="aligncenter" title="NYT man vs machine" src="http://graphics8.nytimes.com/images/2011/03/04/science/rock-paper-scissors.190.jpg" alt="" width="190" height="126" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/03/fight-the-machine-at-nyt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Join us at the Advanced Scientific Programming in Python summer school in Scotland</title>
		<link>http://www.masterbaboon.com/2011/03/join-us-at-the-advanced-scientific-programming-in-python-summer-school-in-scotland/</link>
		<comments>http://www.masterbaboon.com/2011/03/join-us-at-the-advanced-scientific-programming-in-python-summer-school-in-scotland/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 17:31:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[PacMan capture-the-flag]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=489</guid>
		<description><![CDATA[If you&#8217;re interested in learning more about scientific programming in Python, and want to compete in a Pacman capture-the-flag tournament, join us for the next Advanced Scientific Programming in Python summer school in St. Andrew, UK! The faculty line-up includes developers of well-known scientific libraries for Python (e.g., Francesc Alted of PyTables fame). The program [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re interested in learning more about scientific programming in Python, and want to compete in a <a href="http://www.masterbaboon.com/2009/09/pacman-capture-the-flag-a-fun-game-for-artificial-intelligence-development-and-education/">Pacman</a> <a href="http://www.masterbaboon.com/2010/09/tracking-down-the-enemy/">capture-the-flag</a> <a href="http://www.masterbaboon.com/2011/01/tracking-down-the-enemy-2/">tournament</a>, join us for the next <a href="https://python.g-node.org/wiki/">Advanced Scientific Programming in Python</a> summer school in St. Andrew, UK!</p>
<p>The faculty line-up includes developers of well-known scientific libraries for Python (e.g., <a href="http://www.pytables.org/moin/FrancescAlted">Francesc Alted</a> of <a href="http://www.pytables.org/moin">PyTables</a> fame). The program covers advanced topics in numerical programming (advanced NumPy, Cython, parallel applications, data serialization, &#8230;) and modern techniques for writing robust, efficient code (agile programming, test driven development, version control, optimization techniques, &#8230;). Most of all, the school is a great opportunity to meet like-minded people and have fun writing Python code together! Participation is free of charge, and you can <a href="https://python.g-node.org/wiki/">apply online</a>.</p>
<p>You can see a few picture from previous summer schools on our<a href="http://www.facebook.com/group.php?gid=145875921776" target="_blank"> Facebook group</a>.</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 372px"><img class=" " title="Summer school in Berlin" src="http://a5.sphotos.ak.fbcdn.net/hphotos-ak-snc1/6830_1201852400426_1052055109_608170_5509474_n.jpg" alt="Summer school participants in Berlin, working hard on their PacMan agents." width="362" height="243" /><p class="wp-caption-text">Summer school participants in Berlin, working hard on their PacMan agents.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/03/join-us-at-the-advanced-scientific-programming-in-python-summer-school-in-scotland/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking down the enemy (2)</title>
		<link>http://www.masterbaboon.com/2011/01/tracking-down-the-enemy-2/</link>
		<comments>http://www.masterbaboon.com/2011/01/tracking-down-the-enemy-2/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 23:39:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[PacMan capture-the-flag]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[PacMan]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=456</guid>
		<description><![CDATA[I never got the chance to show a working agent based on the Bayesian estimator for the enemy position in the PacMan capture-the-flag game. In the previous PacMan post, I wrote about merging a model of agent movements with the noisy measurements returned by the game to track the enemy agents across the maze. Clearly, [...]]]></description>
			<content:encoded><![CDATA[<p>I never got the chance to show a working agent based on the Bayesian estimator for the enemy position in the PacMan capture-the-flag game. In the <a href="http://www.masterbaboon.com/2010/09/tracking-down-the-enemy/" target="_self">previous PacMan post</a>, I wrote about merging a model of agent movements with the noisy measurements returned by the game to track the enemy agents across the maze. Clearly, this information can give you an edge when planning an attack (to avoid ghosts) or when defending (to intercept the PacMen).</p>
<p>For  the traditional faculty-vs-students tournament at the <a href="https://portal.g-node.org/python-autumnschool/" target="_blank">G-Node scientific programming summer school</a> this year, I wrote a PacMan team made by a simple attacker, and a more sophisticated defender that tries to intercept and devour enemy agents.</p>
<p>Both agents plan their movements using a shortest-path algorithm on a weighted graph: before the start of the game, the maze is transformed in a graph, where nodes are the maze tiles, and edges connect adjacent tiles. Weights along the edges are adjusted according to the estimated position of the agents:</p>
<ul>
<li>Weights on edges close to an enemy ghost are increased (starting value is proportional to the probability of the enemy being there, and falls off exponentially with distance)</li>
<li>Weights on edges close to an enemy PacMan are decreased</li>
<li>Weights on edges close to a friendly agent are increased</li>
</ul>
<p>An agent navigating on such a maze will tend to avoid ghosts, chase PacMen, and cover parts of the maze far from other friendly agents. My attacker does little else than updating the weights of the graph at every turn, and move toward the closest food dot.</p>
<p>On the other hand, defending is quite difficult in this game, so I needed a more sophisticated strategy. While the enemy is still a ghost in its own part of the maze, the defender moves toward the closest enemy agent (its estimated position, that is). When the enemy is a PacMan in the friendly half, the chase is on! Since ghosts and PacMen move at the same speed, it would be pointless to just follow it around, one needs to catch them from the front&#8230; Once more, the solution was to modify the weights of the maze graph, making weights behind the enemy (i.e., opposite to its direction of motion) very high, and lowering the edges in front of it.</p>
<p>The combination of estimator and the weighted graph strategy can be quite entertaining:</p>
<p><iframe title="YouTube video player" type="text/html" width="544" height="327" src="http://www.youtube.com/embed/YM-rQJPL16o" frameborder="0" allowFullScreen></iframe></p>
<p>Sometimes the defender only needs to guard the border to scare the opponent shitless:</p>
<p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="544" height="327" src="http://www.youtube.com/embed/1ciCtwW14RY" frameborder="0" allowFullScreen></iframe></p>
<p>Another useful thing to keep in mind for the future: it is better to base strategies on soft constraints (weighted graphs, probabilities). Setting hard, deterministic rules tends to get you stuck in loops. Soft constraints and some randomness give you more flexibility when you need it but are otherwise just as good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2011/01/tracking-down-the-enemy-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Planet Wars &#8211; Google AI Challenge</title>
		<link>http://www.masterbaboon.com/2010/09/planet-wars-google-ai-challenge/</link>
		<comments>http://www.masterbaboon.com/2010/09/planet-wars-google-ai-challenge/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 21:09:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[Planet Wars]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=340</guid>
		<description><![CDATA[The Computer Science of the University of Waterloo is organizing its second Google AI Challenge. The challenge is a competition between computer programs that control the artificial intelligence of the players in a video game. This time, the game is set in space, and features a symmetric configuration of planets, each containing a fleet of [...]]]></description>
			<content:encoded><![CDATA[<p>The Computer Science of the University of Waterloo is organizing its second <a href="http://ai-contest.com/index.php">Google AI Challenge</a>. The challenge is a competition between computer programs that control the artificial intelligence of the players in a video game.</p>
<p>This time, the game is set in space, and features a symmetric configuration of planets, each containing a fleet of defending spaceships. Each turn, new ships are created, with larger planets creating more ships. At the beginning of the game, each player controls one of the planets and a hundred ships; the AIs issue orders to the ships to send them to conquer planets by outnumbering the local defense. The goal of the game is, of course, to eliminate all of the enemy forces.</p>
<p>This video shows an example game between my first AI (green) playing against DualBot (red), one of the bots included in the starter package; the number floating around represent the fleets commanded by the AIs:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/A0ATZoeWV48?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/A0ATZoeWV48?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The competition is open to everybody, and it is possible to write the AI in basically any programming language. If you plan to use Python, I recommend not using the official starter package, which is un-pythonic and not very sophisticate, but rather <a href="http://github.com/ulope/planetwars-python-kit">this un-official client</a>. The alternative client offers in particular the possibility to log debug information to a local file.</p>
<p>Also, it can be quite frustrating to wait for the official server to match you with some other program, which can take up to an hour. There is an <a href="http://www.benzedrine.cx/planetwars/">alternative server</a> that lets you play with another opponent straight away.</p>
<p>The submission period ends November 27, good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2010/09/planet-wars-google-ai-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>github repository for masterbaboon stuff</title>
		<link>http://www.masterbaboon.com/2010/08/github-repository-for-masterbaboon-stuff/</link>
		<comments>http://www.masterbaboon.com/2010/08/github-repository-for-masterbaboon-stuff/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 16:53:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=289</guid>
		<description><![CDATA[I set up a github repository for the source code and other material published here. It&#8217;s a much more convenient way to share source code than uploading archive files. You can find it at http://github.com/pberkes/masterbaboon . Enjoy!]]></description>
			<content:encoded><![CDATA[<p>I set up a github repository for the source code and other material published here. It&#8217;s a much more convenient way to share source code than uploading archive files.</p>
<p>You can find it at <a href="http://github.com/pberkes/masterbaboon" target="_blank">http://github.com/pberkes/masterbaboon</a> . Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2010/08/github-repository-for-masterbaboon-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My AI reads your mind &#8212; Extensions (part 3)</title>
		<link>http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/</link>
		<comments>http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 13:52:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=232</guid>
		<description><![CDATA[In the previous two posts I showed how to make use of decision theory to write a game AI that forms a model of its opponent and adapts its strategy accordingly. The AI could be improved in several ways: The most obvious improvement would be to build a better model of the opponent. In the [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous two posts I showed how to make use of decision theory to write a game AI that <a href="http://www.masterbaboon.com/2009/04/my-ai-can-read-your-mind-part-1/" target="_self">forms a model of its opponent</a> and <a href="http://www.masterbaboon.com/2009/05/my-ai-reads-your-mind-and-kicks-your-ass-part-2/" target="_self">adapts its strategy</a> accordingly.</p>
<p>The AI could be improved in several ways:</p>
<ul>
<li>The most obvious improvement would be to build a <strong>better model of the opponent</strong>. In the Karate game I used a 2nd order Markov model, i.e., I assumed that the next move of the player only depends on his previous two moves. It is of course possible to use an <strong>higher-order model</strong>, that would keep track of three or more past moves. However, a long history means a much larger number of parameters to estimate, so that it will take much longer for the AI to have a reasonable estimate of the player&#8217;s behavior. An easy workaround would be to collect higher-order statistics, but only use them when enough data is available; this however would still fail if the player decides to adopt a new strategy. One could also use another class of models, like, for example a <strong>recurrent neural network</strong>. I prefer not to use neural networks, first of all to avoid the usual voodoo of choosing parameters like learning rate, network architecture, etc., and second because they work in a black-box fashion, which makes it difficult to extend them in principled ways, as for example suggested below.</li>
<li>When the game is started, the player statistics are blank, in the sense that all the player&#8217;s moves are considered equally likely. This is our initial <strong>prior probability</strong> for the opponent&#8217;s moves. However, it is probable that humans have common biases in the kind of action sequences they choose. One could adapt the game to allow it to learn this biases over many games with different players, and use them as the initial prior, thereby improving the initial phase of the game.</li>
<li>A related point is that at the moment I do not take into account the <strong>uncertainty</strong> about the player&#8217;s move estimation. At the start of the game the AI has only a few examples on which to base its prediction of the next move, and it should take this into account when making decisions. The formal way to capture this uncertainty is to define an <strong>hyperprior</strong> on the transition probabilities, and then integrate over it when predicting the next move: so far, the transition probability is given by a matrix, p(n(t+1) | n(t)) = N_{n(t),n(t+1)}, where N is a matrix and for simplicity I&#8217;m only considering a first order Markov model. N is considered to be a constant at every time point; in reality, N is also a random variable that is being estimated from the player&#8217;s move. It is thus only natural to put a prior on N itself, P(N) (e.g., a Dirichlet distribution for every row of the matrix). The improved prediction, which takes into account our uncertainty about N is given by <strong>p(n(t+1) | n(t)) = integral over N of p(n(t+1) | n(t), N) p(N)</strong> .</li>
<li>In the karate game, the AI tries to maximize its score by picking the action with the highest expected score. Another strategy would be to choose every action with a probability related to the score, for example using p(choosing action a) to be proportional to exp(beta * score of a), where beta is a constant that controls the &#8220;softness&#8221; of the decision: for beta=0, all actions are chosen with the same probability; for large betas, only the action with largest score is chosen. This seems to be closer to the way human takes decision, the so called <strong>probability matching</strong> rule. This strategy is suboptimal if the second order Markov model is the real model of the opponent, but since it is not, it appears to perform better in practice as the AI becomes less predictable (I updated the Karate game in the previous post to do probability matching).</li>
<li>A major improvement to the AI would be to take into account the so-called <strong>theory of mind</strong>, i.e., the fact that while the AI is building a model of the player, the player is doing the same for the AI, and trying to maximize his own score. Taking this aspect into account is quite complex, as one falls rapidly into a deep I-know-that-you-know-that-I-know kind of reasoning. Managing to do so, however, is likely to be highly rewarding for the player&#8217;s experience of the game: several studies have shown how humans activate areas of the brain that are associated with theory-of-mind when playing against a human opponent, but fail to do so against a computer (see Gallagher and Frith, <em>Functional imaging of ‘theory of mind’</em>, Trends in Cognitive Sciences, 7(2), 2003, for a review). It is thus possible that by writing computer programs that make use of theory of mind themselves, those centers would become engaged, giving the player the impression of playing against a human opponent.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced math functions for AS3</title>
		<link>http://www.masterbaboon.com/2009/02/advanced-math-functions-for-as3/</link>
		<comments>http://www.masterbaboon.com/2009/02/advanced-math-functions-for-as3/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 22:29:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[AdvancedMath]]></category>

		<guid isPermaLink="false">http://www.masterbaboon.com/?p=171</guid>
		<description><![CDATA[Did you ever need to sample from a Dirichlet distribution in Actionscript 3.0? What about computing a value of the Gamma function? Probably not In case you did, I wrote a class with a few math methods: a function to sample from multinomial distributions; this is useful if you need to choose randomly from a [...]]]></description>
			<content:encoded><![CDATA[<p>Did you ever need to sample from a Dirichlet distribution in Actionscript 3.0? What about computing a value of the Gamma function? Probably not <img src='http://www.masterbaboon.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  In case you did, I wrote a class with a few math methods:</p>
<ul>
<li>a function to sample from multinomial distributions; this is useful if you need to choose randomly from a set of elements, each with a different probability;</li>
<li>functions to draw samples from the Dirichlet and Gamma distribution;</li>
<li>the Gamma function</li>
<li>a factorial function that works even for large values (using the identity n! = Gamma(n+1))</li>
<li>other utility functions, e.g. to compute mean and variance of an array, or add two arrays together</li>
</ul>
<p>You can <a href="http://www.masterbaboon.com/flashes/advancedmath.zip">download the AdvancedMath class here</a>, it includes <a href="http://www.asunit.org/" target="_blank">AsUnit tests</a>.</p>
<p>This is an example of how to use the AdvancedMath class to simulate a rigged dice: the code below throws the dice 1000 times, and keeps a count of how many times one gets the different faces.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>masterbaboon<span style="color: #000066; font-weight: bold;">.</span>AdvancedMath<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">// probability of the faces; 6 is about twice more likely to appear</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0.14</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.14</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.14</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.14</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.14</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900; font-style: italic;">// count the number of times a face appears</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> count<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = AdvancedMath<span style="color: #000066; font-weight: bold;">.</span>zeros<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900; font-style: italic;">// throw dice 1000 times</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> face<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; face = AdvancedMath<span style="color: #000066; font-weight: bold;">.</span>sampleMultinomial<span style="color: #000000;">&#40;</span>p<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; count<span style="color: #000000;">&#91;</span>face<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">++;</span><br />
<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #009900; font-style: italic;">// show how many times we got which face</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>count<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5929969675637192";
google_ad_slot = "7572213318";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masterbaboon.com/2009/02/advanced-math-functions-for-as3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

