Inspiration

I first learned how to play the card game Trash when my neighbor taught me when I was hanging out at his place. I LOVED the games; it doesn't have the annoying endlessness of war, yet it's just as simple to learn and easy to play. One day last spring I got bored and decided to make a console-based version of the game on repl.it, but I soon realized there aren't many versions of the game on the android app store, so I decided to make a game with a simple UI.

What it does

Trash is a game where two players use one standard deck of 52 cards. The object of the game is to be the first player to complete your layout of ten cards Ace through Ten (A,1,2,3,4,5,6,7,8,9,10). If a king is replacing any of those cards, that still counts as a win. In the game, each player is dealt ten cards face down in two rows of five cards each. Players are not allowed to look at their cards. The remaining cards are placed face down to form the deck pile.

To start, player 1 takes one card from the deck. If the card is any card Ace through ten, the player places that card in its correct location in the layout (the top left card of the layout is the 1 or Ace position, then 2, 3, etc.). To do this, the player must remove the face down card that is occupying that location and turn it face up. This card, in turn, is placed in its appropriate location, if available, displacing the face down card that was there. This continues until the player finds a card that cannot be placed - a Queen or a Jack or a number card whose location is already occupied by a face up card with that number. The player must then discard the unplayable card, placing it face up on the table next to the stock pile to begin a discard pile, and the turn to play passes to the next player.

The next player will begin their turn by drawing either the top card of the deck pile or the top card of the “trash” pile (the card discarded by the previous player). The player will then place their card face up in the correct location in their layout, if available, displacing the card that was there to its own location, and continue until they find an unplayable card, which they add to the top of the discard pile to end their turn.

Since Kings are wild, a King can be placed face up in any location containing a face down card, displacing the card that was there. Also a pip card whose correct location currently contains a face up King can be placed in that location displacing the King, which can then be moved to any other location with a face down card, displacing the card that was there. This app provides the user with the option of playing against a computer or against a friend.

How I built it

I used MIT app inventor for this project.

Challenges I ran into

Obviously, the hardest part of the coding process was allowing the computer to play against the user. The biggest problem was animating the movement of the cards so they moved at an acceptable speed, and also making the code so that the card the computer's card was moving to would flip over at the right time.

Accomplishments that I'm proud of

I'm proud of the fact that I was able to build up a card game from scratch that plays against a computer algorithm, which is actually a decent opponent.

What I learned

I learned how to write out algorithms first using pseudocode and strengthened my problem-solving abilites.

What's next for Trash Card Game

I'd say the next issue is making more of the code run in the app background, because there are some problems with the UI slowing down

Built With

Share this project:

Updates