Build a function in python that can win a Sevens game provided that there are only 2 players
Here are the instructions from Wikipedia:
All cards are dealt to the players, even if as a result some players have one card more than others. The owner of the seven of hearts begins by playing it. Similarly, the other three sevens may later be played as the first cards of their respective suits. After that, cards may be added in sequence down to the ace and up to the king. A player who cannot place a card passes.
You cannot pass if you have a card to play.
The one who gets the seven of hearts is the first to play.
The cards will be randomly distributed to the user and the computer.
The function will have two parameter:
- List of cards remaining to play for computer
- List cards that have been played
The syntax of a card is like this:
For example [king, "clubs"]
The list of suits are:
The list of values are:
- 3 ....
The remaining cards for player 1 will be stored in list named
card_1_rem and the remaining cards for player 2 will be stored in list named
The cards that have been played will be stored in a list called
The function will have to append the played card to the list called
played_cards and subtract the item for the list called
The return of one function will be the input of the competitor
The one who finishes his cards first, wins.
Step 1: Users will submit their programs.
Step 2: I will test the programs against each other.
Step 3: The first program to remain in first place (as measured by lowest total running score) for 50 consecutive games will be the winner. This will help smooth out the effects of luck. However, a maximum of 10000 games will be played, and if no player meets the first criterion, then the player with the lowest total score after 10000 games wins.
Step 4: All the results will be uploaded to a github repo(which I will soon make).
The loser has to count his points as follows
Ace : 1 2 : 2 3 : 3 4 : 4 5 : 5 6 : 6 7 : 7 8 : 8 9 : 9 10 : 10 jack : 10 queen : 10 king : 10
For example if a king and an ace remain in the loser's hand, he gets 11 point.
The objective is to minimize the points you have got.
Winner gets 0 points
IMP : Submissions are allowed only in the Python 3 language.
The controller code of this challenge is here(major update has been done): https://gist.github.com/Salil03/19a093554205b52d05dc7dc55992375a