<?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>All Things IT Blog &#187; C# Programming</title>
	<atom:link href="http://www.enusbaum.com/blog/category/c-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.enusbaum.com/blog</link>
	<description>My little nerded out corner of the Internets!</description>
	<lastBuildDate>Tue, 18 Oct 2011 20:22:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>.NET Remoting and F5 Load Balancers</title>
		<link>http://www.enusbaum.com/blog/2011/04/net-remoting-and-f5-load-balancers/</link>
		<comments>http://www.enusbaum.com/blog/2011/04/net-remoting-and-f5-load-balancers/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 16:22:21 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[.NET Remoting]]></category>
		<category><![CDATA[F5 Load Balancer]]></category>
		<category><![CDATA[Load Balancing]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=437</guid>
		<description><![CDATA[Some of the topics I post on here are usually only of my interest, but once in a while I&#8217;ll give back to the community on issues that had me ripping my hair out. Recently I was working on an application that utilized .NET Remoting to access the middle tier of the application through an [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_439" class="wp-caption alignleft" style="width: 318px"><a href="http://www.enusbaum.com/blog/wp-content/uploads/2011/04/headdesk.jpg"><img class="size-full wp-image-439  " title="*headdesk*" src="http://www.enusbaum.com/blog/wp-content/uploads/2011/04/headdesk.jpg" alt="headdesk" width="308" height="231" /></a><p class="wp-caption-text">.NET Remoting + F5 Load Balancer == *headdesk*</p></div>
<p>Some of the topics I post on here are usually only of my interest, but once in a while I&#8217;ll give back to the community on issues that had me ripping my hair out. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Recently I was working on an application that utilized .NET Remoting to access the middle tier of the application through an F5 Load Balancer. For whatever reason, the .NET Remoting application kept dropping the connection with errors such as:</p>
<p><strong>&#8220;An existing connection was forcibly closed by the remote host&#8221;</strong></p>
<p>Through trouble shooting we were able to determine that it was definitely and issue with the F5 Load Balancer handling the connections being established by the .NET Remoting host.<strong></strong></p>
<p>We were able to resolve the issue by disabling the <a title="F5.com Knowledge Base -- Overview of the OneConnect Profile" href="http://support.f5.com/kb/en-us/solutions/public/7000/200/sol7208.html" target="_blank">OneConnect</a> profile on the F5 Load Balancer for the .NET Remoting VIP. Once the OneConnect profile was disable, the .NET Remoting application was able to hit the Remoting Service behind the VIP without issue.<strong></strong></p>
<p>Hope this helps anyone out there having the same issue!<strong></strong></p>
<p><strong>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</strong></p>
<div class="su-linkbox" id="post-437-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2011/04/net-remoting-and-f5-load-balancers/&quot;&gt;.NET Remoting and F5 Load Balancers&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2011/04/net-remoting-and-f5-load-balancers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ApocBot v0.0 &#8212; Open Source Magic Online Automated Trade Bot Released!</title>
		<link>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/</link>
		<comments>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 16:05:10 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[General Software]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Magic Online]]></category>
		<category><![CDATA[ApocBot]]></category>
		<category><![CDATA[Automated Trading]]></category>
		<category><![CDATA[Magic The Gathering Online]]></category>
		<category><![CDATA[MTGO]]></category>
		<category><![CDATA[MTGO Trading Bot]]></category>
		<category><![CDATA[Trade Bot]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=407</guid>
		<description><![CDATA[For everyone who&#8217;s been waiting and searching, here it is: ApocBot v0.0 &#8212; The First (not completely working) Open Source MTGO Trade Bot written in C#/.NET! Now that the fanfare is over, let&#8217;s get down to the nitty-gritty. What was with the delay? The truth of the matter is that life just has a way [...]]]></description>
			<content:encoded><![CDATA[<p>For everyone who&#8217;s been waiting and searching, here it is:</p>
<div id="attachment_409" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/1389_ApocExpSymbol.jpg"><img class="size-medium wp-image-409" title="ApocBot" src="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/1389_ApocExpSymbol-300x279.jpg" alt="ApocBot" width="300" height="279" /></a><p class="wp-caption-text">ApocBot v0.0</p></div>
<h1>ApocBot v0.0 &#8212; The First (not completely working) Open Source MTGO Trade Bot written in C#/.NET!</h1>
<p>Now that the fanfare is over, let&#8217;s get down to the nitty-gritty.</p>
<h2>What was with the delay?</h2>
<p>The truth of the matter is that life just has a way of happening. My desire to play Magic The Gathering: Online waxes and wanes through the years and I started this project shortly after moving across the country. So you can say it was the product of my being bored in the evenings <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Over the course of a few months my interest in this project started to fade as I settled into my new job and had to travel a bit.</p>
<p>I had debated in my mind on how to handle the bot. I know over time it would be a maintenance nightmare as people would require support and updates, which is honestly why I decided to go Open Source with it. For some reason people feel that paying for software implies some form of support! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  In the end, I just stopped working on it because (a) MTGO is just a hobby, so I wasn&#8217;t looking to make money off the bot and (b) I didn&#8217;t want to have to constantly maintain and update the code to work with new versions/UI changes as they come out. That&#8217;s just the lazy bastard I am <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>That being said, I still feel this is an important project because it gives the community at large the ability to finally be more open about automation on MTGO (and possibly other games).</p>
<h2>So what shape is the code currently in?</h2>
<p>Out of the box, the code isn&#8217;t going to work. I&#8217;ll go into the details below on why/what needs to be updated to get it in running shape.</p>
<p>Other than updating some of the code to work with any UI/screen changes, it should still work pretty well! I know it worked the last time I tried to use it (six months ago?).. so I&#8217;m sure with some TLC, someone can get it up and running again.</p>
<h2>And it&#8217;s free?!</h2>
<p>Yep! Anyone is free to download and use the code for ApocBot in their own Magic Online Trading Bots as long as they adhere to the BSD License terms. If anyone is feeling giving, links back to my blog and some Magic Online gratitude would be appreciated! (My MTGO user name is &#8220;<strong>WndrBr3d</strong>&#8220;)</p>
<h1>Download:</h1>
<h4><em>ApocBot and the source code are released under the<strong> BSD License</strong>. Please review the included &#8220;<span style="text-decoration: underline;"><strong>license.txt</strong></span>&#8221; file for terms and conditions. For more information on the <strong>BSD Licenses</strong>, click <a title="OSI -- The BSD License" href="http://www.opensource.org/licenses/bsd-license.php" target="_self">here</a>.</em></h4>
<h1><strong><a href="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/ApocBot.zip">ApocBot v0.0 (Source)</a></strong></h1>
<p><span style="text-decoration: underline;"><strong>Requirements:</strong></span> <strong>Visual Studio 2010</strong> and<strong> .NET 4.0</strong></p>
<p>And now.. the very rough technical details on how it works&#8230;</p>
<p><span id="more-407"></span></p>
<h2>How does it even work?!</h2>
<p>I followed the same basic idea as a lot of the <a title="Homepage -- AutoIT" href="http://www.autoitscript.com/autoit3/index.shtml" target="_blank">AutoIT</a> bots that are out there in the sense that I&#8217;m snapping screen shots and determining what&#8217;s on the screen by creating checksums of specified areas. I figured, <em>&#8220;Hey, if they can make it work in AutoIT, I&#8217;m sure I can make it work in C# even better!&#8221;</em></p>
<p>So using the idea of area checksums, ApocBot can identify what is currently being displayed on the screen and act appropriately.</p>
<p>The basic configuration for ApocBot to run was WindowsXP (Classic Theme) running at 1024&#215;768 (32-bit color depth).</p>
<h2>The Classes/Controllers</h2>
<h3>MTGOController.cs</h3>
<p>The MTGOController class holds the primary logic for ApocBot including the main program loop and all MTGO Object definitions.</p>
<p>On start up, all the MTGO Objects are defined. Currently these are all hard coded but I had planned to eventually move them all to an XML file and just have them <a title="MSDN -- XMLSerializer" href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.deserialize%28v=VS.100%29.aspx" target="_blank">deserialized</a> on start up (any takers on this? <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).. but for now, they&#8217;re all hard-coded.</p>
<p>After everything is setup, the main program loop will start. The basic function is this:</p>
<ol>
<li>Grab a screen shot</li>
<li>Determine the state of the bot (switch statement)</li>
<li>Based upon the state, check the screen for any known events/items to act upon</li>
<li>Sleep 250ms (to avoid CPU spike caused by constant screen polling)</li>
</ol>
<h3>ScreenController.cs</h3>
<p>The ScreenController class holds all the logic required to grab the screen shots and calculate the area checksums.</p>
<h3>MouseKeyboardController.cs</h3>
<p>The MouseKeyboardController class holds all the logic required to make mouse movements and send keys to the program. Hooks into the Windows API are used to simulate the mouse events to the OS.</p>
<h2>The Objects</h2>
<p>There are really three main objects used by ApocBot to know what&#8217;s going on:</p>
<ol>
<li><strong>MTGOScreen </strong>- Represents a screen in MTGO, such as the &#8220;Home&#8221; or &#8220;Trade&#8221; screens (Multiple Areas, Multiple Points)</li>
<li><strong>MTGOArea </strong>- Represents an area on a screen, such as a pop-up dialogue, card graphic or window (Multiple Points)</li>
<li><strong>MTGOPoint </strong>- Represents a point on the screen, such as an &#8220;OK&#8221; or &#8220;Cancel&#8221; button</li>
</ol>
<p>Objects are referenced in the system to main properties: <strong>Name </strong>and <strong>Checksum</strong>.</p>
<p>The checksums that are currently hard-coded might be out of date. You can generate new checksums using the AreaChecksum() method in the ScreenController.</p>
<hr />That&#8217;s it! I&#8217;ll be more than happy to answer any technical questions people might have about the code in the comments area of this post.</p>
<p>Almost forgot! It&#8217;s named &#8220;ApocBot&#8221; because Apocalypse was my favorite Magic: The Gathering expansion! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers!</p>
<div class="su-linkbox" id="post-407-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/&quot;&gt;ApocBot v0.0 &#8212; Open Source Magic Online Automated Trade Bot Released!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ApocBot &#8212; I feel I owe everyone an update!</title>
		<link>http://www.enusbaum.com/blog/2009/12/apocbot-i-feel-i-owe-everyone-an-update/</link>
		<comments>http://www.enusbaum.com/blog/2009/12/apocbot-i-feel-i-owe-everyone-an-update/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 19:31:02 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Magic Online]]></category>
		<category><![CDATA[Magic Online Bot]]></category>
		<category><![CDATA[MTGO]]></category>
		<category><![CDATA[MTGO Bot]]></category>
		<category><![CDATA[Open Source MTGO Bot]]></category>
		<category><![CDATA[SmartBot]]></category>
		<category><![CDATA[Trade Bot]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=359</guid>
		<description><![CDATA[12/21/2010 UPDATE: I have released the source code for my MTGO trading bot &#8220;ApocBot&#8221;. You can view that blog post and download the code for free here. Well, it seems my little post on my MTGO trading bot as generated some interest, so I felt I should at least give an update on the status. [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>12/21/2010 UPDATE</strong></span>: I have released the source code for my MTGO trading bot &#8220;ApocBot&#8221;. You can view that blog post and download the code for free <a title="Blog Post -- Open Source MTGO Trading Bot" href="http://www.enusbaum.com/blog/2010/12/11/apocbot-v0-0-magic-online-bot-released/" target="_self">here</a>.</p>
<hr />
Well, it seems my little post on my MTGO trading bot as generated some interest, so I felt I should at least give an update on the status.</p>
<ul>
<li>Basic Trade functionality is completed
<ul>
<li>Trade x for y (i.e. 4 Uncommons for 1 Rare)</li>
<li>Buy/Sell x for x (i.e. 6 Rares for 1 Ticket or 1 Ticket for 6 Rares)</li>
</ul>
</li>
<li>Smart Bot functionality is 70% Completed</li>
</ul>
<p>Currently ApocBot is able to correctly identify cards that are selected during a trade and quote the stored price for the cards.  So far, so good!</p>
<p>Want some more info? <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-359"></span></p>
<p>Okay, so here&#8217;s the big announce. I&#8217;m going to open source the Basic Trade functionality. I think it&#8217;s something that&#8217;s really fundamental and should have been included in the MTGO client to begin with. To that, I think it&#8217;s stilly to charge for such a basic function after writing it. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>So now to answer some obvious questions:</p>
<p><strong>Q: ZOMG! You&#8217;re going to open source it?!</strong></p>
<p>A: Yes. ApocBot will be the first free, open source MTGO trade bot <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Q: What license will it be released under?</strong></p>
<p>A: I&#8217;m going to release it under GPL v3</p>
<p><strong>Q: When?!</strong></p>
<p>A: It&#8217;ll be available on this site by January 1st, 2010 <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;ll need some beta testers to use it before I release the source, just to make sure I&#8217;m not going to cause more problems than good. I&#8217;ll send out a call for that within the coming weeks.</p>
<p><strong>Q: What about SmartBot functionality?</strong></p>
<p>A: I&#8217;m still working on SmartBot and to be honest, it has been more trouble than it&#8217;s worth. I&#8217;ll make a decision on that as soon as I think it&#8217;s at a functional point. Because I&#8217;m currently working full time, I&#8217;m only able to dedicate a couple hours a week to ApocBot so this might take a bit. Part of me open sorucing ApocBot in the first place is so the community can begin development of such a plugin or enhancement.</p>
<p><strong>Q: What will I need to develop ApocBot?</strong></p>
<p>A: ApocBot is written in Microsoft C# and you will need Microsoft Visual Studio 2008 (with .NET 3.5) to develop. And Magic: The Gathering Online.. of course <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>So that&#8217;s that! What&#8217;s funny is I was mulling this post around in my head and how to handle a MTGO bot that I knew (a) wouldn&#8217;t make a ton of money and (b) should really be free anyways.</p>
<p>Please feel free to e-Mail me or leave any questions you might have here on this post and I&#8217;ll be more vigilant in getting back to everyone.</p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-359-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/12/apocbot-i-feel-i-owe-everyone-an-update/&quot;&gt;ApocBot &#8212; I feel I owe everyone an update!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/12/apocbot-i-feel-i-owe-everyone-an-update/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Coming Soon &#8212; Magic The Gathering Online Smart Bot!</title>
		<link>http://www.enusbaum.com/blog/2009/09/coming-soon-magic-the-gathering-online-smart-bot/</link>
		<comments>http://www.enusbaum.com/blog/2009/09/coming-soon-magic-the-gathering-online-smart-bot/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 20:57:04 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General Software]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Automated Trading]]></category>
		<category><![CDATA[Magic Online]]></category>
		<category><![CDATA[Magic Online Bot]]></category>
		<category><![CDATA[Magic The Gathering Online]]></category>
		<category><![CDATA[MTGO]]></category>
		<category><![CDATA[Smart Bot]]></category>
		<category><![CDATA[Trading Bot]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=347</guid>
		<description><![CDATA[12/21/2010 UPDATE: I have released the source code for my MTGO trading bot &#8220;ApocBot&#8221;. You can view that blog post and download the code for free here. I thought I&#8217;d take the opportunity to update my blog here to talk about what I&#8217;ve been working on lately, as it would appear that my free projects [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>12/21/2010 UPDATE</strong></span>: I have released the source code for my MTGO trading bot &#8220;ApocBot&#8221;. You can view that blog post and download the code for free <a title="Blog Post -- Open Source MTGO Trading Bot" href="http://www.enusbaum.com/blog/2010/12/11/apocbot-v0-0-magic-online-bot-released/" target="_self">here</a>.</p>
<hr />I thought I&#8217;d take the opportunity to update my blog here to talk about what I&#8217;ve been working on lately, as it would appear that my free projects of WWWinamp and the Discogs API are no longer updated <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I&#8217;ve been working on my first retail product and I&#8217;m really excited about it!</p>
<p><span id="more-347"></span></p>
<p>After trying to secure a 3rd party trading bot for Magic The Gathering Online (MTGO) v3 from Wizards of the Coast (WotC), I decided it was time to strike out on my own and write one. A lot of people had done so already using automation software (like AutoIT), but I went the path of a more professional software development environment and wrote it in .NET using C# and WCF.</p>
<p>WCF you ask? Yep! I don&#8217;t want to dive into the details too much at the moment but it will revolve around a central data hub providing real time updates to users of the application (vs. having to download and deploy a new version every time an update is published from WotC). There will be a bunch of good features as well!</p>
<p>I wanted to poll people on pricing though. I&#8217;ve seen prices for &#8216;Simple&#8217; Magic Online trading bots for anywhere from $99 to $399! And to that, I haven&#8217;t even been able to find the price of a &#8216;Smart Bot&#8217; anywhere, as it seems the people who build them keep the software to themselves.</p>
<p>What I&#8217;m thinking about doing is setting up a monthly pricing model. Here&#8217;s the matrix:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="160" valign="top"><strong>Bot Type</strong></td>
<td width="160" valign="top"><strong>1-Month (Monthly)</strong></td>
<td width="160" valign="top"><strong>12-Month (Yearly)</strong></td>
<td width="160" valign="top"><strong>Lifetime</strong></td>
</tr>
<tr>
<td width="160" valign="top">Trade Bot</td>
<td width="160" valign="top">$5 USD</td>
<td width="160" valign="top">$50 USD</td>
<td width="160" valign="top">$199 USD</td>
</tr>
<tr>
<td width="160" valign="top">Smart Bot</td>
<td width="160" valign="top">$15 USD</td>
<td width="160" valign="top">$150 USD</td>
<td width="160" valign="top">$399 USD</td>
</tr>
</tbody>
</table>
<p><strong>Trade Bot:</strong> Your basic Magic Online trading bot. &#8220;Buying/Selling x Cards for x Tickets&#8221; or &#8220;Trading x Uncommons for x Rares&#8221;</p>
<p><strong>Smart Bot:</strong> Each card in your library can be assigned a specific price. You&#8217;re running a Virtual Store on Magic Online.</p>
<p>Some features I&#8217;m working on for the Smart Bot will be:</p>
<ul>
<li>User Credit System (and ability to create Credit Network spanning multiple bots)</li>
<li>Interactive Website Showing Sales History / Income Information</li>
</ul>
<p>I&#8217;m offering a time based licensing because I think it&#8217;s the most fair pricing structure for this type of software. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So I&#8217;m curious to hear back from anyone who stumbles across this blog post! I want to hear features and requests you would have for such a piece of software! I know Magic Trading bots are a shadey business at best, but I wanted to try to make a legitimate alternative to having to pay a lot of money up front for a piece of software you might not like.</p>
<p>I&#8217;ll try to post some screen shots of the bot in action while I&#8217;m testing it. I&#8217;m really excited about this project! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-347-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/09/coming-soon-magic-the-gathering-online-smart-bot/&quot;&gt;Coming Soon &#8212; Magic The Gathering Online Smart Bot!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/09/coming-soon-magic-the-gathering-online-smart-bot/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>.NET StringBuilder &#8212; Fast, but not as fast as you think!</title>
		<link>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/</link>
		<comments>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/#comments</comments>
		<pubDate>Thu, 28 May 2009 20:18:47 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft .NET 3.0 / WinFX]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Optimization]]></category>
		<category><![CDATA[.NET Profiler]]></category>
		<category><![CDATA[.NET Profiling]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Optimization]]></category>
		<category><![CDATA[C# String Concatenation]]></category>
		<category><![CDATA[C# String Manipulation]]></category>
		<category><![CDATA[C# Strings]]></category>
		<category><![CDATA[StringBuilder]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=294</guid>
		<description><![CDATA[StringBuilder: Friend or Foe?]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a situation where I was tasked to profile some .NET code and do some optimizations anywhere hot spots popped up. I was amazed to find out that one of the BIGGEST offenders in our code block was a simple call to <strong>StringBuilder.Append(char)</strong>. I had to take a step back and scratch my head and wonder if my profiler was confused.</p>
<p>I re-ran some tests using the <strong>StopWatch</strong> class to hard code some metrics into the application and they also confirmed the findings. What&#8217;s up? How could a class that everyone says you can use to your hearts content when it came to string concatenation was failing me?</p>
<p>Turns out, it was a mix of misuse and a common misconception about the <a title="MSDN Documentation -- StringBuilder Class" href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" target="_blank">StringBuilder Class</a>.</p>
<p><span id="more-294"></span></p>
<p>One of the first things you learn while picking up .NET is that the <a title="MSDN Documentation -- StringBuilder Class" href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" target="_blank">StringBuilder Class</a> is your friend when it comes to concatenating large strings in memory. It beats the pants off of <a title="MSDN Documentation -- String.Concat Method" href="http://msdn.microsoft.com/en-us/library/system.string.concat.aspx" target="_blank">String.Concat</a> and <a title="MSDN Documentation -- String.Format Method" href="http://msdn.microsoft.com/en-us/library/system.string.format.aspx" target="_blank">String.Format</a>, while also being a mutable object in the Framework utilizing an in-memory buffer.</p>
<p>I used <a title="Homepage -- JetBrains dotTrace Profiler" href="http://www.jetbrains.com/profiler/" target="_blank">JetBrains dotTrace</a> to help profile the application and it was very evident from the get-go that StringBuilder was causing the whole process to slow down.</p>
<p>The nature of my application was basically reading in a text buffer 1 character as a time, and using the <strong>StringBuilder</strong> as an output buffer. So for a 1k file, The method <strong>Append(char)</strong> would be called 1024 times. A 600k file would call <strong>Append(char)</strong> 614,400 times.</p>
<p>So why was I getting burned in execution time? The issue turned out to be two fold.</p>
<p>First, there&#8217;s overhead cost to the call. I don&#8217;t care how lightweight your method is, if you&#8217;re calling it <span style="text-decoration: underline;"><strong>SIX HUNDRED THOUSAND TIMES</strong></span>, it&#8217;s going to take a bit. Let alone a method who handles a string buffer in memory and string manipulation. So basically, no matter how fast StringBuilder actually is, it&#8217;s not a free call and you should consider the fact that the call still has overhead when architecting your solution.</p>
<p>Architecture brings me to my second point. While writing each character individually made sense initally, it seems that it was just lazy <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  The optimized route would have been calling Append with a SUBSTRING of the input buffer, this way we avoid the overhead of multiple calls by writing all the neccisary data in one big blob.</p>
<p>So 600,000 calls to <strong>StringBuilder.Append(char)</strong> becomes only a few hundred calls to <strong>StringBuilder.Append(string.Substring(start, count))</strong>. Sure, the Substring Virtual Method itself has overhead, but it&#8217;s still less than the thousands of calls to <strong>Append(char)</strong> that we&#8217;re saving ourself <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Conclusion?</p>
<p>StringBuilder is fast, but it&#8217;s not free. Take this into consideration when utilizing it while appending large data sets in small chunks. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers!</p>
<div class="su-linkbox" id="post-294-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/&quot;&gt;.NET StringBuilder &#8212; Fast, but not as fast as you think!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Example Huffman Compression Routine in C#</title>
		<link>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/</link>
		<comments>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/#comments</comments>
		<pubDate>Fri, 22 May 2009 21:17:04 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data Compression]]></category>
		<category><![CDATA[Deflate]]></category>
		<category><![CDATA[GZip]]></category>
		<category><![CDATA[Huffman Coding]]></category>
		<category><![CDATA[Huffman Compression]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=285</guid>
		<description><![CDATA[This last week I decided to sit down and hash out a simple Huffman compression routine using C#. I&#8217;d never created a compression routine before from scratch (my past implementations were static for the sake of time savings), so I fleshed one out. I know that many examples exist elsewhere on the net&#8230;. but they [...]]]></description>
			<content:encoded><![CDATA[<p>This last week I decided to sit down and hash out a simple Huffman compression routine using C#. I&#8217;d never created a compression routine before from scratch (my past implementations were static for the sake of time savings), so I fleshed one out. I know that many examples exist elsewhere on the net&#8230;. but they all seemed overly complicated and up their own ass <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I had a couple goals in mind while creating my routine:</p>
<p><strong>1. KEEP IT SIMPLE</strong> &#8212; A lot of routines out there WORK, but their code is too overly complicated for their own good. This over complication leads to slowness which brings me to my next goal <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  It should be a simple class that accepts input data, with simple public accessors that are easy to understand even for the novice developer (sorry folks, no asynchronous delegates). <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><strong>2. MAKE IT FAST</strong> &#8212; When dealing with large amounts of data in C#, especially when running it through an algorithm, it&#8217;s all too easy to use all the handy built in virtual methods or using other build in tools which make coding easier with speed being the sacrifice. Die hard C++ developers will point to these routines as C#&#8217;s downfall as a legitimate language when it comes to data intensive tasks.</p>
<p><span id="more-285"></span></p>
<p>The class I came up with is pretty simple. I use a Generic List to store a collection of &#8220;Leaf&#8221; objects, which have several basic attributes that help not only identify its value but also its place in the tree. Using this method, I was able to utilize the built in methods of the List object (I know, for shame&#8230;. but it&#8217;s easier in this instance) by firing off anonymous delegates for searches and comparators. I&#8217;m not terribly worried about using these virtual methods here only because the creation and encoding of the tree is usually the smallest task in the process <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The encoding and decoding is where I decided to focus on optimizations since this is where the BULK of the work is done. The .NET Framework has several methods that make working with binary data easy. You can use the Convert.ToString() method which allows you to pass in a BASE option, thus allowing you to convert any character to it&#8217;s binary representation. My original implementation used that method and the end result as embarrassingly slow <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I went back to the drawing board and thought to myself, &#8220;If I had to re-write this in C++, how would I handle the encoding?&#8221; Duh, I&#8217;d be using bitwise operators up the wazoo! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>After some recoding and pulling my hair out for a couple of hours, I was able to re-write the routine using bit operations and it works! On top of all that, it&#8217;s fast as all get out! My current benchmarks had it encoding a 1MB data set in under 1 second with ~50% compression. Not too shabby! Of course, compression ratios will vary depending on how normalized the input data set is.</p>
<p>Now I&#8217;m sure there&#8217;s some question you have on your mind and I&#8217;ll try to address them now:</p>
<p><strong>Q: Does it use a lot of memory?</strong></p>
<p><strong>A:</strong> You bet your sweet ass it does! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Seriously though, it&#8217;s only the method in which I setup the class that requires the memory. I establish an input buffer within the class that you can write the &#8216;raw&#8217; data to, which is then read from during encoding. In addition, during encoding I create an output buffer in memory where the &#8216;encoded&#8217; data is written. So it stands to reason that if you&#8217;re encoding 100MB of data, this routine can easily gobble up 200MB of RAM or more. The rule of thumb I found was File Size * 4 would be the memory requirement. There&#8217;s optimizations you can make that would lower the memory footprint (like, build the frequency table without buffering then read the input 1 byte at a time, say from a file), but I felt that would over complicate the solution and make it too focused for one specific instance. The current implementation is kept general for a reason <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Q: Could this be done faster in C++?</strong></p>
<p><strong>A:</strong> Yes, probably&#8230;. but not much faster. Although the code is written in C#, at run time the IL is compiled to x86. The bit operations we&#8217;re using would compile the exact same as a C++ routine (XOR is XOR, I don&#8217;t care what language you&#8217;re using). In addition, the encoding of the data itself is only using primitive native types which limits any cross language differences. In fact, you can paste the encode and decode routines into C++ and they work! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Your only speed improvement might be in the generation of the tree itself&#8230; but even then, that&#8217;s super small overhead when compared with the amount of data you&#8217;re probably compressing.</p>
<p>Of course, all that applied to the Encoding (Compression) side of the house, the decompression routine is pretty slow (about 3 seconds per 1MB of decompressed data) and could probably use some more optimizations.</p>
<p><strong>Q: Is this any better than using the built in GZip or Deflate classes available in System.IO.Compression?</strong></p>
<p><strong>A:</strong> It&#8217;s not even close to being in competition with those routines <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  This is really just a proof of concept for BASIC Huffman Coding, which doesn&#8217;t take into account advanced features of modern compression routines such as pattern or content mapping. This routine is slower (especially in decompression), so I wouldn&#8217;t go making anything like this your #1 choice for a compression routine if others are available <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  So use this for educational purposes only.</p>
<p><strong>Q: What version of the .NET Framework will this work with?</strong></p>
<p><strong>A:</strong> The code here was written in Visual Studio 2008 targeting .NET 3.5. I use some Framework 3.5 specific things (such as object initializers), but nothing that would make conversion difficult. I avoided LINQ only because I&#8217;m not entirely sold on the idea and I still like using anonymous delegates. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  This code could be converted to Framework 2.0 with minor changes and possibly Framework 1.1, but that might require a little more effort.</p>
<p><strong>Q: What is the format used to store the compressed data?</strong></p>
<p><strong>A:</strong> I encode the decompression information within the final output stream. The output format is like this:</p>
<p>Bytes 0 &#8211; 8: Final Output Size (Not used, but there as a checksum if needed in the future)</p>
<p>Byte 9: Number of Bytes in the Decode Dictionary</p>
<p>Bytes 10 &#8211; n: Decode Dictionary</p>
<p>Between the Decode Dictionary and the actual data I add the characters &#8220;BCD&#8221; (which stands for <strong>B</strong>inary <strong>C</strong>oded <strong>D</strong>ata). This lets me know where the dictionary ends and the actual coded data begins. It helped during debugging and I figure it&#8217;d help anyone else out there as well while working with this routine <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Q: What&#8217;s with the essay? Just give me the code!</strong></p>
<p><strong>A:</strong> Fine! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Seriously though, the only reason I&#8217;m doing such a long write-up on the code is to help people who are perhaps beginning to look into this sort of code for the first time and might have questions on why I did things a certain way. Understanding WHY the code was written helps understand how it operates.</p>
<p>So that&#8217;s the high and low of it! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope this helps someone out and if you have any questions, please feel free to leave a comment!</p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Huffman.zip</strong> &#8211; <a title="Huffman Coding in C#" href="http://www.enusbaum.com/blog/wp-content/uploads/Huffman.zip">Download</a> (3k)</p>
<div class="su-linkbox" id="post-285-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/&quot;&gt;Example Huffman Compression Routine in C#&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>A new version of WWWinamp is coming&#8230; I SWEAR!</title>
		<link>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/</link>
		<comments>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 04:00:42 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft .NET 3.0 / WinFX]]></category>
		<category><![CDATA[WWWinamp]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2008/01/21/a-new-version-of-wwwinamp-is-coming-i-swear/</guid>
		<description><![CDATA[Hello Everyone! I&#8217;m currently working on the latest version of WWWinamp after taking another hiatus from the project in order to clear my head and work on some other fun things such as the previously mentioned XNA projects The next version of WWWinamp will be targeted for the .NET 3.5 Framework and you will need [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone!</p>
<p>I&#8217;m currently working on the latest version of WWWinamp after taking another hiatus from the project in order to clear my head and work on some other fun things such as the <a href="http://www.enusbaum.com/blog/2007/12/28/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/" title="2D WndrPong! using the Microsoft XNA Game Studio v2.0!" target="_blank">previously mentioned</a> XNA projects  <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The next version of WWWinamp will be targeted for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6&amp;displaylang=en" title="Microsoft .NET Framework 3.5" target="_blank">.NET 3.5 Framework</a> and you will need to have it installed on your machine in order to run WWWinamp. Most of the changes in this version are behind the scenes and will probably be transparent to you, the user. BUT, some visible changes in the upcoming version of WWWinamp 4.2 will be:</p>
<ul>
<li><strong>Automatic Version Checking for new releases of WWWinamp </strong></li>
<li><strong>Ability to enable or disable Automatic Version Checking  </strong></li>
<li><strong>Ability to enable or disable Windows Vista warning message<br />
</strong></li>
<li><strong>Improved performance under load</strong></li>
</ul>
<p>I know, nothing earth shattering on the horizon. &#8220;Why is this?&#8221; you might as. Well, the honest reason is that I haven&#8217;t received any bug reports with issues that weren&#8217;t related to a misconfiguration or user error. This is a good thing! It means that WWWinamp is stable and there aren&#8217;t any horrible bugs that continue to nag users. The downside to this is that because WWWinamp is pretty feature rich as is, I&#8217;m running low on ideas that could be implemented.</p>
<p>An idea I&#8217;ve tossed about and am thinking about trying out is creating a WWWinamp .NET assembly for user within your own Windows or ASP.NET applications developed using the .NET framework. The assembly would handle the media library and searching of the library so you wouldn&#8217;t have to code your own database and file searching routines, as well as handling the unmanaged code required to interface with <a href="http://www.winamp.com/" title="WinAmp -- It really whips the llamas ass!" target="_blank">Winamp</a> (if it&#8217;s running locally on the WWWinamp machine) or communicating via WCF to a remote instance of WWWinamp running the WCF daemon.</p>
<p>I think that between the WWWinamp Server and my proposed WWWinamp Assembly, that&#8217;d give both advanced and novice users full control over their setup. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As I mentioned in a <a href="http://www.enusbaum.com/blog/2007/12/05/wwwinamp-is-being-converted-to-net-framework-v35/" title="WWWinamp is being converted to .NET Framework v3.5!" target="_blank">previous post</a>, I&#8217;ve moved WWWinamp into Visual Studio 2008 with Team Foundation Server. Within the latest version of Visual Studio 2008 there is a set of <a href="http://blogs.msdn.com/fxcop/archive/2007/02/28/announcing-visual-studio-code-metrics.aspx" title="Announcing Visual Studio Code Metrics!" target="_blank">code analysis tools</a> which calculate such items as Code Maintainability and Cyclomatic Complexity. I ran it on WWWinamp and it scored the following:</p>
<p><strong>Maintainability Index:</strong> 83 (out of 100)</p>
<p><strong>Cyclomatic Complexity:</strong> 636</p>
<p><strong>Depth of Inheritance:</strong> 7</p>
<p><strong>Class Coupling:</strong> 151</p>
<p><strong>Lines of Code:</strong> 1,829 (!!)</p>
<p>After over a year, I think WWWinamp has gotten better and continues to improve with every version!</p>
<p>Big thanks to everyone for their support and keep your eyes peeled here for the latest version of WWWinamp!</p>
<div class="su-linkbox" id="post-73-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/&quot;&gt;A new version of WWWinamp is coming&#8230; I SWEAR!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2D WndrPong! using the Microsoft XNA Game Studio v2.0!</title>
		<link>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/</link>
		<comments>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 00:28:04 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft XNA]]></category>
		<category><![CDATA[2D Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Pong!]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/12/28/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/</guid>
		<description><![CDATA[I decided to take some time this weekend to sit down and learn what I could about the latest release of Microsoft&#8217;s XNA Game Studio. I started out with a book I purchased called Microsoft XNA Game Studio Creators Guide, which turned out to be a terrible book. Most of the examples in this book [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to take some time this weekend to sit down and learn what I could about the latest release of Microsoft&#8217;s <a href="http://www.xna.com/" title="Link -- Microsoft XNA Game Studio Website" target="_blank">XNA Game Studio</a>. I started out with a book I purchased called <a href="http://www.amazon.com/Microsoft%C2%AE-Game-Studio-Creators-Guide/dp/007149071X/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1198886266&amp;sr=8-1" title="Link to the worst book on XNA ever printed, ever." target="_blank">Microsoft XNA Game Studio Creators Guide</a>, which turned out to be a terrible book. Most of the examples in this book assume that you&#8217;re starting with a project the book provides on a Website, which already has hundreds of lines of code, custom shaders and everything built in&#8230; without even explaining how the code is working in the background.</p>
<p>After fumbling around with that for an hour or so an only succeeding in creating a small square on the screen, I headed over to Microsoft.com to see if any MSDN articles might exist to help me along in my &#8216;ground up&#8217; learning of XNA.  I was pleasantly surprised when I found a great article titled &#8220;<a href="http://msdn2.microsoft.com/en-us/library/bb203893.aspx" title="Best Starter Article ever for XNA :)" target="_blank">Your First Game: Microsoft XNA Game Studio in 2D</a>&#8220;. This was EXACTLY what I was looking for as it starts from the ground up, assuming the reader has never done game programming before, let alone 3D game programming. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The example provided my Microsoft in this article is a simple 2D Texture of a cat that bounces around the window. I was so pleased with the ease of coding this, I thought to myself, &#8220;Heck, how hard could it be to recreate Pong?&#8221; <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So I set upon my task.</p>
<p>Several hours and many Coca-Cola bottles later I had not only my first XNA game <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/wndrpong.thumbnail.gif" title="2D WndrPong! running in Windows" target="_blank">running in Windows</a>, but after purchasing the XNA Creators Club annual subscription from the XBox Live! marketplace for $99, I had it <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/wndrpong_tv.jpg" title="2D WndrPong! running on the XBox 360!" target="_blank">running on my XBox 360</a> as well <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I decided to take a little extra time and add a debug information screen as well as a small welcome screen <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Controls (PC):</strong></p>
<p>Up/Down for Player 1 Paddle (Left): Q/A</p>
<p>Up/Down for Player 2 Paddle (Right): Up Arrow/Down Arrow</p>
<p>Debug Information: F1</p>
<p><strong>Controls (XBox 360):</strong></p>
<p>Up/Down for Player 1 Paddle (Left): Left Thumbstick on Player 1 Remote</p>
<p>Up/Down for Player 2 Paddle (Right): Left Thumbstick on Player 2 Remote</p>
<p>I did run into a couple of &#8216;gotchas!&#8217; while working with Game Studio. The major one I had trouble with was when you&#8217;re developing for the XBox 360 you have to account for <a href="http://en.wikipedia.org/wiki/Overscan" title="Link -- Wikipedia Article on Overscan" target="_blank">overscan</a> on the Television and have your game render within the &#8216;<a href="http://en.wikipedia.org/wiki/Safe_area" title="Link -- Wikipedia Article on Safe Area" target="_blank">Safe Area</a>&#8216;. I noticed that when I was playing my Pong! game on my LCD TV at 720p, the edges of the game were cut off and it looked like it was stretched past the borders of my TV. After asking the fine folks in #XNA on IRC about this issue, they were able to help me out. Now I have my Pong! game account for this by setting up an XBox 360 macro which pads the edges of the play area by 50 pixels.</p>
<p>I&#8217;m including the Source Code for my version of Pong! which I&#8217;ve titled, &#8220;2D WndrPong!&#8221;. You can work in XNA Game Studio for free using <a href="http://msdn2.microsoft.com/en-us/express/aa975050.aspx" title="Link -- Microsoft.com Visual C# 2005 Express Edition" target="_blank">Visual C# 2005 Express Edition</a> along with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DF80D533-BA87-40B4-ABE2-1EF12EA506B7&amp;displaylang=en" title="Link -- Microsoft.com XNA Game Studio 2.0 Install" target="_blank">XNA Game Studio 2.0</a> <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  To deploy your games to an XBox 360, you must pair your XBox with your PC  (using the &#8220;XNA Game Studio Device Center&#8221; tool)  then you must purchase an XNA Creators Club Membership from the XBox 360 Marketplace. I believe the prices are $49.99 for 3 Months, $99.99 for a year. I opted for the entire year since I know it&#8217;s going to take me some time to learn <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Baby Steps <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>2D WndrPong! Source Code</strong> &#8211; <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/2d_wndrpong.zip" title="Link -- Download Link to 2D WndrPong!" target="_blank">Download</a> (36k)</p>
<div class="su-linkbox" id="post-69-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/&quot;&gt;2D WndrPong! using the Microsoft XNA Game Studio v2.0!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WWWinamp is being converted to .NET Framework v3.5!</title>
		<link>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/</link>
		<comments>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 05:17:32 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[.NET 2008]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Team Foundation Server 2008]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/12/05/wwwinamp-is-being-converted-to-net-framework-v35/</guid>
		<description><![CDATA[Yep, it&#8217;s true! I&#8217;ve spent the last week or so playing around with the .NET Framework v3.5 and I really like what I see. Microsoft has also put a lot of work into Team Foundation Server 2008 as well. I&#8217;ve setup a Virtual Machine using Virtual PC here running Team Foundation Server 2008 on Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Yep, it&#8217;s true!</p>
<p>I&#8217;ve spent the last week or so playing around with the .NET Framework v3.5 and I really like what I see. Microsoft has also put a lot of work into Team Foundation Server 2008 as well. I&#8217;ve setup a Virtual Machine using Virtual PC here running Team Foundation Server 2008 on Windows 2003 Server R2 and was able to get WWWinamp imported + converted without issue!</p>
<p>[zoomer]66|450|0|WWWinamp in Team Foundation Server 2008|1|0[/zoomer]</p>
<p>One thing I have noticed is that TFS does take up quite a bit of resources. I had to kick my VM up to 2GB of RAM in order for it to handle and build WWWinamp without hitting the swap file. Something to keep in mind moving forward I suppose. I&#8217;d imagine a large installation of TFS would require something along the lines of a Quad Core CPU with at least 4GB RAM.</p>
<p>There are several features in .NET 3.5 that I plan on implementing in WWWinamp right off the bat:</p>
<ul>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb384062(VS.90).aspx" title="MSDN -- Article on C# Object Initializers in .NET 3.5" target="_blank">Object Initializers</a> &#8211; This will really help clean up the already massive code base. It&#8217;ll also speed things up a bit <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb545961(VS.90).aspx" title="MSDN Article -- Embedded Manifests in C# .NET 3.5" target="_blank">Embedded Manifest</a> &#8211; A feature I&#8217;m surprised they didn&#8217;t implement with the release of .NET 3.0. Now the .manifest file will be embedded into WWWinamp, so you won&#8217;t have the extra file handing around if you run Windows Vista <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb383977(VS.90).aspx" title="MSDN Article -- Extension Methods in C# .NET 3.5" target="_blank">Extension Methods</a> &#8211; Again, this will help clean up the code base and make things faster. I imagine it&#8217;ll take up a little more memory, but these days RAM is abundant <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>Now, I see LinQ and I&#8217;m trying to figure out it&#8217;s role in everything. I think it&#8217;ll make DB communication easier but I&#8217;m not a fan of the anonymous data types and implicit local variables. I think it could lead to some sloppy coding methodology if not kept in check.</p>
<p>I think it&#8217;s handy that you can now run a SQL like statement on a generic, but I&#8217;m wondering what sets this apart from the <a href="http://msdn2.microsoft.com/en-us/library/fh1w7y8z.aspx" title="MSDN Article -- FindAll method in C# .NET 2.0" target="_blank">FindAll</a> method that already exists in <a href="http://msdn2.microsoft.com/en-us/library/system.collections.generic.aspx" title="MSDN Article -- System.Collections.Generics in C# .NET 2.0" target="_blank">System.Collection.Generics</a>. It does make it easier though to search through a Generic Collection for a developer who doesn&#8217;t have a solid grasp on delegates.</p>
<p>So, all that said, things are moving along. I&#8217;ll keep you all updated on the progress and please, send in those feature requests! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-67-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/&quot;&gt;WWWinamp is being converted to .NET Framework v3.5!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WWWinamp Feedback Requested</title>
		<link>http://www.enusbaum.com/blog/2007/12/wwwinamp-feedback-requested/</link>
		<comments>http://www.enusbaum.com/blog/2007/12/wwwinamp-feedback-requested/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 05:04:26 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Feedback]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/12/02/wwwinamp-feedback-requested/</guid>
		<description><![CDATA[I started tapping away at the WWWinamp source the other night and was curious if there are any features you guys, the users, would like to see added? I&#8217;ve been trying to think up new ideas but I&#8217;m not sure if they&#8217;d even be helpful. So basically, I&#8217;m asking help for what to put in [...]]]></description>
			<content:encoded><![CDATA[<p>I started tapping away at the WWWinamp source the other night and was curious if there are any features you guys, the users, would like to see added? I&#8217;ve been trying to think up new ideas but I&#8217;m not sure if they&#8217;d even be helpful.</p>
<p>So basically, I&#8217;m asking help for what to put in the next version. If you could leave a comment with any of the following, that&#8217;d REALLY help out! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<ul>
<li>What feature would you like to see added to WWWinamp?</li>
<li>Is there any nagging bug or weird behavior you would like fixed?</li>
</ul>
<p>I&#8217;m currently fiddling around with Visual Studio 2008 right now and am looking into the benefits C# 3.5 offers over 2.0, which the current release of WWWinamp is based upon.</p>
<p>Thanks for your feedback and support everyone! I look forward to your responses! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-64-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/12/wwwinamp-feedback-requested/&quot;&gt;WWWinamp Feedback Requested&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/12/wwwinamp-feedback-requested/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

