<?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>Einar Egilsson &#187; Card Games</title>
	<atom:link href="http://einaregilsson.com/category/cardgames/feed/" rel="self" type="application/rss+xml" />
	<link>http://einaregilsson.com</link>
	<description>A site for my programming pet projects</description>
	<lastBuildDate>Fri, 10 Feb 2012 09:54:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Spades</title>
		<link>http://einaregilsson.com/spades-card-game/</link>
		<comments>http://einaregilsson.com/spades-card-game/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 08:37:25 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Card Games]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://einaregilsson.com/?p=445</guid>
		<description><![CDATA[Yet another card game finished. The last card game I created was Hearts, which is a trick taking game, but you play on your own. This time I wanted to create a game where you play in teams, so a human player and a computer player work together against two other computer players. So I [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another card game finished. The last card game I created was <a href="http://www.hearts-cardgame.com">Hearts</a>, which is a trick taking game, but you play on your own. This time I wanted to create a game where you play in teams, so a human player and a computer player work together against two other computer players. So I created <a href="http://www.spades-cardgame.com">Spades</a>, a nice trick taking game where you play in teams and must bid before each hand how many tricks you think you&#8217;ll take.<br />
<span id="more-445"></span><br />
It was an interesting game to implement, especially making the computer players work sensibly with their partners. Usually you want to get as many tricks as possible, but you can also bid 0, and then you can&#8217;t take any trick, and your partner has to try to help you out if he sees that you are about to take the trick. You also have to be careful to not get too many tricks above your bid, since if you get 10 tricks more (over the course of a few hands) you&#8217;ll get a big penalty.</p>
<p>I can track the win percentage of the human team and the computer team, so far the computer team only wins about 35% of its games, but it&#8217;s a nice challenge to try to make it win more. And now that the game is live, and has lots of plays every day it&#8217;s a lot of fun to tweak the computer players, publish the new version and then see the next day if the win percentage goes up or down.</p>
<p>For my next project I think I&#8217;ll do something different. I&#8217;ve purchased the domain <a href="http://solitaire-cardgame.com">http://solitaire-cardgame.com</a> and am going to try to create Klondike (classic solitaire) first, if that&#8217;s fun then I&#8217;ll probably add a few others later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/spades-card-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online Crazy Eights Card Game</title>
		<link>http://einaregilsson.com/online-crazy-eights-card-game/</link>
		<comments>http://einaregilsson.com/online-crazy-eights-card-game/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 21:20:18 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Card Games]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/?p=441</guid>
		<description><![CDATA[My pet projects over the last few months have been mostly Visual Studio Extensions and online card games. And now I&#8217;ve finished a new card game. This time I made Crazy Eights, a popular card game in Iceland under the name Olsen Olsen. There are dozens of variations of it possible but I just made [...]]]></description>
			<content:encoded><![CDATA[<p>My pet projects over the last few months have been mostly Visual Studio Extensions and online card games. And now I&#8217;ve finished a new card game. This time I made Crazy Eights, a popular card game in Iceland under the name Olsen Olsen. There are dozens of variations of it possible but I just made a simple one where eights change suits and you can play multiple cards together if they have the same rank. Not much more to say about it, now go and <a href="http://www.crazyeights-cardgame.com">play Crazy Eights online!</a> </p>
<p>UPDATE 28.06.2011: And now I have <a href="http://www.hearts-cardgame.com/">a new card game, Hearts</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/online-crazy-eights-card-game/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Idiot cardgame for Facebook</title>
		<link>http://einaregilsson.com/idiot-cardgame-for-facebook/</link>
		<comments>http://einaregilsson.com/idiot-cardgame-for-facebook/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 22:28:19 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Card Games]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/?p=419</guid>
		<description><![CDATA[A couple of years ago I created a simple javascript version of the cardgame Idiot. It was very simple, no animation, tracking of scores or anything like that. Still, it got a few users, and there was some activity on it every day. A few months ago I wanted to learn some new technologies. I [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago I created a <a href="http://einaregilsson.com/2008/09/13/idiot-cardgame/">simple javascript version of the cardgame Idiot</a>. It was very simple, no animation, tracking of scores or anything like that. Still, it got a few users, and there was some activity on it every day. A few months ago I wanted to learn some new technologies. I wanted to try Google App Engine, learn more about jQuery and try creating a Facebook app. So, I decided to use Idiot as a test project and create a better version of the game. <span id="more-419"></span></p>
<p>I worked on it on and off for months. No pressure to finish since it was just a hobby project. And finally, on November 18th I launched the new version at <a href="http://www.idiot-cardgame.com">http://www.idiot-cardgame.com</a> and at <a href="http://apps.facebook.com/idiot-cardgame/">http://apps.facebook.com/idiot-cardgame/</a> to play it within Facebook itself.</p>
<div style="border:solid 1px black; margin-bottom:10px; padding:5px; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; background-color:#ddd;"><strong>UPDATE 24.05.2011:</strong> Because the game is better known under the name Shithead I bought a new domain for that, shithead-cardgame.com. Unfortunately both Facebook and Google App Engine were unhappy with a domain with profanity in the title so I forked the code and made a simple anonymous version that&#8217;s not a Facebook app. Go there to <a href="http://www.shithead-cardgame.com/play-shithead-online.html">play shithead card game online</a>.
</div>
<p>The new game has animated playing of cards, shows your avatars and tracks statistics. You can also choose cardbacks and cardfronts, animation speed and some other options, and there is a <a href="http://www.idiot-cardgame.com/highscores">High scores</a> page which shows the 10 best players.</p>
<p>Now, 6 weeks after launch it has about 250 registered Facebook users plus a lot of anonymous users. I wanted to allow anonymous play as well instead of forcing everyone to give their Facebook credentials. However, tracking of statistics and saving preferences requires Facebook registration. There are around 6-700 games played every day and the computer player wins around 45-50% of them.</p>
<p>All in all I&#8217;m happy with the game. I&#8217;ve been adding a few small features and fixing bugs since launch. The next major feature I&#8217;m planning is the ability to play against your friends. The newest App Engine SDK includes support for Comet style connections which would make this a lot easier than it was a few months ago.</p>
<p>Finally, some lessons learned:</p>
<ul>
<li>Create your basic game engine in vanilla javascript and use events (or callbacks) for rendering the actions. I did this and can run games for testing in a simple command line script, which is really nice while you&#8217;re developing the basic game.</li>
<li>Make the human player and the computer player implement the same interface, and let the Game object be ignorant of which player is which. This gives you the ability to play two computer players against each other during testing, which helps a lot if you don&#8217;t want to actually play the game thousands of times during development. I even have hidden options to do this in production so I can just watch an animated game play out.</li>
<li>Facebook SDK documentation is complete crap. Best resource to test things is <a href="http://fbrell.com">http://fbrell.com</a>.</li>
<li>App Engine regularly throws errors when connecting to the Datastore. Not all the time, but it is something you have to plan for.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/idiot-cardgame-for-facebook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Idiot cardgame (a.k.a. Shithead)</title>
		<link>http://einaregilsson.com/idiot-cardgame/</link>
		<comments>http://einaregilsson.com/idiot-cardgame/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 18:47:33 +0000</pubDate>
		<dc:creator>einar</dc:creator>
				<category><![CDATA[Card Games]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://tech.einaregilsson.com/?p=107</guid>
		<description><![CDATA[UPDATE 20.10.2010: A few days ago I launched a completely revamped version of this game, with animation, tracking of results, connection to Facebook and a lot more. That means that the blog post is completely out of date! Play the new version at http://www.idiot-cardgame.com or at http://www.shithead-cardgame.com. Or, you can play the original version, the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 20.10.2010:</strong> A few days ago I launched a completely revamped version of this game, with animation, tracking of results, connection to Facebook and a lot more. That means that the blog post is completely out of date! Play the new version at <a href="http://www.idiot-cardgame.com">http://www.idiot-cardgame.com</a> or at <a href="http://www.shithead-cardgame.com/play-shithead-online.html">http://www.shithead-cardgame.com</a>. Or, you can play the original version, the one that this blog post is talking about at <a href="http://einaregilsson.com/idiot/">http://einaregilsson.com/idiot/</a>. </p>
<p>Original blog post follows:</p>
<p>The last few weeks my hobby project has been creating a cardgame in Javascript. I&#8217;ve always wanted to create a cardgame and I decided to use simple Javascript so I could make it available online since no-one wants to bother to download small games. I figured there were thousands of blackjacks and solitaires out there so I decided to create my favorite cardgame, Idiot. <span id="more-107"></span>After googling around I found that there was a <a href="http://en.wikipedia.org/wiki/Shithead_(card_game)">Wikipedia page</a> about it under the name Shithead which listed all sorts of different variations. My variation uses the rules that I&#8217;ve usually used in real life:</p>
<ul>
<li>The point is to lose all your cards by putting them on the pile, a card that is put on the pile must be equal or higher than the top card of the pile. If you have no card to put on the pile you must take the entire pile.</li>
<li>There are always three cards in your hand, if you have less than three you must draw enough cards from the deck to get three again. After the deck is finished no more cards are drawn.</li>
<li>There are three downwards facing cards and three upwards facing cards on the table. You cannot play them until your hand is finished. You cannot look at a downward facing card before playing it.</li>
<li>Before you start you can exchange cards from your hand with the upwards facing cards on the table.</li>
<li>You can put a two on top of everything, it is the restart card.</li>
<li>You can put a five on top of everything, it is the reverse card, meaning that in the next turn the opponent must put a card equal or lower than five.</li>
<li>You can put a ten on top of everything and it burns the pile, and you get to put out the first card in the new pile.</li>
<li>You can put out more than one card at a time as long as they have the same rank.</li>
<li>If there are four cards with the same rank at the top of the pile then the pile is removed.</li>
<li>If you have no card that you can put on top of the pile then you may draw the top card of the deck and put on the pile, if it is a legal move then you do not have to take the pile.</li>
</ul>
<p>The game can be played at the url <a href="http://einaregilsson.com/idiot/">http://einaregilsson.com/idiot/</a>. As for the implementation, don&#8217;t expect any animation or fancy stuff. You simply choose the cards you want to put out and press the <em>Play selected cards</em> button. When the computer is playing the cards simply disappear from its hand and show up on the pile. However there is a small delay between each move by the computer so you can see when it puts out two or more cards and when it&#8217;s drawing cards. As for the rule about drawing a card off the top of the deck when you have to take the pile, that is done automatically. You simply press the <em>Take the pile</em> button and you will see a new card appear at the top of the pile (given that the deck is not empty). If the move is legal then the pile will stay, if it is not legal you will get the whole pile in your hand.</p>
<p>The game is implemented in two files, <a href="/download/cards.js">cards.js</a> and <a href="/download/idiot.js">idiot.js</a>. Cards.js is a generic library that has a base class for a card container and concrete classes for a hand, deck and card, it could easily be re-used for any card game. Idiot.js is the game itself, it works allright, although there are a lot of edge cases that could be added to the computer player to make it smarter. The code is pretty heavily commented so it should be easy to follow should anyone want to extend the game or use the library for something. The game files are licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution license</a> and so can be used for pretty much anything, they have been tested on the latest versions of all the major browsers. Please leave any error reports or suggestions as comments on this page.</p>
]]></content:encoded>
			<wfw:commentRss>http://einaregilsson.com/idiot-cardgame/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

