6
2
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:
[value, suit]
For example [king, "clubs"]
The list of suits are:
- clubs
- spades
- diamonds
- hearts
The list of values are:
- 1
- 2
- 3 ....
- 11(jack)
- 12(queen)
- 13(king)
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 card_2_rem
The cards that have been played will be stored in a list called played_cards
The function will have to append the played card to the list called played_cards
and subtract the item for the list called card_1_rem
or card_2_rem
The return of one function will be the input of the competitor
The one who finishes his cards first, wins.
Winning Condition
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
will you play the programs against each other until a winner is clear to a statistically significant level? – Jonah – 2018-07-12T02:38:51.630
@Agile_Eagle I couldn't say without knowing the variance of that game. but if you graph the results over time you should be able to see the convergence. eg, say there are 5 programs competing. give each one a different color. let the y-axis be a competitors place, and let x be the number of rounds. at the beginning, the lines will jump up and down and intersect each other. eventually, all the lines will be parallel and stay that way. once that state is achieved, you'll know who the real winner is. – Jonah – 2018-07-12T04:19:46.847
1
Let us continue this discussion in chat.
– Agile_Eagle – 2018-07-12T04:20:20.0233https://www.pagat.com/layout/sevens.html (For anyone else that doesn't know the game and needs more detailed explanation.) – sundar - Reinstate Monica – 2018-07-12T10:50:57.297
1The bots should ideally just return the card played; it should be the responsibility of the controller to check that the intended move is vaild and make the appropriate changes to the game state. – user1502040 – 2018-07-13T23:53:45.567