I need to create this game in Python but I'm really confused on how to write the code!
The game Accordion is played with a deck of 52 cards. Beginning with one card, cards are laid out in a row to the right. As each card is played, its compared with cards before it. If its the same rank or suit as the card right to its left or 3 spaces to its left, it should be placed on top of that card (by user's command, of course). If moving this card made other moves possible, ask user if he wants to do that as well. Cards may only be moved to the left only 1 or 3 spaces. End the game with all the cards in a single pile. Replacing the cards instead of of placing one on top of another (in contrast with real card game)
Example: Ranks: ‘A’ - Ace, 2-10 - numbers, J - Jack, Q - Queen, K - King. Suits - S, H, C, D - Spades, Hearts, Clubs, Diamonds
7H 8C AD QC # No plays
7H 8C AD QC 8H # 8H can be moved 3 spaces to cover 8C
7H 8H AD QC # 8H can be moved 1 to cover 7H
8H AD QC # next card….
8H AD QS 8S # Should 8 be moved 1 or 3?
Player chooses.
Program specifications:
User should be able to use following functions:
'D' – Deal the next card from the top of the deck.
'M' 'card' 'num' - Move certain card certain number of spaces, 1 or 3. card should be the string representing a card—JH, 3D, etc. num must be 1 or 3. The move should be legal. If rules are violated, command has no effect and 'wrong move' is printed.
'H' – Print a list of all legal moves accordingly to the current game state.
'N' – Check the number of cards left in the deck.