<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The Applied Games Group Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/apg/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/apg/feed.xml</link>
    <description>New stuff directly from Microsoft Research.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:27:30 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Work Experience Student - Max Steele</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/work-experience-student-max-steele</link>
      <pubDate>Thu, 28 Aug 2008 05:38:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/08/28/work-experience-student-max-steele/</guid>
      <description><![CDATA[Last week we&nbsp;enjoyed having&nbsp;Max Steele here for a week of work experience.&nbsp; Max is a...]]></description>
      <content:encoded><![CDATA[<P>Last week we&nbsp;enjoyed having&nbsp;Max Steele here for a week of work experience.&nbsp; Max is a 6th form student, currently studying for his A-levels and hoping to pursue a career in Computer science.&nbsp; Before&nbsp;his time here Max had&nbsp;never&nbsp;done any coding so we thought we would throw him in at the deep end and set him the task of programming a&nbsp;Blackjack game in F#.&nbsp; It was very interesting to teach someone about functional programming from the ground up without them having&nbsp;written an imperative program before.&nbsp; In fact this lack of knowledge might actually have helped, as he was not tempted to fill the code with for loops etc!&nbsp; Here is what Max has to say about&nbsp;his experience in Cambridge.</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><FONT face=Calibri size=3><EM>This week I have been here in The Applied Games Group on work experience over my summer vacation from school. I have currently just completed an AS-level year in Further Mathematics, Philosophy and Economics and intend to apply to university in the coming months for something along the lines of a Maths and Computer Science course. </EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><FONT face=Calibri size=3><EM>When I came into the Group I was put under David Stern’s wing, with no prior experience to any sort of programming whatsoever. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>I was very keen to learn about programming and gain a better understanding of how computers work on the whole. Unfortunately there was no other option other than to be thrown straight into the deep end with a book called ‘Expert F#’, a book that definitely is not for someone in my position. As I tried to read through sections like the introduction of this book and other articles on functional programming I slowly started to grasp loose concepts, despite sometimes understanding only a few words a sentence. Talking with Phillip about how the platforms of computers are compiled helped greatly and although I went home with an aching head each night I am sure a lot of this information clung on to something to recall on in the future.</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><IMG title="The Blackjack player" style="WIDTH: 414px; HEIGHT: 301px" height=417 alt="The Blackjack player" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/11/32/77/maxscreenshot.jpg" original-url="http://blogs.technet.com/photos/apg/images/3113277/original.aspx" width=605 mce_src="http://blogs.technet.com/photos/apg/images/3113277/original.aspx">&nbsp;&nbsp;<IMG title="The code" style="WIDTH: 400px; HEIGHT: 301px" height=313 alt="The code" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/11/32/86/maxcode3.JPG" original-url="http://blogs.technet.com/photos/apg/images/3113286/original.aspx" width=413 mce_src="http://blogs.technet.com/photos/apg/images/3113286/original.aspx"></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><FONT face=Calibri size=3><EM>Luckily, towards the end of my first day I was found an exercise by David to teach take me through some of the basic functions including arrays and lists as well. Progressing from this we decided to try to create a Blackjack game. The aim was to first create the most basic program where the player can play head on against a dealer with set rules to his gameplay. After more than two days full of work and new functions I finally was able to create the most simple of games allowing you to keep score against the dealer as you play. David is due a lot of credit for this work and I am very grateful for the hours of time he put in over the week to help me understand this completely new way of thinking. What was most exciting was to realise that I had learnt enough of this to think on my own and write new functions by myself. After creating the main structure as well as the user interface controlling the player with David, I was able to go on and create almost all of the dealer actions by myself. All of what seemed like unbearable slow progress in learning this code earlier in the week really came together and gave me a great feeling of accomplishment at this point.</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><FONT face=Calibri size=3><EM>As for the future, I am really glad I have been able to enjoy the experience of this week and will definitely continue on with this work in the future at home to create a complete Blackjack game where all actions like “split” and “double down” will be possible. I would lastly like to thank everyone for their help and friendliness both in and outside of work this week and hope that I may meet some of you again one day if I end up in a similar line of work. Enjoy the game!&nbsp; - Max</EM></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt">I have attached&nbsp;Max's code to this post - have fun!</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><FONT face=Calibri size=3>- David Stern</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"><EM><FONT face=Calibri size=3></FONT></EM>&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/5337/00/00/03/11/32/76/Program.fs" original-url="http://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-5337-00-00-03-11-32-76/Program.fs">Program.fs</a></p>]]></content:encoded>
    </item>
    <item>
      <title>TrueSkill in F#</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/trueskill-in-f</link>
      <pubDate>Mon, 16 Jun 2008 00:25:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/06/16/trueskill-in-f/</guid>
      <description><![CDATA[Following the publication of the F# source code for the TrueSkill Through Time paper, we have used...]]></description>
      <content:encoded><![CDATA[<P>Following the <A href="http://blogs.technet.com/apg/archive/2008/04/05/trueskill-through-time.aspx" mce_href="http://blogs.technet.com/apg/archive/2008/04/05/trueskill-through-time.aspx">publication</A> of the <A href="http://research.microsoft.com/fsharp/fsharp.aspx" mce_href="http://research.microsoft.com/fsharp/fsharp.aspx">F#</A> source code for the <A href="http://research.microsoft.com/osa/apg/trueskill.aspx" mce_href="http://research.microsoft.com/osa/apg/trueskill.aspx">TrueSkill</A> Through Time paper, we have used the same inference library code to demonstrate how the original TrueSkill algorithm can be coded. In the attached source code, only the <U>program.fs</U> file is different to the TrueSkill through Time blog post and it builds up the factor graph for an arbitrary N-player game with an arbitrary draw probability. Both these numbers can be entered on the command line when running the resulting sample. We tried to make sure to stay as close as possible to the description on page 3 of the <A href="ftp://ftp.research.microsoft.com/pub/tr/TR-2006-80.pdf" mce_href="ftp://ftp.research.microsoft.com/pub/tr/TR-2006-80.pdf">TrueSkill technical report</A>.</P>
<P>The attached ZIP file contains the entire source code which should compile without problems with <A href="http://research.microsoft.com/research/downloads/Details/7ac148a7-149b-4056-aa06-1e6754efd36f/Details.aspx">F# 1.9.3.14</A>. You can either load the solution in Visual Studio 2008 or simply run build.bat form the command line - in either case you will end up with a <U>trueskill.exe</U> program. </P>
<P><STRONG>Update</STRONG>: Following the release of the <A href="http://msdn.microsoft.com/en-us/fsharp/default.aspx" mce_href="http://msdn.microsoft.com/en-us/fsharp/default.aspx">F# September 2008 CTP</A> we have updated the source code to work with <A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en">F# 1.9.6.2</A>. Also, we added one of the new features of F#, namely units-of-measure, which makes the TrueSkill update invocation calls now read as follows:</P>
<P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">let</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> priorMu = 25.0&lt;SkillPoints&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">let</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> priorSigma = priorMu / 3.0<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">let</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> priorSkills = Array.init noPlayers (</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">fun</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> i </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">-&gt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> Gaussian.Create (priorMu, priorSigma))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; mso-no-proof: yes; mso-bidi-font-size: 10.0pt">let</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"> (posteriorSkills, logZ) = <o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: windowtext; mso-no-proof: yes; mso-bidi-font-size: 10.0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>NPlayerTrueSkillUpdate (0.5*priorSigma, 0.01*priorSigma, drawProb / 100.0) priorSkills<o:p></o:p></SPAN></P>
<P mce_keep="true">Note that one can no longer accidentally pass the variance instead of the standard deviation because the former being of type <FONT face="Courier New">float&lt;SkillPoints^2&gt;<FONT face=Arial>. Try yourself!</FONT> </FONT></P>
<P mce_keep="true"><STRONG>Update 2</STRONG>: We had some feedback from Andrew Kennedy that we exploited a current "bug" in the units-of-measure code where literals (such as 1.0) can have generic units. We removed the incorrect usages and re-posted the ZIP file.&nbsp;</P><STRONG>Update 3</STRONG>: We extended the example to work with draws. Thanks to Chih-Jen Lin for the suggestion!&nbsp; 
<P mce_keep="true"><FONT face="Courier New"></FONT>&nbsp;</P>
<P mce_keep="true">
<P mce_keep="true"><SMALL>Ralf Herbrich &amp; Thore Graepel</SMALL></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/5337/00/00/03/07/16/81/TrueSkill%20-%20CTP.zip" original-url="http://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-5337-00-00-03-07-16-81/TrueSkill-_2D00_-CTP.zip">TrueSkill - CTP.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Create a Game with Popfly</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/create-a-game-with-popfly</link>
      <pubDate>Wed, 04 Jun 2008 08:22:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/06/04/create-a-game-with-popfly/</guid>
      <description><![CDATA[Popfly has a great Alpha that lets you create a game&nbsp;in your browser, no programming required,...]]></description>
      <content:encoded><![CDATA[<P><A class="" href="http://www.popfly.com/" mce_href="http://www.popfly.com/">Popfly</A> has a great Alpha that lets you <A class="" href="http://www.popfly.com/gamecreator/" mce_href="http://www.popfly.com/gamecreator/">create a game</A>&nbsp;in your browser, no programming required, and then easily embed it on your own site.</P>
<P>The following&nbsp;is one of the sample games - Space Boy:</P>
<P><IFRAME style="WIDTH: 100%; HEIGHT: 480px" src="http://www.popfly.com/users/Team/Space%20Boy.small" frameBorder=no allowTransparency mce_src="http://www.popfly.com/users/Team/Space%20Boy.small"></IFRAME></P>
<P>You can read more on <A class="" href="http://blogs.msdn.com/somasegar/archive/2008/05/02/popfly-game-creator.aspx" mce_href="http://blogs.msdn.com/somasegar/archive/2008/05/02/popfly-game-creator.aspx">Somasegar's WebLog: PopFly Game Creator</A>. It looks like <A class="" href="http://www.microsoft.com/Silverlight/" mce_href="http://www.microsoft.com/Silverlight/">Silverlight</A>&nbsp;is going to&nbsp;be a very&nbsp;interesting platform for games.</P>
<P>Phil</P>]]></content:encoded>
    </item>
    <item>
      <title>Statically link with ILMerge</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/statically-link-with-ilmerge</link>
      <pubDate>Thu, 29 May 2008 14:49:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/05/29/statically-link-with-ilmerge/</guid>
      <description><![CDATA[Today Ralf &amp; I were looking at ways to bundle up a&nbsp;bunch of .Net assemblies into a single...]]></description>
      <content:encoded><![CDATA[<P>Today Ralf &amp; I were looking at ways to bundle up a&nbsp;bunch of .Net assemblies into a single assembly for use within&nbsp;our group; the goal to&nbsp;expose only the functionality we want and only need to reference&nbsp;one assembly in our projects. Enter command line app <A class="" href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" mce_href="http://research.microsoft.com/~mbarnett/ILMerge.aspx">ILMerge</A> by Michael Barnett of Microsoft Research which lets you merge a set of dlls into a single assembly and selectively hide functionality by changing <A class="" href="http://msdn.microsoft.com/en-us/library/yzh058ae(VS.71).aspx" mce_href="http://msdn.microsoft.com/en-us/library/yzh058ae(VS.71).aspx">public access modifiers</A> to <A class="" href="http://msdn.microsoft.com/en-us/library/7c5ka91b(VS.71).aspx" mce_href="http://msdn.microsoft.com/en-us/library/7c5ka91b(VS.71).aspx">internal</A>.&nbsp;The first&nbsp;assembly&nbsp;you specify on the command line&nbsp;is the primary one and it's types maintain their access modifiers, the subsequent assembles are the ones that can be hidden by using ILMerge's ExcludeFile parameter where you can specify a file which in turn&nbsp;contains a list of <A class="" href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.aspx">regular expressions</A>&nbsp;for the&nbsp;types&nbsp;you would like to&nbsp;keep public. When you merge the assemblies if you have&nbsp;also written XML code documentation files these get merged too, so you even get to keep the <A class="" href="http://en.wikipedia.org/wiki/IntelliSense" mce_href="http://en.wikipedia.org/wiki/IntelliSense">intellisense</A> tooltips on the classes and functions you have documented with /// comments.&nbsp;For C#&nbsp;projects you can specify XML documentation output&nbsp;in the project's Visual Studio build properties, and for <A class="" href="http://en.wikipedia.org/wiki/F%E2%99%AF_%28programming_language%29" mce_href="http://en.wikipedia.org/wiki/F%E2%99%AF_%28programming_language%29">F#</A>&nbsp;projects you can use the command line <EM>-doc filename</EM> option. To quickly check if we were getting the desired results in our target assembly we used the&nbsp;<A class="" href="http://msdn.microsoft.com/en-us/library/f7dy01k1(VS.80).aspx" mce_href="http://msdn.microsoft.com/en-us/library/f7dy01k1(VS.80).aspx">ILdasm</A>&nbsp;tool to walk through our types. While&nbsp;checking the output&nbsp;we noticed that by default in the current F#, triple slash XML comments&nbsp;get embedded in the assembly for use in Visual Studio for tooltips; but if you are already generating seperate XML documentation it is possible to turn off this feature with the <A class="" href="http://blogs.technet.com/controlpanel/blogs/--no-interface-data" mce_href="http://blogs.technet.com/controlpanel/blogs/--no-interface-data "><EM>--no-interface-data</EM></A> command line option. So in summary ILMerge&nbsp;appears to be&nbsp;a great, highly customisable tool that lets you&nbsp;distribute a single assembly exposing just the functionality you want to expose (just like linking good old&nbsp;.Lib files in C++ :)).</P>
<P>Phil</P>]]></content:encoded>
    </item>
    <item>
      <title>BabyJack Inline Video Card Game</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/babyjack-inline-video-card-game</link>
      <pubDate>Mon, 26 May 2008 06:27:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/05/26/babyjack-inline-video-card-game/</guid>
      <description><![CDATA[Its been yet another wet&nbsp;and windy bank&nbsp;holiday weekend here in the UK,&nbsp;so&nbsp;I...]]></description>
      <content:encoded><![CDATA[<P mce_keep="true">Its been yet another wet&nbsp;and windy bank&nbsp;holiday weekend here in the UK,&nbsp;so&nbsp;I decided&nbsp;to involve the family and create&nbsp;a video <A class="" href="http://en.wikipedia.org/wiki/Blackjack" mce_href="http://en.wikipedia.org/wiki/Blackjack">Blackjack</A> called BabyJack,&nbsp;despite the baby's name being Sean&nbsp;not Jack :). Just press the Play button below to pit your wits against the baby...</P>
<TABLE class="" border=8>
<TBODY>
<TR>
<TD class="">
<DIV id=wmp></DIV></TD></TR>
<TR>
<TD class="" align=middle>
<DIV id=Prompt style="FONT-SIZE: 20px; FONT-FAMILY: fantasy"><INPUT style="FONT-SIZE: 20px; FONT-FAMILY: fantasy" onclick=Javascript:Shuffle(); type=button value="Play BabyJack!"></INPUT> </DIV></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript>
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
	var element = document.getElementById("wmp");
	element.innerHTML = "<OBJECT id=player height=280 width=340 type =application/x-oleobject classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 ><PARAM NAME=\"URL\" VALUE=\"http://www.trelford.com/BabyJack.gif\"><PARAM NAME=\"uiMode\" VALUE=\"none\"></OBJECT>";
}
else
{
	var element = document.getElementById("wmp");
	element.innerHTML = "<OBJECT id=player height=280 width=340 type=application/x-ms-wmp ><PARAM NAME=\"URL\" VALUE=\"http://www.trelford.com/BabyJack.gif\"><PARAM NAME=\"uiMode\" VALUE=\"none\"></OBJECT>";
}


var player = theForm.player;

function Pair(first,second)
{
	this.fst = first;
	this.snd = second;
	this.toString = function () { return "("+this.fst+","+this.snd+")"; }
}

function Card(rank, suit) {

	function HighValue(rank)
	{
		switch (rank)
		{
			case '2': return 2;
			case '3': return 3;
			case '4': return 4;
			case '5': return 5;
			case '6': return 6;
			case '7': return 7;
			case '8': return 8;
			case '9': return 9;
			case 'J': return 10;
			case 'Q': return 10;
			case 'K': return 10;
			case 'A': return 11;		
		}
		return 0;
	}

	function LowValue (rank)
	{
		if (rank == 'A') return 1;
		return HighValue (rank);
	}

	this.rank = rank;
	this.suit = suit;
	this.highValue = HighValue(rank);
	this.lowValue = LowValue (rank);

	this.toString   = function () {
		var code, color;
		switch (this.suit) 
		{ 
			case "C": code = "clubs"; color="black";
 break;

			case "D": code = "diams"; color="red"; break;
			case "H": code = "hearts"; color="red"; break;
			case "S": code = "spades"; color="black"; break;
		} 		
		return "<font color=" + color +">" + this.rank + "&" + code +";</font>"; 
	}
}

function ComputeHandRank(hand)
{
	var high = 0, low = 0;
	for (var i=0;i<hand.length;i++)
	{
		high += hand[i].highValue;
		low += hand[i].lowValue;
	}
	return high <= 21 ? high : low; 	
}

function Deck () {
	
	function generateCards() {	
		var cards = new Array();
		var suits = "CDHS";
		for (var suit=0; suit<suits.length; suit++)
		{
			var ranks = "A23456789JQK";
			for (var rank=0; rank<ranks.length; rank++)
			{
				var card = new Card(ranks.charAt(rank), suits.charAt(suit));
				cards.push( card  );
			}	

		}
		return cards;	
	}

	function shuffle (cards) {
		var pairs = new Array();
		for (var i=0;i<cards.length;i++)
		{
			pairs.push ( new Pair(Math.random(), cards[i]) );
		}
		pairs.sort( function (a,b) { return a.fst - b.fst; }	);	


		var shuffled = new Array();
		for (var i=0;i
<pairs.length;i++)
		{		
			shuffled.push( pairs[i].snd );
		}
		return shuffled;
	}

	this.cards = shuffle( generateCards() );	 
	this.takeOne = function () { return this.cards.shift(); }
}

var deck, babyHand, userHand;

function Play()
{
	setTimeout( function () { player.URL= "http://www.trelford.com/BabyJack.gif"; clearTimeout();}, 100);
	player.controls.play ();
	var s = "<input style=\"font-family:fantasy;font-size:20\" type=button onclick=\"Javascript:Shuffle();\" value=\"Play BabyJack!\"/>";
	document.getElementById("Prompt").innerHTML = s;
}


function Shuffle()
{
	player.URL= "http://www.trelford.com/Shuffle.wmv";
	document.getElementById("Prompt").innerHTML = "Shuffling deck";
	deck = new Deck();
	babyHand = new Array();
	userHand = new Array();
	babyHand.push(deck.takeOne());
	userHand.push(deck.takeOne());
	babyHand.push(deck.takeOne());	
	userHand.push(deck.takeOne());

}

function StickOrTwist()
{
	var html = "Your cards " + userHand.join();
	if (userHand.length > 2 && ComputeHandRank (userHand) > 21 )
	{
		html += " make you Bust";
		setTimeout( function () { player.URL = "http://www.trelford.com/Win.wmv"; clearTimeout(); }, 500);
	}
	else
 	{
		setTimeout( function () { player.URL= "http://www.trelford.com/StickOrTwist.gif"; clearTimeout(); }, 100);			
		html += " do you "; 
		html += "<input style=\"font-family:fantasy;font-size:20\" type=button value=\"Stick\"/ onClick=\"Javascript:Stick();\">";
		html += "&nbsp;or&nbsp;"
		html += "<input style=\"font-family:fantasy;font-size:20\" type=button value=\"Twist\"/ onClick=\"Javascript:Twist();\">";
	}
	document.getElementById("Prompt").innerHTML = html;	
}

function Stick()
{	
	if (ComputeHandRank (babyHand) >= ComputeHandRank (userHand) )
	{
		document.getElementById("Prompt").innerHTML = "BabyJack wins with " + babyHand.join();
		player.URL = "http://www.trelford.com/Win.wmv";				
	}
	else
	{
		document.getElementById("Prompt").innerHTML = "BabyJack loses with " + babyHand.join();
		player.URL = "http://www.trelford.com/Lose.wmv";				
	}
}

function Twist()
{
	player.URL= "http://www.trelford.com/Card.wmv";
	document.getElementById("Prompt").innerHTML = "Dealing card";	
	userHand.push(deck.takeOne());
}

</SCRIPT>

<SCRIPT language=JScript event=playStateChange(newState) for=player>
if (newState == 1) {
	if (player.URL.match ("Shuffle") != null) StickOrTwist ();
	if (player.URL.match ("Card") != null) StickOrTwist ();
	if (player.URL.match ("Win") != null) Play ();
	if (player.URL.match ("Lose") != null) Play ();
}
</SCRIPT>

<P>For those of you interested in how it was done; the video was shot on a simple digital camera, and then sepia and film age&nbsp;<A class="" href="http://www.microsoft.com/windowsxp/using/moviemaker/create/addspecialfx.mspx#specialfx" mce_href="http://www.microsoft.com/windowsxp/using/moviemaker/create/addspecialfx.mspx#specialfx">effects</A> were applied in&nbsp;<A class="" href="http://www.microsoft.com/windows/products/windowsvista/features/details/moviemaker.mspx" mce_href="http://www.microsoft.com/windows/products/windowsvista/features/details/moviemaker.mspx">Vista's Movie Maker</A>, with sound generated by my eldest son <A class="" href="https://www.youtube.com/watch?v=uapHhhQNdfk" mce_href="https://www.youtube.com/watch?v=uapHhhQNdfk">Thomas</A> playing piano in the background. The stills were created&nbsp;using Microsoft <A class="" href="http://windowshelp.microsoft.com/Windows/en-US/help/f5feb1df-8dd7-4ab0-9f65-3c1c89a329ab1033.mspx" mce_href="http://windowshelp.microsoft.com/Windows/en-US/help/f5feb1df-8dd7-4ab0-9f65-3c1c89a329ab1033.mspx">Paint</A> and the&nbsp;Chiller font.&nbsp;The video itself was embedded in the page using the <A class="" href="http://msdn.microsoft.com/en-us/library/bb249579(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb249579(VS.85).aspx">Windows Media Player Control</A>; and the interaction was coded&nbsp;in <A class="" href="http://www.w3schools.com/JS/" mce_href="http://www.w3schools.com/JS/">Javascript</A> using trusty <A class="" href="http://windowshelp.microsoft.com/Windows/en-NZ/Help/d85ed1d6-e6b7-468a-be39-9505c04ceb781033.mspx" mce_href="http://windowshelp.microsoft.com/Windows/en-NZ/Help/d85ed1d6-e6b7-468a-be39-9505c04ceb781033.mspx">Notepad</A>.</P>
<P><EM><STRONG>Phil Trelford</STRONG></EM></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/5337/00/00/03/06/11/29/BabyJack.html" original-url="http://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-5337-00-00-03-06-11-29/BabyJack.html">BabyJack.html</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Lunar Lander Retro Vector XNA 2.0 Game sample written in F#</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/lunar-lander-retro-vector-xna-2-0-game-sample-written-in-f</link>
      <pubDate>Sun, 11 May 2008 17:36:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/05/11/lunar-lander-retro-vector-xna-2-0-game-sample-written-in-f/</guid>
      <description><![CDATA[While travelling to&nbsp;Microsoft HQ in Redmond&nbsp;earlier in the year for the annual...]]></description>
      <content:encoded><![CDATA[<P>While travelling to&nbsp;Microsoft HQ in Redmond&nbsp;earlier in the year for the annual TechFest&nbsp;event - for some fun I decided to&nbsp;have a go at writing a&nbsp;small retro game in <A class="" title=FSharp href="http://research.microsoft.com/fsharp/fsharp.aspx" mce_href="http://research.microsoft.com/fsharp/fsharp.aspx">F#</A> using <A class="" href="http://creators.xna.com/" mce_href="http://creators.xna.com/">XNA 2.0</A>, and attached are the results. When&nbsp;moving over&nbsp;to Pacific time I usually find myself waking up at 4am for the first few days, leaving me with plenty of wide awake hours I wouldn't normally have to while away, and this is when the sample was born. I&nbsp;decided on an implementation of&nbsp;<A class="" title="Lunar Lander Computer Game" href="http://en.wikipedia.org/wiki/Lunar_Lander_%28computer_game%29" mce_href="http://en.wikipedia.org/wiki/Lunar_Lander_%28computer_game%29">Lunar Lander</A> basically because it is pretty simple both logically and graphically,&nbsp;and at the same time fun and achievable in a&nbsp;relatively short time. The&nbsp;sample lets you play with a game pad or keyboard ('Z' and 'X' to rotate, Space to thrust), and to complete the game you must land on the long flat section before you run out of fuel&nbsp;and hit the jagged terrain.</P>
<P><IMG title="Lunar Lander XNA Game Screenshot" style="WIDTH: 500px; HEIGHT: 375px" height=375 alt="Lunar Lander XNA Game Screenshot" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/05/37/99/lunarlandergame.gif" original-url="http://blogs.technet.com/photos/apg/images/3053799/500x375.aspx" width=500 mce_src="http://blogs.technet.com/photos/apg/images/3053799/500x375.aspx"></P>
<P>For those interested, the source is attached to this post, which comprises a Visual Studio 2005 solution, a C# XNA 2.0 shell project to take advantage of the content pipeline for audio, an F# game implementation project and a small utility project to create terrain vectors from points in an image file. Please feel free to download and&nbsp;play with it, in theory if you have XNA 2.0 and F#&nbsp;installed then you should be able to just load the solution and press F5 to build and run.&nbsp;</P>
<P mce_keep="true"><STRONG><EM>Phillip Trelford</EM></STRONG></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/5337/00/00/03/05/38/06/LunarLander.zip" original-url="http://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-5337-00-00-03-05-38-06/LunarLander.zip">LunarLander.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>LEGO Halo 3 Foundry Forge Kit</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/lego-halo-3-foundry-forge-kit</link>
      <pubDate>Fri, 18 Apr 2008 04:47:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/04/18/lego-halo-3-foundry-forge-kit/</guid>
      <description><![CDATA[We have recently come accross Jeff Keegan's solution to being&nbsp;obsessed with Halo 3's Forge...]]></description>
      <content:encoded><![CDATA[<P>We have recently come accross Jeff Keegan's solution to being&nbsp;obsessed with Halo 3's Forge mode, but&nbsp;stuck at work without an Xbox:</P>
<P><STRONG>The LEGO Halo 3 Foundry Forge Kit! (</STRONG><A class="" title="LEGO Halo 3 Foundry Forge Kit (LH3FFK)" href="http://www.keegan.org/jeff/lego/foundry/" target=_blank mce_href="http://www.keegan.org/jeff/lego/foundry/"><STRONG>LH3FFK</STRONG></A><STRONG>)</STRONG></P>
<P><A class="" title="Big Arena Bot" href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaBot_sbs_big.jpg" target=_blank mce_href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaBot_sbs_big.jpg"><IMG title="Big Arena Bot" style="WIDTH: 580px; HEIGHT: 163px" height=163 alt="Big Arena Bot" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/04/69/04/BigArenaBot_sbs.jpg" original-url="http://blogs.technet.com/photos/apg/images/3046904/original.aspx" width=580 align=left mce_src="http://blogs.technet.com/photos/apg/images/3046904/original.aspx"></A></P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">We loved the idea, and asked Jeff to tell us the story. Here it is in Jeff's very own words:</P>
<P mce_keep="true"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: Calibri; mso-fareast-language: EN-GB; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"><EM>"Halo 3 has a feature that lets you modify existing maps, but it's limited in that it only lets you place/move/remove objects - you can't change the terrain. That limitation changed slightly when Bungie gave us the Halo 3 map "Foundry", a large warehouse where virtually every object in the room is removable, and the terrain is basically a big empty box. With Foundry, they essentially threw down the gauntlet and said "Here's a blank slate - go have fun and create something cool". Many of us have risen to the occasion, pouring hours upon hours into the art of placing virtual shipping containers, bridges, staircases, crates, and wire fences in that big empty box, all to create that one perfect sandbox to play in.<BR><BR>One day, while talking about some map ideas with my friend Aron at work, we found ourselves drawing whiteboard illustrations just to convey the ideas that were coming to mind. Someone had already created a PDF file showing a top-down view of the empty warehouse (and a bunch of paper cutouts of containers that were to scale), but that crude tool only allowed you to create these very two-dimensional maps, hugging the ground. Looking at the Lego constructions on my desk, Aron said what I'd already been thinking for a while - someone should do this with Lego bricks. A few days later I had the entire design modeled in Lego Digital Designer - my Lego Halo 3 Foundry Forge Kit (LH3FFK). Before clicking the check-price button to see how much the actual pieces would cost, I wondered to myself how much I could stomach.. I imagined the best case scenario: that 20 years from now I'd fondly remember that cool Halo Lego map thing I did back in '08, that I'd create a bunch of incredible maps we play every Thursday, that I'd have fun building and using it, and that at least a few people said they thought it was cool. How much would I pay for that? I thought, maaaaybe, at the most, umm.. ehh.. $300?&nbsp; I cringed at the amount, amazed that I'd let myself go that high.&nbsp; I clicked the button and saw $380.&nbsp; Doh!<BR><BR>After one initial scaled-down purchase ($80), a cost saving trip to the local Lego store, some more self convincing, a final big purchase from Lego's Pick-a-Brick website, and more than 30 days of waiting for overseas shipping, I now have my kit. It took two days to sort out all of the Lego pieces and build the LH3FFK pieces. It's incredibly satisfying designing levels by hand; Forge is great (and also satisfying), but actually holding the blocks and manipulating them just feels different.&nbsp; My favorite part about this whole exercise? When I was a kid, every time I built a Lego building or maze, I'd think "Man, I wish we could shrink ourselves down to that size and run around in there, climb this, jump off of that, and crawl through this".&nbsp; Now, I can! Well worth the price of ten pounds of acrylonitrile butadiene styrene.<BR><BR>Now if only I could keep my daughters from turning my Big Arena map into a Lego tea party."</EM><BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: Calibri; mso-fareast-language: EN-GB; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin">We love Jeff's passion! Here are two more (clickable) screenshots:</SPAN></P>
<P mce_keep="true"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: Calibri; mso-fareast-language: EN-GB; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"><A class="" title="Big Arena Top" href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaTop_sbs_big.jpg" target=_blank mce_href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaTop_sbs_big.jpg"><IMG title="Big Arena Top" style="WIDTH: 580px; HEIGHT: 163px" height=163 alt="Big Arena Top" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/04/69/06/BigArenaTop_sbs.jpg" original-url="http://blogs.technet.com/photos/apg/images/3046906/original.aspx" width=580 mce_src="http://blogs.technet.com/photos/apg/images/3046906/original.aspx"></A></SPAN></P>
<P mce_keep="true"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: Calibri; mso-fareast-language: EN-GB; mso-ansi-language: EN-GB; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"><A class="" title="Big Arena W Corner" href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaWCorner_sbs_big.jpg" target=_blank mce_href="http://www.keegan.org/jeff/lego/foundry/lh3ffk_sbs_20080423/bigsbs/BigArenaWCorner_sbs_big.jpg"><IMG title="Big Arena W Corner" style="WIDTH: 580px; HEIGHT: 163px" height=163 alt="Big Arena W Corner" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/13/5393/00/00/03/04/69/08/BigArenaWCorner_sbs.jpg" original-url="http://blogs.technet.com/photos/apg/images/3046908/original.aspx" width=580 mce_src="http://blogs.technet.com/photos/apg/images/3046908/original.aspx"></A></P></SPAN>
<P mce_keep="true"><STRONG><EM>Joaquin Quiñonero Candela</EM></STRONG></P>]]></content:encoded>
    </item>
    <item>
      <title>TrueSkill Through Time</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/trueskill-through-time</link>
      <pubDate>Sat, 05 Apr 2008 08:59:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/04/05/trueskill-through-time/</guid>
      <description><![CDATA[In December 2007, we published a paper about the application of TrueSkill to all recorded data of...]]></description>
      <content:encoded><![CDATA[<P>In December 2007, we published a <A href="http://books.nips.cc/papers/files/nips20/NIPS2007_0931.ps.gz">paper</A> about the application of <A title="TrueSkill Homepage" href="http://www.research.microsoft.com/mlp/apg/trueskill.aspx" mce_href="http://www.research.microsoft.com/mlp/apg/trueskill.aspx">TrueSkill</A> to all recorded data of professional and semi-professional Chess play from 1850 to 2006. The dataset can be obtained from <A href="http://www.chessbase.com/shop/product.asp?pid=211&amp;user=&amp;coin=">ChessBase</A>. We are very happy to be able to release the <A href="http://research.microsoft.com/fsharp/fsharp.aspx">F#</A> source code that performed all these massive computations. A few things to bear in mind when running this code:</P>
<UL>
<LI>The full factor graph has ~30,000,000 factors and ~25,000,000 variables. At this size, the analysis is among the largest applications of (approximate) Bayesian inference to date. Nevertheless, the full message passing schedule allocates no more than 11 GB of memory and is run in under 20 minutes on an Intel Pentium 4 processor. These numbers hold for the adaptive draw margin model run on 3.5 million games.</LI>
<LI>Due to the huge amount of results (&gt;1,200,000 skills of all players in all their active years) we use SQL server to store the result set. Please let us know if you think a purely text based result output is needed and we will add it.</LI>
<LI>There is a very interesting, related <A href="http://math.bu.edu/people/mg/research/glicko.pdf">paper</A> by Prof. <A href="http://math.bu.edu/people/mg/research/glicko.pdf">Mark Glickman</A> which analyses subset of this data (88 top players of all time).</LI></UL>
<P mce_keep="true">The attached ZIP file contains the entire source code which should compile without problems with <A href="http://research.microsoft.com/research/downloads/Details/7ac148a7-149b-4056-aa06-1e6754efd36f/Details.aspx">F# 1.9.3.14</A>. You can either load the solution in Visual Studio 2008 or simply run build.bat form the command line - in either case you will end up with a <U>chessanalysis.exe</U> program or an <U>analysis.exe</U> program. If you want to try out the application, we included the first 1,000 lines of match outcomes (this is part of the first 5 years of data we have).</P>
<P mce_keep="true">As for running the code, here are the parameter switches of the command line application:</P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-no-safe</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Does not save results predictions (default: off)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-q&nbsp;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Verbosity level off; only works on single runs (default: on)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-N &lt;int&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; First N games only (default: ALL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-delta &lt;float&gt;</B>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Maximum deviation in any marginal for convergence (default: 0.01)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-muS &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mean of prior skill belief (default: 1200)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-sigmaS &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Standard deviation of prior skill belief (default: 400)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-muD &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Mean of prior draw margin belief (default: 300)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-sigmaD &lt;float&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </B>Standard deviation of prior draw margin belief (default: 100)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-beta &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Standard deviation of performance distr. (default: 600)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-tauS &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Standard deviation of skill dynamics distr. (default: 40)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-tauD &lt;float&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Standard deviation of draw margin dynamics distr. (default: 10)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>-server &lt;string&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQL server name for output (default: 'camresapga01')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-prefix &lt;string&gt;</B> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Table name prefix for output (default: 'Result')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-db &lt;string&gt;</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name of the database for output (default: 'ChessBase')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-mf</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Fixed draw margin (default)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-mf2</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fixed draw margin with two factors for draw<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-maf</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fixed draw margin with ADF (iterate per year)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-maf2</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Fixed draw margin with pure ADF<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-mv</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Variable draw margin<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-as</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Single run (default)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>-am</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Model selection</P>
<P mce_keep="true">So, a good first test is analysis.exe -no-safe SmallChessBase.csv.</P>
<P mce_keep="true">We are very interested to hear your feedback - both on the model, our paper and the F# code.</P>
<P><STRONG>Update</STRONG>: Following the release of the <A href="http://msdn.microsoft.com/en-us/fsharp/default.aspx" mce_href="http://msdn.microsoft.com/en-us/fsharp/default.aspx">F# September 2008 CTP</A> we have updated the source code to work with <A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=61ad6924-93ad-48dc-8c67-60f7e7803d3c&amp;displaylang=en">F# 1.9.6.2</A>. Also, we added one of the new features of F#, namely units-of-measure. Note that one can no longer accidentally pass the variance instead of the standard deviation beceause the former being of type <FONT face="Courier New">float&lt;ELOPoints^2&gt;<FONT face=Arial>. We have also added full debug support so simply press F5 to experiment with the -no-safe SmallChessBase.csv option mentioned above.</FONT></FONT></P>
<P><STRONG>Update</STRONG>: We removed a reduant schedule creation in the function <EM>FixedDrawMarginADFAnalyse</EM>. Thanks <A class="" href="http://users.rsise.anu.edu.au/~xzhang/" mce_href="http://users.rsise.anu.edu.au/~xzhang/">to Henry (Xinhua) Zhang</A>&nbsp;for pointing out this mistake!</P>
<P mce_keep="true"><SMALL>Ralf Herbrich &amp; Thore Graepel</SMALL></P>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/5337/00/00/03/02/96/64/ChessAnalysis%20-%20CTP.zip" original-url="http://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-5337-00-00-03-02-96-64/ChessAnalysis-_2D00_-CTP.zip">ChessAnalysis - CTP.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Arkwright Scholar Erroll Wood Visits MSRC</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/arkwright-scholar-erroll-wood-visits-msrc</link>
      <pubDate>Sat, 01 Mar 2008 15:53:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/03/01/arkwright-scholar-erroll-wood-visits-msrc/</guid>
      <description><![CDATA[Erroll Wood visited Microsoft Research Cambridge as an Arkwright scholar, and chatted to the...]]></description>
      <content:encoded><![CDATA[<FONT size=3>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Erroll Wood visited Microsoft Research Cambridge as an Arkwright scholar, and chatted to the Applied Games Group on Monday 11 of February 2008. Before handing in the mike to Erroll, let us link to some of the games he&nbsp;has written:</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<UL type=disc>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Tank Patrol: <A href="http://www.newgrounds.com/portal/view/298719"><SPAN style="COLOR: blue">http://www.newgrounds.com/portal/view/298719</SPAN></A><o:p></o:p></SPAN></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Turret Defence: <A href="http://www.newgrounds.com/portal/view/329519"><SPAN style="COLOR: blue">http://www.newgrounds.com/portal/view/329519</SPAN></A><o:p></o:p></SPAN></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Comet Blaster: <A href="http://www.newgrounds.com/portal/view/358561"><SPAN style="COLOR: blue">http://www.newgrounds.com/portal/view/358561</SPAN></A><o:p></o:p></SPAN></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 36.0pt"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Turret Defence 2: <A href="http://www.newgrounds.com/portal/view/393174"><SPAN style="COLOR: blue">http://www.newgrounds.com/portal/view/393174</SPAN></A><o:p></o:p></SPAN></LI></UL>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Now, here's the story of the Arkwright scholarship in Erroll's own words<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">In my GCSE year I took a paper and an interview for an Arkwright scholarship – a Design &amp; Technology sponsorship scheme aimed to stimulate young people to raise the profile of the Design &amp; Technology subject. Those who are accepted into the scheme are given £500 over 2 years to spend in the academic field and many more opportunities. Their school also receives £500 over two years to buy equipment. A few months after the interview I was pleasantly surprised to find out I’d secured a place with Microsoft Research Cambridge with its MD Andrew Herbert as my sponsor but I was most pleased to be given the chance to spend a few days in MSRC – a valuable experience.</SPAN></I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">I found the whole branch very impressive and the people working there really seemed to enjoy what they were doing. I was given a tour round plenty of different projects and it was interesting and exciting to get a peek at what might end up in big profile products in the near future. I also got a few days to work with the Computational Biology team helping them finish off a website though I did spend a lot of time just chatting and getting to know the team which was great.</SPAN></I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">This is a games blog I understand and I guess one of the reasons MSRC chose to sponsor me was my expressed interest in programming and games. As a hobby and to make some pocket money on the side I design and program games in flash to be played through web browsers. I’ve always enjoyed playing games and it’s a real pleasure to be able to make them as well so others can experience what you’ve created for them. It is a time consuming process however and I wish I was able to make more of them more often, but as it is I can only get them out during holidays when I’ve got more free time it seems.</SPAN></I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">To recap, thanks to all the guys who made my stay at MSRC so enjoyable and I wish everyone all the best!</SPAN></I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">Erroll</SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><I><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"></SPAN></I>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">I very much enjoyed talking to Erroll, and got addicted to <A class="" title="Turret Defence 2" href="http://www.newgrounds.com/portal/view/393174" target=_blank mce_href=" http://www.newgrounds.com/portal/view/393174">Turret Defence 2</A>. </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; TEXT-ALIGN: justify"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-GB; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><STRONG><EM>Joaquin Quiñonero Candela</P></EM></STRONG>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face=Arial size=3></FONT>&nbsp;</P></SPAN></FONT>]]></content:encoded>
    </item>
    <item>
      <title>F# Custom Exceptions</title>
      <link>https://docs.microsoft.com/archive/blogs/apg/f-custom-exceptions</link>
      <pubDate>Thu, 17 Jan 2008 16:07:00 GMT</pubDate>
      <dc:creator><![CDATA[apg]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/apg/2008/01/17/f-custom-exceptions/</guid>
      <description><![CDATA[This&nbsp;post&nbsp;tries to explore exception handling in F# with custom exception types.
Some...]]></description>
      <content:encoded><![CDATA[<P>This&nbsp;post&nbsp;tries to explore exception handling in F# with custom exception types.</P>
<P><STRONG>Some background on .Net exceptions</STRONG></P>
<UL>
<LI><STRONG>Exceptions happen:</STRONG> <CITE>"Programs must be able to uniformly handle errors that occur during execution. The common language runtime greatly assists the design of fault-tolerant software by providing a model for notifying programs of errors in a uniform way. All <SPAN style="BACKGROUND-COLOR: yellow">.NET Framework operations indicate failure by throwing exceptions</SPAN>."</CITE>&nbsp;- <A href="http://msdn2.microsoft.com/en-us/library/5b2yeyab.aspx">.NET Framework Developer's Guide: Handling and Throwing Exceptions</A>. 
<LI><STRONG>Deal with them:</STRONG> <CITE>"To build successful and flexible applications that can be maintained and supported easily, you must adopt an appropriate strategy for exception management. You must design your system to ensure that it is capable of the following:&nbsp;</CITE> 
<UL>
<LI><CITE><SPAN style="BACKGROUND-COLOR: yellow">Detecting exceptions</SPAN>.</CITE> 
<LI><CITE>Logging and reporting information.</CITE> 
<LI><CITE>Generating events that can be monitored externally to assist system operation."</CITE></LI></UL>- <A href="http://msdn2.microsoft.com/en-us/library/ms954599.aspx#emag__exception_management">Microsoft patterns &amp; practices: Exception Management Architecture Guide</A>. </LI>
<LI><STRONG>But:</STRONG> <CITE>"<SPAN style="BACKGROUND-COLOR: yellow">Do not rely on exceptions in your code.</SPAN> Exceptions can cause performance to suffer significantly, so you should avoid using them as a way to control normal program flow. If it is possible to detect in code a condition that would cause an exception, do so rather than catching the exception itself and handling the condition."</CITE>&nbsp; -&nbsp;<A href="http://technet.microsoft.com/en-us/library/5dws599a(VS.80).aspx#CodingPractices">Microsoft TechNet:&nbsp;Developing High-Performance ASP.NET Applications</A>.</LI>
<LI><STRONG>And:</STRONG> <CITE>"In most cases, <SPAN style="BACKGROUND-COLOR: yellow">use the predefined exceptions types</SPAN>. Define new exception types only for programmatic scenarios. Introduce a new exception class to enable a programmer to take a different action in code based on the exception class."</CITE> - <A href="http://msdn.microsoft.com/en-us/library/seyhszts.aspx">.Net Framework Developers Guide - Best Practices for Handling Exceptions</A>.</LI></UL>
<P><STRONG>Quick guide to F#&nbsp;exception&nbsp;handling keywords</STRONG></P>
<P>
<TABLE class="" cellSpacing=0 cellPadding=3 width="100%" border=0>
<TBODY>
<TR>
<TH class=top align=left width="25%" class="top">F#</TH>
<TH class=top align=left width="25%" class="top">C# equivalent</TH>
<TH class=top align=left width="50%" class="top">Description</TH></TR>
<TR>
<TD class=odd class="odd">raise exception</TD>
<TD class=odd class="odd"><A href="http://msdn2.microsoft.com/en-us/library/1ah5wsex.aspx">throw</A> exception;</TD>
<TD class=odd class="odd">Throws the specified exception.</TD></TR>
<TR>
<TD class=even class="even">rethrow ()</TD>
<TD class=even class="even"><A href="http://msdn2.microsoft.com/en-us/library/0yd65esw(VS.71).aspx">throw</A>;</TD>
<TD class=even class="even">Rethrows the current&nbsp;exception unchanged from a catch block.</TD></TD>
<TR>
<TD class=odd class="odd">try ... with</TD>
<TD class=odd class="odd"><A href="http://msdn2.microsoft.com/en-us/library/0yd65esw.aspx">try-catch</A></TD>
<TD class=odd class="odd">Filters&nbsp;exceptions.</TD></TR>
<TR>
<TD class=even class="even">try ... finally</TD>
<TD class=even class="even">
<P><A href="http://msdn2.microsoft.com/en-us/library/zwc8s4fz.aspx">try-finally</A></P></TD>
<TD class=even class="even">Guarantees&nbsp;execution of specified final block.</TD></TR>
<TR>
<TD class=odd class="odd">failwith string</TD>
<TD class=odd class="odd">&nbsp;</TD>
<TD class=odd class="odd">Throws a <A href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type_Failure.html">Failure</A> exception with the specified string.</TD></TR></TBODY></TABLE></P>
<P><STRONG>F#'s predifined library exceptions</STRONG></P>
<P>
<TABLE class="" cellSpacing=0 cellPadding=3 width="100%" border=0>
<TBODY>
<TR>
<TH class=top align=left width="25%" class="top">Exception</TH>
<TH class=top align=left width="25%" class="top">Usage</TH>
<TH class=top align=left width="50%" class="top">Description</TH></TR>
<TR>
<TD class=odd class="odd"><A href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type_Failure.html">Failure</A> of string</TD>
<TD class=odd class="odd">failwith "Bang!"</TD>
<TD class=odd class="odd">General failure.</TD></TR>
<TR>
<TD class=even class="even"><A href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type_InvalidArgument.html">InvalidArgument</A>&nbsp;of string</TD>
<TD class=even class="even">invalid_arg "arg1"</TD>
<TD class=even class="even">Invalid argument exception.</TD></TR>
<TR>
<TD class=odd class="odd"><A href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type__exn.html">exn</A></TD>
<TD class=odd class="odd">raise (new exn("Bang!"))</TD>
<TD class=odd class="odd">System.Exception type abbreviation.</TD></TR></TBODY></TABLE></P>
<P><STRONG>Filtering Failures </STRONG></P>
<P>Exceptions are caught/filtered&nbsp;using&nbsp;pattern matching and a Failure exception can be matched&nbsp;like a <A href="http://research.microsoft.com/fsharp/manual/quicktour.aspx#QuickTourDiscriminatedUnions">discriminated union </A>type:</P><PRE>    <SPAN style="COLOR: blue">try</SPAN> failwith "Too many errors"
    <SPAN style="COLOR: blue">with</SPAN> | <A class="" href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type_Failure.html">Failure</A> s <SPAN style="COLOR: blue">-&gt;</SPAN> printf "%s" s</PRE>Outputs: "Too many errors" 
<P><STRONG>Some reusable System.Exception based classes</STRONG></P>
<P>Frequently it is possible to simply reuse existing exception classes in your code:</P>
<TABLE class="" cellSpacing=0 cellPadding=3 width="100%" border=0>
<TBODY>
<TR>
<TH class=top align=left width="25%" class="top">Exception class</TH>
<TH class=top align=left width="75%" class="top">Thrown when...</TH></TR>
<TBODY>
<TR>
<TD class=odd class="odd"><A href="http://msdn2.microsoft.com/en-us/library/system.applicationexception.aspx">ApplicationException</A></TD>
<TD class=odd class="odd">a non-fatal application error occurs.</TD></TR>
<TR>
<TD class=even class="even"><A href="http://msdn2.microsoft.com/en-us/library/system.argumentnullexception.aspx">ArgumentNullException</A></TD>
<TD class=even class="even">a null reference is passed to a method that does not accept it.</TD></TR>
<TR>
<TD class=odd class="odd"><A href="http://msdn2.microsoft.com/en-us/library/system.argumentoutofrangeexception.aspx">ArgumentOutOfRangeException</A></TD>
<TD class=odd class="odd">the value of an argument is outside the allowable range of values.</TD></TR>
<TR>
<TD class=even class="even"><A href="http://msdn2.microsoft.com/en-us/library/system.formatexception.aspx">FormatException</A></TD>
<TD class=even class="even">the format of an argument does not meet the parameter specifications.</TD></TR>
<TR>
<TD class=odd class="odd"><A href="http://msdn2.microsoft.com/en-us/library/system.invalidoperationexception.aspx">InvalidOperationException</A></TD>
<TD class=odd class="odd">a method call is invalid for the object's current state.</TD></TR>
<TR>
<TD class=even class="even"><A href="http://msdn2.microsoft.com/en-us/library/system.notimplementedexception.aspx">NotImplementedException</A></TD>
<TD class=even class="even">a requested method or operation is not implemented.</TD></TR></TBODY></TABLE>
<P><STRONG>Custom F# exceptions</STRONG></P>
<P>In some cases we&nbsp;have a pragmatic reason to introduce our own custom exceptions, for example if we define our own data layer we may want to&nbsp;have&nbsp;an exception type for this layer.&nbsp;In the same way the .Net&nbsp;framework&nbsp;defines&nbsp;the <A href="http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlexception.aspx">SqlException</A> class&nbsp;&nbsp;for&nbsp;SQL specific exceptions.&nbsp;F# Custom exceptions&nbsp;provide an extremely concise form definition like discriminated unions&nbsp;which&nbsp;makes them simarly&nbsp;easy&nbsp;to <A class="" href="http://research.microsoft.com/fsharp/manual/quicktour.aspx#QuickTourPatterns" mce_href="http://research.microsoft.com/fsharp/manual/quicktour.aspx#QuickTourPatterns">pattern match</A> against: </P>
<UL>
<LI><STRONG>Defining a custom F# exception</STRONG> <PRE><A href="http://research.microsoft.com/fsharp/manual/lexyacc.aspx#ExceptionDefns">exception</A> AppException of string</PRE>
<LI>
<P><STRONG>Raising a custom F#&nbsp;exception&nbsp;</STRONG></P><PRE>raise (AppException <SPAN style="COLOR: #a31515">"Bang!"</SPAN>)</PRE>
<LI>
<P><STRONG>Catching a custom F# exception</STRONG></P><PRE><SPAN style="COLOR: blue">try</SPAN> raise (AppException <SPAN style="COLOR: #a31515">"Bang!"</SPAN>) <SPAN style="COLOR: blue">with</SPAN> | AppException s <SPAN style="COLOR: blue">-&gt;</SPAN> printf <SPAN style="COLOR: #a31515">"%s"</SPAN> s</PRE>
<P>Outputs: "Bang!"<STRONG>&nbsp;</STRONG></P>
<LI>
<P><STRONG>Reading the&nbsp;Message property value of&nbsp;a custom F# exception</STRONG><BR.> <PRE><SPAN style="COLOR: blue">try</SPAN>&nbsp;raise&nbsp;(AppException <SPAN style="COLOR: #a31515">"Bang!"</SPAN>)&nbsp;<SPAN style="COLOR: blue">with</SPAN> | e <SPAN style="COLOR: blue">-&gt;</SPAN> printf <SPAN style="COLOR: #a31515">"%s"</SPAN> e.Message</PRE>
<P>Outputs: "Exn+AppException[System.String]..."</P></LI></UL>
<P>So this all seems to make F# custom exceptions&nbsp;great for F# projects which are self-contained or which have F# projects as final consumers. However&nbsp;F# custom exceptions&nbsp;current concise construction syntax&nbsp;does not allow&nbsp;us to&nbsp;pass the values for the <A href="http://msdn2.microsoft.com/en-us/library/system.exception.message.aspx">Message</A> and <A href="http://msdn2.microsoft.com/en-us/library/system.exception.innerexception.aspx">InnerException</A> properties&nbsp;to&nbsp;the underlying <A href="http://msdn2.microsoft.com/en-us/library/system.exception.aspx">System.Exception</A>. It is possible to override the System.Exception.Message property but then again we lose a lot of our original conciseness. So I think this means then that F# custom exceptions are probably not suitable&nbsp;if&nbsp;you are going to be throwing an exception&nbsp;out of your F# project to say a C# project or&nbsp;to a vanilla exception&nbsp;logging mechanism.<STRONG>&nbsp;</STRONG></P>
<P><STRONG>An&nbsp;Alternative - custom exceptions using plain old inheritance</STRONG></P>
<P>You will see below&nbsp;custom exceptions using inheritance are also&nbsp;pretty concise for definition and for pattern matching and also allow you to&nbsp;easily&nbsp;initialize the <A href="http://msdn2.microsoft.com/en-us/library/system.exception.aspx">System.Exception</A>'s <A href="http://msdn2.microsoft.com/en-us/library/system.exception.message.aspx">Message</A> and <A href="http://msdn2.microsoft.com/en-us/library/system.exception.innerexception.aspx">InnerException</A> properties. Here we make good use of F#'s constructed classes, optional parameters and inheritance facilities:</P>
<UL>
<LI><STRONG>Defining an F# custom exception&nbsp;using inheritance</STRONG> <PRE><SPAN style="COLOR: blue">type</SPAN> VanillaException (message:string, ?innerException:exn) =
    <SPAN style="COLOR: blue">inherit</SPAN> ApplicationException (message, 
        <SPAN style="COLOR: blue">match</SPAN> innerException <SPAN style="COLOR: blue">with</SPAN> | Some(ex) <SPAN style="COLOR: blue">-&gt;</SPAN> ex | _ <SPAN style="COLOR: blue">-&gt;</SPAN> null)            </PRE>
<LI><STRONG>Pattern matching&nbsp;exception types in F#&nbsp;</STRONG> <PRE><SPAN style="COLOR: blue">try</SPAN> raise (new VanillaException(<SPAN style="COLOR: #a31515">"Vanilla!"</SPAN>)) 
<SPAN style="COLOR: blue">with</SPAN> 
| <A href="http://research.microsoft.com/fsharp/manual/FSharp.Core/Microsoft.FSharp.Core.type_Failure.html">Failure</A> s <SPAN style="COLOR: blue">-&gt;</SPAN> printf <SPAN style="COLOR: #a31515">"%s"</SPAN> s
| :? VanillaException as e <SPAN style="COLOR: blue">-&gt;</SPAN> printf <SPAN style="COLOR: #a31515">"%s"</SPAN> e.Message
| e <SPAN style="COLOR: blue">-&gt;</SPAN> e.Message</PRE>Outputs: "Vanilla!"</LI></UL>
<P>So it appears&nbsp;then that this approach&nbsp;is&nbsp;more suited&nbsp;to F# originated frameworks and libraries that expose exceptions to other languages and/or logging frameworks. Finally I would recommend that in this case that you catch any F# custom exceptions at the application boundary including Failure exceptions and rethrow them as vanilla .Net exceptions. </P>
<P><SMALL>Phil Trelford</SMALL></P>
<P><SMALL><FONT size=2>Further reading check out: <A class="" href="http://www.springerlink.com/content/nm5235752hm3710r/?p=3d79f4935a564bbda0bb5c880edeb421&amp;pi=3" mce_href="http://www.springerlink.com/content/nm5235752hm3710r/?p=3d79f4935a564bbda0bb5c880edeb421&amp;pi=3">Expert F# Chapter 4 Introducing Imperative Programming</A>.</FONT></SMALL></P></STRONG></STRONG>]]></content:encoded>
    </item>
  </channel>
</rss>