For those that just want to play the game already, go here to play it
The last few weeks my hobby project has been creating a cardgame in Javascript. I’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. After googling around I found that there was a Wikipedia page about it under the name Shithead which listed all sorts of different variations. My variation uses the rules that I’ve usually used in real life:
The game can be played at the url http://tech.einaregilsson.com/idiot-cardgame/. As for the implementation, don’t expect any animation or fancy stuff. You simply choose the cards you want to put out and press the Play selected cards 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’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 Take the pile 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.
The game is implemented in two files, cards.js (syntaxhighlighted) and idiot.js (syntaxhighlighted). 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 Creative Commons Attribution license 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.
Great game but I ran into the situation where there was no pickup pile left and then a 5. Neither my cards nor the computer’s could beat it so the game was in a stalemate. Have you seen this happen before?
Hi Peter, glad you enjoy the game.
So did both you and the computer have a card that was higher than 5? Normally I would think that eventually one player would have to take the 5 and then decide to put something else out, not the 5, just to move the game along. But not knowing the exact cards and number of them you had I’m not sure if that was possible. I did get one report about a stalemate a while ago but I don’t remember the specifics, something to do with a 5 though.
If you remember the number of cards and roughly what they were I can try to recreate it myself and figure out a solution. The computer doesn’t handle edge cases very well currently, and this is definitely an edge case that needs to be fixed
First off let me say, Thank you for creating this! Passes time when I have no one else to play with, and beats solitaire by far! I also ran into a stalemate, the computer and I both hand only 1 upward facing card on our stacks, both being a King, and the only card on the pile was a single Ace. If the computer plays the ace, my king will not beat it, it being a lower card rank, so my only choice is to take the stack(the single ace) now I have 1 card in hand and the computer has 0 cards in hand, I must play the ace, then the computer must take the stack and so on it keeps going back and forth. Also a suggestion if possible would be to implement a “new game” button onto the board so that you do not have to refresh the page everytime you want a new game.
keep up the good work,
-Steve