added undo command
Tri Peaks is a solitaire card game that is akin to the solitaire games Golf and Black Hole. The game uses one deck and the object is to clear three peaks made up of cards.
The game starts with eighteen cards dealt face-down on the tableau to form three pyramids with three overlapping tiers each. Over these three pyramids are ten face-up cards.
The twenty-four remaining cards make up the stock. The first card from the stock is put in the waste pile. For a card in the tableau to be moved to the waste pile, it must be a rank higher or lower regardless of suit. This card becomes the new top card and the process is repeated several times (e.g. 7-8-9-10-9-10-J-10-9-8, etc.) until the sequence stops. Along the way, any face-down cards that are no longer overlapping are turned up.
In case the sequence is stopped, i.e. no card on the tableau can be put over the top card of the waste pile, a card is placed on the waste pile from the stock to see if it can start a new sequence. Cards are transferred from the stock to the waste pile one at a time as long as it does not begin a new sequence with the cards on the tableau.
The game is won if all three peaks are cleared before or after the last card from the stock is discarded to the waste pile. However, the game is lost if there are still cards that cannot be placed on the waste pile after the stock has run out.