I need a python script that will produce the optimal solution for a game called GoGo 21 that is based on BlackJack rules. Please see picture in attach.
The script will receive in input a list of 52 cards. The taxonomy is 2-3-4-5-6-7-8-9-10-J-Q-K-A.
The script needs to return in output a list with the sequence of where to put each card (column1, column2, column3, column4 or trash).
Please read carefully the game rules and point calculation. I want a script that produce the optimal solution to solve for the highest score based on the points calculation rules below.
I am a Python developer so I know how to read and write code, I just don't have time do to this.
1- CODE NEEDS TO BE WELL INDENTED AND COMMENTED
2- CODE WILL BE PLUGGED IN INTO ANOTHER SCRIPT
3- THE SOLVE FOR THE BEST SCORE PART WILL BE EXTENSIVELY TESTED
The goal is to place (or throw away) all 52 cards in the deck in one of the four columns on the card table to complete the round. You can only place or throw away one card at a time. The current card you have to place is the 'open' or card lying face up under the four columns. To the left of the deck you can see how many cards remain to be placed.
You can place each card in any column as long as the sum does not exceed 21; the sum of the column is presented above each column. When the column adds up to 21 the column will be cleared and you will receive points depending on the card combination you used. Columns where you can’t place the card will be dimmed down. If you can’t place the card you have to throw it away by clicking the trash can to the right of the deck. Try to keep the number of cards you throw away to a minimum, so you get a bigger bonus at the end of the round.
Just like in Black Jack an Ace can be worth 1 or 11, and the game automatically picks the suitable value trying to add up to 21 when possible. The Jacks, Queens and Kings are worth 10 and the other number cards are worth their face value.
There are 4 ways of combining cards to clear a column:
Standard 21: Any number of cards that add up to 21
Black Jack: You combine an Ace with any card worth 10
5 Card Charlie: 5 cards where the sum of the cards adds up to less than 21
Joker: The Joker will clear any column regardless of the value
The different combinations have different scoring values.
The base score for clearing a column starts at 100 points, and after that each time you clear a column it’s worth an additional 100 points. So the second time you clear a column it has a base score of 200 points and so on. Then for a Black Jack or a 5 Card Charlie combination you get an additional bonus on top of your base score. A Black Jack gives you additional points equal to the base score for that column being cleared, and a 5 Card Charlie gives you extra points equal to double the base score. Here’s an example of a series of cleared columns and their scores:
Clearing Type Base score Add on Total value
1 21 100 0 100
2 21 200 0 200
3 21 300 0 300
4 Black Jack 400 400 800
5 21 500 0 500
6 5 Card Charlie 600 1200 1800
7 Black Jack 700 700 1400
8 21 800 0 800
and so on.